mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 07:06:06 +09:00
new kana font and its tester, adjusting baselines of kana/cjkpunct/hangul, new color model 216 instead of 256, proof-of-concept factioning with four relationship models (amicable, neutral, hostile, fearful)
Former-commit-id: ac2ca8d0f4432377f1030afa6ac86df0c6887b3e Former-commit-id: 855f49d6c0e89da1e7311744683dc83e68ac84e4
This commit is contained in:
76
src/com/Torvald/ColourUtil/Col216.java
Normal file
76
src/com/Torvald/ColourUtil/Col216.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.Torvald.ColourUtil;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-11.
|
||||
*/
|
||||
public class Col216 implements LimitedColours {
|
||||
|
||||
private byte data;
|
||||
private static int[] LOOKUP = {0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public Col216(byte data) {
|
||||
create(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param r 0-5
|
||||
* @param g 0-5
|
||||
* @param b 0-5
|
||||
*/
|
||||
public Col216(int r, int g, int b) {
|
||||
create(r, g, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color createSlickColor(int raw) {
|
||||
assertRaw(raw);
|
||||
int r = LOOKUP[(raw / 36)];
|
||||
int g = LOOKUP[((raw % 36) / 6)];
|
||||
int b = LOOKUP[raw % 6];
|
||||
|
||||
return createSlickColor(r, g, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color createSlickColor(int r, int g, int b) {
|
||||
assertRGB(r, g, b);
|
||||
return new Color(LOOKUP[r], LOOKUP[g], LOOKUP[b]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int raw) {
|
||||
assertRaw(raw);
|
||||
data = (byte) raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int r, int g, int b) {
|
||||
assertRGB(r, g, b);
|
||||
data = (byte) (36 * r + 6 * g + b);
|
||||
}
|
||||
|
||||
public byte getRaw() { return data; }
|
||||
|
||||
private void assertRaw(int i) {
|
||||
if (i > 0xFF || i < 0) {
|
||||
System.out.println("i: " + String.valueOf(i));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRGB(int r, int g, int b) {
|
||||
if (r > 5 || g > 5 || b > 5 || r < 0 || g < 0 || b < 0) {
|
||||
System.out.println("r: " + String.valueOf(r));
|
||||
System.out.println("g: " + String.valueOf(g));
|
||||
System.out.println("b: " + String.valueOf(b));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.Torvald.ColourUtil;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-07.
|
||||
*
|
||||
* 3-3-2 256 colour RGB
|
||||
*/
|
||||
public class Col256 {
|
||||
|
||||
private byte data;
|
||||
|
||||
/**
|
||||
* Create new Col256 format.
|
||||
* @param data 0x00-0xFF
|
||||
*/
|
||||
public Col256(int data) {
|
||||
this.data = (byte) data;
|
||||
}
|
||||
|
||||
public Col256(int r, int g, int b) {
|
||||
if (r > 7 || g > 7 || b > 3) {
|
||||
throw new IllegalArgumentException("Colour range: RG: 0-7, B:0-4");
|
||||
}
|
||||
|
||||
data = (byte) (r << 5 | g << 2 | b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Col256 colour and convert it to Slick Color
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public Color create(int i) {
|
||||
if (i > 0xFF || i < 0) {
|
||||
throw new IllegalArgumentException("Colour range: #00 - #FF");
|
||||
}
|
||||
int r = (i & 0b11100000) >> 5;
|
||||
int g = (i & 0b00011100) >> 2;
|
||||
int b = i & 0b00000011;
|
||||
|
||||
return create(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Col256 colour and convert it to Slick Color
|
||||
* @return
|
||||
*/
|
||||
public Color create(int r, int g, int b) {
|
||||
if (r > 7 || g > 7 || b > 3) {
|
||||
throw new IllegalArgumentException("Colour range: RG: 0-7, B:0-4");
|
||||
}
|
||||
|
||||
int[] colIndex3 = {0, 36, 73, 109, 146, 182, 219, 255};
|
||||
int[] colIndex2 = {0, 85, 170, 255};
|
||||
|
||||
return new Color(
|
||||
colIndex3[r]
|
||||
, colIndex3[g]
|
||||
, colIndex2[b]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve raw RGB value
|
||||
* @return 0bRRRGGGBB
|
||||
*/
|
||||
public byte getByte() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,16 +7,26 @@ import org.newdawn.slick.Color;
|
||||
*
|
||||
* 12-bit RGB
|
||||
*/
|
||||
public class Col4096 {
|
||||
public class Col4096 implements LimitedColours {
|
||||
|
||||
private short data;
|
||||
|
||||
/**
|
||||
* Create new Col4096 format.
|
||||
* @param data 0xARGB
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public Col4096(int data) {
|
||||
this.data = (short) data;
|
||||
create(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param r 0-15
|
||||
* @param g 0-15
|
||||
* @param b 0-15
|
||||
*/
|
||||
public Col4096(int r, int g, int b) {
|
||||
create(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,12 +34,17 @@ public class Col4096 {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public Color create(int i) {
|
||||
public Color createSlickColor(int i) {
|
||||
assertRaw(i);
|
||||
|
||||
int a, r, g, b;
|
||||
|
||||
r = (i & 0xF00) >> 8;
|
||||
g = (i & 0x0F0) >> 4;
|
||||
b = i & 0x00F;
|
||||
|
||||
if (i > 0xFFF) {
|
||||
int a = (i & 0xF000) >> 12;
|
||||
int r = (i & 0x0F00) >> 8;
|
||||
int g = (i & 0x00F0) >> 4;
|
||||
int b = i & 0x000F;
|
||||
a = (i & 0xF000) >> 12;
|
||||
|
||||
return new Color(
|
||||
(r << 4) | r
|
||||
@@ -39,10 +54,6 @@ public class Col4096 {
|
||||
);
|
||||
}
|
||||
else {
|
||||
int r = (i & 0xF00) >> 8;
|
||||
int g = (i & 0x0F0) >> 4;
|
||||
int b = i & 0x00F;
|
||||
|
||||
return new Color(
|
||||
(r << 4) | r
|
||||
, (g << 4) | g
|
||||
@@ -51,6 +62,34 @@ public class Col4096 {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color createSlickColor(int r, int g, int b) {
|
||||
assertARGB(0, r, g, b);
|
||||
return createSlickColor(r << 8 | g << 4 | b);
|
||||
}
|
||||
|
||||
public Color createSlickColor(int a, int r, int g, int b) {
|
||||
assertARGB(a, r, g, b);
|
||||
return createSlickColor(a << 12 |r << 8 | g << 4 | b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int raw) {
|
||||
assertRaw(raw);
|
||||
data = (short) (raw & 0xFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int r, int g, int b) {
|
||||
assertARGB(0, r, g, b);
|
||||
data = (short) (r << 8 | g << 4 | b);
|
||||
}
|
||||
|
||||
public void create(int a, int r, int g, int b) {
|
||||
assertARGB(a, r, g, b);
|
||||
data = (short) (a << 12 | r << 8 | g << 4 | b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to 3 byte values, for raster imaging.
|
||||
* @return byte[RR, GG, BB] e.g. 0x4B3 -> 0x44, 0xBB, 0x33
|
||||
@@ -72,8 +111,25 @@ public class Col4096 {
|
||||
* Retrieve raw ARGB value
|
||||
* @return 0xARGB
|
||||
*/
|
||||
public short getShort() {
|
||||
public short getRaw() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private void assertRaw(int i) {
|
||||
if (i > 0xFFFF || i < 0) {
|
||||
System.out.println("i: " + String.valueOf(i));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertARGB(int a, int r, int g, int b) {
|
||||
if (a > 16 || r > 16 || g > 16 || b > 16 || r < 0 || g < 0 || b < 0 || a < 0) {
|
||||
System.out.println("a: " + String.valueOf(a));
|
||||
System.out.println("r: " + String.valueOf(r));
|
||||
System.out.println("g: " + String.valueOf(g));
|
||||
System.out.println("b: " + String.valueOf(b));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
18
src/com/Torvald/ColourUtil/LimitedColours.java
Normal file
18
src/com/Torvald/ColourUtil/LimitedColours.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.Torvald.ColourUtil;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-11.
|
||||
*/
|
||||
public interface LimitedColours {
|
||||
|
||||
|
||||
|
||||
Color createSlickColor(int raw);
|
||||
Color createSlickColor(int r, int g, int b);
|
||||
|
||||
void create(int raw);
|
||||
void create(int r, int g, int b);
|
||||
|
||||
}
|
||||
@@ -257,6 +257,9 @@ public class GameFontBase implements Font {
|
||||
+ getWidth(s.substring(0, i))
|
||||
)
|
||||
, Math.round(y)
|
||||
- ((prevInstance == SHEET_KANA) ? 2
|
||||
: (prevInstance == SHEET_CJK_PUNCT) ?
|
||||
1 : 0)
|
||||
, sheetX
|
||||
, sheetY
|
||||
);
|
||||
|
||||
36
src/com/Torvald/JsonGetter.java
Normal file
36
src/com/Torvald/JsonGetter.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.Torvald;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-15.
|
||||
*/
|
||||
public class JsonGetter {
|
||||
|
||||
private static String jsonString = new String();
|
||||
|
||||
public static JsonObject readJson(String jsonFileName) throws IOException {
|
||||
readJsonFileAsString(jsonFileName);
|
||||
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
JsonObject jsonObj = jsonParser.parse(jsonString).getAsJsonObject();
|
||||
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
private static void readJsonFileAsString(String path) throws IOException {
|
||||
Files.lines(
|
||||
FileSystems.getDefault().getPath(path)
|
||||
).forEach(JsonGetter::strAppend);
|
||||
}
|
||||
|
||||
private static void strAppend( String s) {
|
||||
jsonString += s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,10 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private final int CONTACT_AREA_BOTTOM = 2;
|
||||
private final int CONTACT_AREA_LEFT = 3;
|
||||
|
||||
private final int UD_COMPENSATOR_MAX = 100;
|
||||
private final int LR_COMPENSATOR_MAX = TSIZE;
|
||||
private final int TILE_CLIMB_RATE = 4;
|
||||
|
||||
/**
|
||||
* A constant to make falling faster so that the game is more playable
|
||||
*/
|
||||
@@ -261,6 +265,9 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (collidedRightAndAdjusted()) { // treat as 'event--collided right'
|
||||
veloX = 0;
|
||||
walledRight = true;
|
||||
|
||||
// TODO remove above two lines and implement tile climb (multi-frame calculation.)
|
||||
// Use variable TILE_CLIMB_RATE
|
||||
}
|
||||
else if (collidedLeftAndAdjusted()) { // treat as 'event--collided left'
|
||||
veloX = 0;
|
||||
@@ -351,7 +358,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private void adjustHitBottom() {
|
||||
int tY = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_BOTTOM, 0, 0);
|
||||
for (int lim = 0; lim < TSIZE; lim++) {
|
||||
for (int lim = 0; lim < UD_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
@@ -371,7 +378,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private void adjustHitTop() {
|
||||
int tY = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_TOP, 0, 0);
|
||||
for (int lim = 0; lim < TSIZE; lim++) {
|
||||
for (int lim = 0; lim < UD_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
@@ -391,7 +398,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private void adjustHitRight() {
|
||||
int tX = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_RIGHT, 0, 0);
|
||||
for (int lim = 0; lim < TSIZE; lim++) {
|
||||
for (int lim = 0; lim < LR_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
@@ -417,7 +424,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private void adjustHitLeft() {
|
||||
int tX = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_LEFT, 0, 0);
|
||||
for (int lim = 0; lim < TSIZE; lim++) {
|
||||
for (int lim = 0; lim < LR_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.JsonGetter;
|
||||
import com.Torvald.Rand.Fudge3;
|
||||
import com.Torvald.Rand.HQRNG;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -16,10 +17,9 @@ import java.nio.file.Files;
|
||||
public class CreatureBuildFactory {
|
||||
|
||||
private static final String JSONPATH = "./res/raw/";
|
||||
private static String jsonString = new String();
|
||||
|
||||
public ActorWithBody build(String jsonFileName) throws IOException, SlickException {
|
||||
JsonObject jsonObj = readJson(jsonFileName);
|
||||
JsonObject jsonObj = JsonGetter.readJson(JSONPATH + jsonFileName);
|
||||
ActorWithBody actor = new ActorWithBody();
|
||||
|
||||
|
||||
@@ -99,24 +99,4 @@ public class CreatureBuildFactory {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsFloat());
|
||||
}
|
||||
}
|
||||
|
||||
private JsonObject readJson(String jsonFileName) throws IOException {
|
||||
readJsonFileAsString(jsonFileName);
|
||||
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
JsonObject jsonObj = jsonParser.parse(jsonString).getAsJsonObject();
|
||||
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
private void readJsonFileAsString(String filename) throws IOException {
|
||||
Files.lines(
|
||||
FileSystems.getDefault().getPath(JSONPATH + filename)
|
||||
).forEach(this::strAppend);
|
||||
}
|
||||
|
||||
private void strAppend( String s) {
|
||||
jsonString += s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
88
src/com/Torvald/Terrarum/Actors/Faction/Faction.java
Normal file
88
src/com/Torvald/Terrarum/Actors/Faction/Faction.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.Torvald.Terrarum.Actors.Faction;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-15.
|
||||
*/
|
||||
public class Faction {
|
||||
|
||||
private String factionName;
|
||||
private HashSet<String> factionAmicable;
|
||||
private HashSet<String> factionNeutral;
|
||||
private HashSet<String> factionHostile;
|
||||
private HashSet<String> factionFearful;
|
||||
|
||||
public Faction(String factionName) {
|
||||
this.factionName = factionName;
|
||||
factionAmicable = new HashSet<>();
|
||||
factionNeutral = new HashSet<>();
|
||||
factionHostile = new HashSet<>();
|
||||
factionFearful = new HashSet<>();
|
||||
}
|
||||
|
||||
public HashSet<String> getFactionFearful() {
|
||||
return factionFearful;
|
||||
}
|
||||
|
||||
public void setFactionFearful(HashSet<String> factionFearful) {
|
||||
this.factionFearful = factionFearful;
|
||||
}
|
||||
|
||||
public HashSet<String> getFactionAmicable() {
|
||||
return factionAmicable;
|
||||
}
|
||||
|
||||
public void setFactionAmicable(HashSet<String> factionAmicable) {
|
||||
this.factionAmicable = factionAmicable;
|
||||
}
|
||||
|
||||
public HashSet<String> getFactionNeutral() {
|
||||
return factionNeutral;
|
||||
}
|
||||
|
||||
public void setFactionNeutral(HashSet<String> factionNeutral) {
|
||||
this.factionNeutral = factionNeutral;
|
||||
}
|
||||
|
||||
public HashSet<String> getFactionHostile() {
|
||||
return factionHostile;
|
||||
}
|
||||
|
||||
public void setFactionHostile(HashSet<String> factionHostile) {
|
||||
this.factionHostile = factionHostile;
|
||||
}
|
||||
|
||||
public void addFactionAmicable(String faction) {
|
||||
factionAmicable.add(faction);
|
||||
}
|
||||
|
||||
public void addFactionNeutral(String faction) {
|
||||
factionNeutral.add(faction);
|
||||
}
|
||||
|
||||
public void addFactionHostile(String faction) {
|
||||
factionHostile.add(faction);
|
||||
}
|
||||
|
||||
public void addFactionFearful(String faction) {
|
||||
factionFearful.add(faction);
|
||||
}
|
||||
|
||||
public void removeFactionAmicable(String faction) {
|
||||
factionAmicable.remove(faction);
|
||||
}
|
||||
|
||||
public void removeFactionNeutral(String faction) {
|
||||
factionNeutral.remove(faction);
|
||||
}
|
||||
|
||||
public void removeFactionHostile(String faction) {
|
||||
factionHostile.remove(faction);
|
||||
}
|
||||
|
||||
public void removeFactionFearful(String faction) {
|
||||
factionFearful.remove(faction);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.Torvald.Terrarum.Actors.Faction;
|
||||
|
||||
import com.Torvald.JsonGetter;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-15.
|
||||
*/
|
||||
public class FactionRelatorFactory {
|
||||
|
||||
private static final String JSONPATH = "./res/raw/";
|
||||
|
||||
public Faction build(String filename) throws IOException {
|
||||
JsonObject jsonObj = JsonGetter.readJson(JSONPATH + filename);
|
||||
Faction factionObj = new Faction(jsonObj.get("factionname").getAsString());
|
||||
|
||||
|
||||
jsonObj.get("factionamicable").getAsJsonArray().forEach(
|
||||
s -> factionObj.addFactionAmicable(s.getAsString())
|
||||
);
|
||||
jsonObj.get("factionneutral").getAsJsonArray().forEach(
|
||||
s -> factionObj.addFactionNeutral(s.getAsString())
|
||||
);
|
||||
jsonObj.get("factionhostile").getAsJsonArray().forEach(
|
||||
s -> factionObj.addFactionHostile(s.getAsString())
|
||||
);
|
||||
jsonObj.get("factionfearful").getAsJsonArray().forEach(
|
||||
s -> factionObj.addFactionFearful(s.getAsString())
|
||||
);
|
||||
|
||||
return factionObj;
|
||||
}
|
||||
|
||||
}
|
||||
17
src/com/Torvald/Terrarum/Actors/Factionable.java
Normal file
17
src/com/Torvald/Terrarum/Actors/Factionable.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-15.
|
||||
*/
|
||||
public interface Factionable {
|
||||
|
||||
void assignFaction(Faction f);
|
||||
void unassignFaction(Faction f);
|
||||
HashSet<Faction> getAssignedFactions();
|
||||
void clearFactionAssigning();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.GameControl.EnumKeyFunc;
|
||||
import com.Torvald.Terrarum.GameControl.KeyMap;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
@@ -12,11 +13,12 @@ import org.lwjgl.input.Controllers;
|
||||
import org.newdawn.slick.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
public class Player extends ActorWithBody implements Controllable, Pocketed, Serializable {
|
||||
public class Player extends ActorWithBody implements Controllable, Pocketed, Factionable {
|
||||
|
||||
@Nullable public Controllable vehicleRiding;
|
||||
|
||||
@@ -48,6 +50,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Ser
|
||||
private final float AXIS_POSMAX = 1.0f;
|
||||
private final int GAMEPAD_JUMP = 5;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). <br />
|
||||
*
|
||||
@@ -111,10 +115,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Ser
|
||||
);
|
||||
|
||||
// Heading flag
|
||||
if (left)
|
||||
walkHeading = LEFT;
|
||||
else
|
||||
walkHeading = RIGHT;
|
||||
if (left) walkHeading = LEFT;
|
||||
else walkHeading = RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,4 +514,23 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Ser
|
||||
return spriteGlow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignFaction(Faction f) {
|
||||
factionSet.add(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unassignFaction(Faction f) {
|
||||
factionSet.remove(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<Faction> getAssignedFactions() {
|
||||
return factionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFactionAssigning() {
|
||||
factionSet.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,48 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.GameItem.InventoryItem;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-31.
|
||||
*/
|
||||
public class TestNPC extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem {
|
||||
public class TestNPC extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem,
|
||||
Factionable {
|
||||
|
||||
private InventoryItem itemData;
|
||||
// private ActorAI ai;
|
||||
private ActorInventory inventory;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void attachAI() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignFaction(Faction f) {
|
||||
factionSet.add(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unassignFaction(Faction f) {
|
||||
factionSet.remove(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<Faction> getAssignedFactions() {
|
||||
return factionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFactionAssigning() {
|
||||
factionSet.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachItemData() {
|
||||
itemData = new InventoryItem() {
|
||||
|
||||
@@ -27,6 +27,7 @@ public class CommandDict {
|
||||
dict.put("teleport", new TeleportPlayer());
|
||||
dict.put("cat", new CatStdout());
|
||||
dict.put("exportav", new ExportAV());
|
||||
dict.put("gsontest", new GsonTest());
|
||||
}
|
||||
|
||||
public static ConsoleCommand getCommand(String commandName) {
|
||||
|
||||
48
src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java
Normal file
48
src/com/Torvald/Terrarum/ConsoleCommand/GsonTest.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-10.
|
||||
*/
|
||||
public class GsonTest implements ConsoleCommand {
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
if (args.length == 2) {
|
||||
JsonElement avelem = new Gson().toJsonTree(Terrarum.game.getPlayer());
|
||||
|
||||
String jsonString = avelem.toString();
|
||||
|
||||
BufferedWriter bufferedWriter;
|
||||
FileWriter writer;
|
||||
try {
|
||||
writer = new FileWriter(Terrarum.defaultDir + "/Exports/" + args[1] + ".json");
|
||||
bufferedWriter = new BufferedWriter(writer);
|
||||
|
||||
bufferedWriter.write(jsonString);
|
||||
bufferedWriter.close();
|
||||
|
||||
new Echo().execute("GsonTest: exported to " + args[1] + ".json");
|
||||
}
|
||||
catch (IOException e) {
|
||||
new Echo().execute("GsonTest: IOException raised.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
Echo echo = new Echo();
|
||||
echo.execute("Usage: gsontest filename-without-extension");
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class MapCamera {
|
||||
private static final byte ICE_MAGICAL = 30;
|
||||
|
||||
private static Byte[] TILES_CONNECT_SELF = {
|
||||
COPPER
|
||||
COPPER
|
||||
, IRON
|
||||
, GOLD
|
||||
, SILVER
|
||||
@@ -78,7 +78,7 @@ public class MapCamera {
|
||||
};
|
||||
|
||||
private static Byte[] TILES_DARKEN_AIR = {
|
||||
STONE
|
||||
STONE
|
||||
, DIRT
|
||||
, GRASS
|
||||
, SAND
|
||||
@@ -97,8 +97,10 @@ public class MapCamera {
|
||||
* i.e. red hues get lost if you dive into the water
|
||||
*/
|
||||
private static Byte[] TILES_BLEND_MUL = {
|
||||
(byte)224, (byte)225, (byte)226, (byte)227, (byte)228, (byte)229, (byte)230, (byte)231
|
||||
, (byte)232, (byte)233, (byte)234, (byte)235, (byte)236, (byte)237, (byte)238, (byte)239
|
||||
(byte)224, (byte)225, (byte)226, (byte)227, (byte)228, (byte)229, (byte)230, (byte)231
|
||||
, (byte)232, (byte)233, (byte)234, (byte)235, (byte)236, (byte)237, (byte)238, (byte)239
|
||||
, (byte)240, (byte)241, (byte)242, (byte)243, (byte)244, (byte)245, (byte)246, (byte)247
|
||||
, (byte)248, (byte)249, (byte)250, (byte)251, (byte)252, (byte)253, (byte)254, (byte)255
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user