merge
This commit is contained in:
commit
247c8aed5c
3 changed files with 35 additions and 9 deletions
|
@ -79,6 +79,11 @@ public class Die extends Actor {
|
||||||
return getFaceValue() <= 0;
|
return getFaceValue() <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFace(Face face) {
|
||||||
|
faces[faceIndex] = face;
|
||||||
|
face.setTransform(transform);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,10 @@ public class Face extends Actor{
|
||||||
transform.setSize(w, h);
|
transform.setSize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTransform(Transform transform) {
|
||||||
|
this.transform = transform;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setBlankFaceSprite(Texture sprite){
|
public static void setBlankFaceSprite(Texture sprite){
|
||||||
blankFaceSprite = sprite;
|
blankFaceSprite = sprite;
|
||||||
}
|
}
|
||||||
|
@ -103,10 +107,6 @@ public class Face extends Actor{
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransform(Transform transform) {
|
|
||||||
this.transform = transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 calculatePipLocation(Vector2 percentages) {
|
public Vector2 calculatePipLocation(Vector2 percentages) {
|
||||||
double radians = Math.toRadians(transform.rotation);
|
double radians = Math.toRadians(transform.rotation);
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ public class Face extends Actor{
|
||||||
face.setOrigin(face.getWidth()/2, face.getHeight()/2);
|
face.setOrigin(face.getWidth()/2, face.getHeight()/2);
|
||||||
face.rotate(transform.getRotation());
|
face.rotate(transform.getRotation());
|
||||||
face.setPosition(transform.x-face.getWidth()/2, transform.y-face.getHeight()/2);
|
face.setPosition(transform.x-face.getWidth()/2, transform.y-face.getHeight()/2);
|
||||||
|
|
||||||
face.draw(batch);
|
face.draw(batch);
|
||||||
|
|
||||||
for(Pip pip : pips){
|
for(Pip pip : pips){
|
||||||
|
|
|
@ -107,16 +107,32 @@ public class Game extends ApplicationAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode
|
int shopeIndex = -1;
|
||||||
|
if (input.isKeyJustPressed(Input.Keys.I)) shopeIndex = 0;
|
||||||
|
else if (input.isKeyJustPressed(Input.Keys.O)) shopeIndex = 1;
|
||||||
|
else if (input.isKeyJustPressed(Input.Keys.P)) shopeIndex = 2;
|
||||||
|
|
||||||
|
List<Die> selected = getSelectedDice();
|
||||||
|
if (selected.size() == 1 && shopeIndex != -1) {
|
||||||
|
Face face = getShopeIndex(shopeIndex);
|
||||||
|
|
||||||
|
if (face != null) {
|
||||||
|
Die die = selected.get(0);
|
||||||
|
die.setFace(face);
|
||||||
|
removeShopeIndex(shopeIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < dice.size(); i++) { //buy for or select dice, iterating over for each keycode
|
||||||
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current die, 1, 2...9, 0 on keyboard
|
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current die, 1, 2...9, 0 on keyboard
|
||||||
|
|
||||||
if (input.isKeyJustPressed(keyCode)) { //if key corresponding to die has been pressed
|
if (!input.isKeyJustPressed(keyCode)) continue;
|
||||||
|
|
||||||
Die die = dice.get(i); //die iterator is looking at
|
Die die = dice.get(i); //die iterator is looking at
|
||||||
die.setSelected(!die.isSelected()); //flip lock state
|
die.setSelected(!die.isSelected()); //flip lock state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void reroll() {
|
private void reroll() {
|
||||||
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
||||||
|
@ -220,6 +236,10 @@ public class Game extends ApplicationAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Face getShopeIndex(int index) {
|
||||||
|
return shope.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeShopeIndex(int index) {
|
public void removeShopeIndex(int index) {
|
||||||
shope.remove(index);
|
shope.remove(index);
|
||||||
shope.add(index, null);
|
shope.add(index, null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue