Added support for entity animation chaining

This commit is contained in:
Collin Smith 2019-03-05 14:57:25 -08:00
parent 5540c6436c
commit 87e95ad1aa
3 changed files with 23 additions and 3 deletions

View File

@ -189,6 +189,10 @@ public class Animation extends BaseDrawable {
}
}
public boolean isFinished() {
return frame == numFrames - 1;
}
public boolean isLooping() {
return looping;
}

View File

@ -126,6 +126,7 @@ public class Entity {
int dirty;
String mode;
String code;
String mode2;
String layers[];
String weaponClass;
Vector3 position = new Vector3();
@ -228,6 +229,11 @@ public class Entity {
return (byte) 0xFF;
}
public void animate(String mode1, String mode2) {
setMode(mode1);
this.mode2 = mode2;
}
public Vector3 position() {
return position;
}
@ -532,6 +538,10 @@ public class Entity {
animation.draw(batch, x, y);
updateLabel(label, x, y);
//if (over) drawLabel(batch);
if (mode2 != null && animation.isFinished()) {
setMode(mode2);
mode2 = null;
}
}
protected void updateLabel(Label label, float x, float y) {

View File

@ -90,7 +90,7 @@ public class StaticEntity extends Entity {
case 9 : case 10: case 11: case 12: case 13: case 14: case 15: case 16:
break;
case 17: // waypoint
// TODO: Automatically sets on
// TODO: Set ON based on save file
setMode("ON");
break;
case 18:
@ -107,6 +107,12 @@ public class StaticEntity extends Entity {
}
}
@Override
public void animate(String mode1, String mode2) {
assert !base.CycleAnim[Diablo.files.ObjMode.index(mode1)];
super.animate(mode1, mode2);
}
private void operate(GameScreen gameScreen) {
switch (base.OperateFn) {
case 0:
@ -117,8 +123,8 @@ public class StaticEntity extends Entity {
break;
case 23: // waypoint
if (mode.equalsIgnoreCase("NU")) {
setMode("OP");
//setMode("OP".."ON");
animate("OP", "ON");
Diablo.audio.play("object_waypoint_open", true);
}
break;
case 24: case 25: case 26: case 27: case 28: case 29: