public static void RushFountain(Elf e) { ManaFountain fountain; e.ShouldTargetFountain(out fountain); if (e.InRange(fountain, e.MaxSpeed * 2)) { double savingDuration = 1.0 * (GameState.Game.InvisibilityCost - GameState.CurrentMana) / GameState.Game.GetMyself().ManaPerTurn; savingDuration = System.Math.Ceiling(savingDuration); int duration = (int)System.Math.Max(savingDuration, 1); if (!e.SafeNotToMove(duration)) { if (GameState.HasManaFor(CreatableObject.Invisibility)) { e.CastInvisibility(); } else { GameState.SaveManaFor(CreatableObject.Invisibility); } } } if (!e.AlreadyActed && e.ShouldAttack(fountain) && e.InAttackRange(fountain)) { e.Attack(fountain); } else if (!e.AlreadyActed) { MissionExtensions.MoveTargets[e] = fountain; Mission.MoveToTarget.ExecuteWith(e); } }
public override void DoGameAction() { Elf elf = (Elf)gameObject; elf.CastInvisibility(); }