public override void UpdateState(Game game) { if (elfState != null) { bool stopPlan = false; if (elfState.step == ElfPlanState.Step.SpeedUp) { if (elfState.elf.HasSpeedUp()) { elfState.step = ElfPlanState.Step.Movement; } else { stopPlan = true; } } else if (elfState.step == ElfPlanState.Step.Movement) { Location expectedLocation = elfState.elf.GetLocation().Towards(elfState.targetLocation, elfState.elf.MaxSpeed); if (elfState.elf.GetLocation().Distance(expectedLocation) > Constants.Game.ElfMaxSpeed) { stopPlan = true; } if (stopPlan) { ElfMoveTargets.RemoveHeuristicCircle(GetType().Name); elfState = null; } } } if (elfState == null && Constants.GameCaching.GetEnemyManaFountains().Length == 1) { foreach (Elf elf in Constants.Game.GetMyLivingElves()) { ManaFountain suitableTargetManaFountain = FindSuitableManaFountain(elfState.elf); if (suitableTargetManaFountain != null) { elfState = CreateElfState(elf, suitableTargetManaFountain); ElfMoveTargets.AddHeuristicCircleWithTurnLimit(GetType().Name, new Circle(elfState.targetLocation, Constants.Game.ManaFountainSize + Constants.Game.ElfAttackRange), numOfTurns); break; } } } }
public virtual void PreDoTurn(Game game) { ElfMoveTargets.ClearOutdatedTargets(); }