Esempio n. 1
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();
            }