void UpdateFleeing() { if (!character.moveToTarget(fleePosition, character.speed * 1.5f)) { currentRangedState = RangedAttackStates.IDLE; } }
void StartFleeing(RangedAttackStates previousState) { float xPos = character.getFeetPosition().x; float d1 = Mathf.Abs(-2.0f - xPos); float d2 = Mathf.Abs(2.0f - xPos); fleePosition = character.getFeetPosition(); fleePosition.x = (d1 > d2)?-2.0f:2.0f; currentState = Attack.AttackStates.RUNNING; }
public void CheckIfMustFlee() { if (hitsToFlee <= 0) { return; } BasicEnemy e = character as BasicEnemy; if (e.numHits >= hitsToFlee) { e.numHits = 0; currentRangedState = RangedAttackStates.FLEEING; } }
void UpdateFollowing() { Hero h = character.currentTarget as Hero; BasicEnemy e = character as BasicEnemy; Vector2 diff = h.getFeetPosition() - e.getFeetPosition(); OrientCharacter(diff.x); if (InAttackRange(diff.magnitude)) { currentRangedState = RangedAttackStates.ATTACKING; } else { character.moveToTarget(h, e.speed); } }
void UpdateIdle() { Hero h = character.currentTarget as Hero; BasicEnemy e = character as BasicEnemy; Vector2 diff = h.getFeetPosition() - e.getFeetPosition(); OrientCharacter(diff.x); if (InAttackRange(diff.magnitude)) { if (rechargeTimer <= 0.0f) { currentRangedState = RangedAttackStates.ATTACKING; } } else { currentRangedState = RangedAttackStates.FOLLOWING; } }
public override void onEndAttack() { currentRangedState = RangedAttackStates.IDLE; base.onEndAttack(); }
void StartAttacking(RangedAttackStates previousState) { currentState = Attack.AttackStates.ATTACKING; }
void StartFollowing(RangedAttackStates previousState) { currentState = Attack.AttackStates.RUNNING; }
void StartIdle(RangedAttackStates previousState) { currentState = Attack.AttackStates.IDLE; }