public override State Update(float delta) { timePassed += delta; attacker.Animate(attacker.ProvideAction()); if (timePassed >= timer) { timePassed = 0; Action currentAction = attacker.ProvideAction(); attacker.Reset(); GD.Print("Recorded action " + currentAction.ToString()); --actionsCount; if (currentAction != Action.Timeout) { actions.Add(currentAction); } if (actionsCount <= 0) { return(new PreNegateState(controller, actions)); } } return(this); }
public DeathState(BaseController controller, IActionProvider deadman) { this.deadman = deadman; this.controller = controller; timePassed = 0; deadman.Reset(); koSound = (AudioStreamPlayer)this.controller.GetNode("Sounds").GetNode("KOSound"); koSound.Play(); deadman.Animate(Action.Death); controller.ResetKOLabel(); }
public override State Update(float delta) { if (recordedActions.Count == 0) { return(new PreRecordState(controller, ++controller.Turn)); } if (defender.IsPerformingAction || attacker.IsPerformingAction) { return(this); } if (iterator >= recordedActions.Count) { return(new PreRecordState(controller, ++controller.Turn)); } Action negativeAction = (Action)(-(int)defender.ProvideAction()); if (negativeAction != Action.Timeout) { defender.Animate(defender.ProvideAction()); attacker.Animate(recordedActions[iterator]); timePassed = 0; if (negativeAction == recordedActions[iterator]) { GD.Print("OK"); evadeSound.Play(); } else { GD.Print("Wrong action! " + negativeAction.ToString()); --defender.Health; gruntSound.Play(); defender.Blood.SetEmitting(true); GD.Print("HP " + defender.Health); if (defender.Health <= 0) { GD.Print("Game over"); return(new DeathState(controller, defender)); } } ++iterator; } else { timePassed += delta; if (timePassed >= timer) { timePassed = 0; GD.Print("Timeout!"); attacker.Animate(recordedActions[iterator]); --defender.Health; gruntSound.Play(); defender.Blood.SetEmitting(true); GD.Print("HP " + defender.Health); if (defender.Health <= 0) { GD.Print("Game over"); return(new DeathState(controller, defender)); } ++iterator; } } return(this); }