示例#1
0
 void AttemptMoveAttack(CreatureBase creature)
 {
     if (creature != null)
     {
         List <CreatureBase> searchTargetCreatures = creature.ActiveLaneNode.laneManager.SearchRange((int)creature.Range, creature.ActiveLaneNode, this);
         bool foundAttackTarget = false;
         foreach (CreatureBase _creature in searchTargetCreatures)
         {
             if (_creature.Owner != creature.Owner)   //Found enemy creature in range
             {
                 foundAttackTarget = true;
                 AIResponse.Attack(creature);
             }
         }
         if (!foundAttackTarget)
         {
             int moveSpaces = creature.ActiveLaneNode.laneManager.GetOpenNodes(creature.ActiveLaneNode, _RightFacing);
             if (moveSpaces > AIResponse.Tokens)
             {
                 moveSpaces = AIResponse.Tokens;
             }
             if (AIResponse.Move(creature, moveSpaces))
             {
                 LogStack.Log("Hal Move " + creature.GetInstanceID() + " - " + moveSpaces + " spaces - " + creature.LaneProgress, LogLevel.System);
             }
         }
     }
 }
示例#2
0
            public override void OnTick(IBoardState[] data)
            {
                AIResponse.onTick(null);

                var maxCycles = 99;

                Initialize();

                while (AIResponse.Tokens > 0 && maxCycles > 0)
                {
                    if (CheckIfAlliesAreInAttackingDistance())
                    {
                        continue;
                    }



                    SpawnEnemy();


                    CreatureBase FarthestLane1Ally = null;
                    CreatureBase FarthestLane2Ally = null;
                    CreatureBase FarthestLane3Ally = null;

                    if (TournamentManager._instance.lanes[0].GetFriendliesInLane(this).Count > 0)
                    {
                        FarthestLane1Ally = TournamentManager._instance.lanes[0].GetFriendliesInLane(this)[0];
                        if (FarthestLane1Ally != null && !friendlyBases.Contains(FarthestLane1Ally))
                        {
                            friendlyBases.Add(FarthestLane1Ally);
                        }
                    }

                    if (TournamentManager._instance.lanes[1].GetFriendliesInLane(this).Count > 0)
                    {
                        FarthestLane2Ally = TournamentManager._instance.lanes[1].GetFriendliesInLane(this)[0];
                        if (FarthestLane2Ally != null && !friendlyBases.Contains(FarthestLane2Ally))
                        {
                            friendlyBases.Add(FarthestLane2Ally);
                        }
                    }

                    if (TournamentManager._instance.lanes[2].GetFriendliesInLane(this).Count > 0)
                    {
                        FarthestLane3Ally = TournamentManager._instance.lanes[2].GetFriendliesInLane(this)[0];
                        if (FarthestLane3Ally != null && !friendlyBases.Contains(FarthestLane3Ally))
                        {
                            friendlyBases.Add(FarthestLane3Ally);
                        }
                    }


                    var          farthsetAlong    = 0;
                    CreatureBase withMostProgress = null;


                    foreach (var creatureBase in friendlyBases)
                    {
                        if (creatureBase != null && creatureBase.LaneProgress > farthsetAlong ||
                            withMostProgress.isDead)
                        {
                            farthsetAlong = creatureBase.LaneProgress;

                            withMostProgress = creatureBase;
                        }
                    }

                    Debug.Log("Further: " +
                              (withMostProgress != null ? withMostProgress.GetInstanceID().ToString() : " NULL"));


                    CreatureBase canFinish = null;

                    foreach (var creature in _Creatures)
                    {
                        int remaining = creature.LaneProgress - 10;

                        if (remaining <= 10)
                        {
                            canFinish = creature;
                        }
                    }


                    if (CheckIfCreatureCanFinish(canFinish))
                    {
                        Debug.Log("Finish");
                    }
                    else
                    {
                        CheckIfClosestenemyIsInAttackingrange(withMostProgress);
                    }



                    maxCycles--;
                }


                AIResponse.FinalizeResponse();
            }