コード例 #1
0
 void DoSomething()
 {
     if (DefsById.Count >= MinTanksForAttack)  // make sure at least have a few units before attacking
     {
         Float3 approximateattackpos = LastAttackPos;
         if (approximateattackpos == null)
         {
             foreach (int id in DefsById.Keys)
             {
                 Float3 thispos = aicallback.GetUnitPos(id);
                 if (thispos != null)
                 {
                     approximateattackpos = thispos;
                 }
             }
             //approximateattackpos = aicallback.GetUnitPos(DefsById.Keys.GetEnumerator().Current);
         }
         logfile.WriteLine("tankcontroller approximateattackpos: " + approximateattackpos);
         Float3 nearestenemypos = enemyselector.ChooseAttackPoint(approximateattackpos);
         if (nearestenemypos != null)
         {
             attackpackcoordinator.SetTarget(nearestenemypos);
             packcoordinatorselector.ActivatePackCoordinator(attackpackcoordinator);
             LastAttackPos = nearestenemypos;
         }
         else
         {
             if (DefsById.Count > MinTanksForSpreadSearch)
             {
                 spreadsearchpackcoordinator.SetTarget(nearestenemypos);
                 packcoordinatorselector.ActivatePackCoordinator(spreadsearchpackcoordinator);
             }
             else
             {
                 if (unitcontroller.UnitDefsByName.ContainsKey("armcom"))
                 {
                     guardpackcoordinator.SetTarget(unitcontroller.UnitDefsByName["armcom"][0].id);
                     packcoordinatorselector.ActivatePackCoordinator(guardpackcoordinator);
                 }
             }
         }
     }
     else
     {
         if (unitcontroller.UnitDefsByName.ContainsKey("armcom"))
         {
             guardpackcoordinator.SetTarget(unitcontroller.UnitDefsByName["armcom"][0].id);
             packcoordinatorselector.ActivatePackCoordinator(guardpackcoordinator);
         }
     }
 }
コード例 #2
0
        void DoSomething()
        {
            if (TankDefsById.Count >= MinTanksForAttack)  // make sure at least have a few units before attacking
            {
                Float3 approximateattackpos = LastAttackPos;
                if (approximateattackpos == null)
                {
                    approximateattackpos = CommanderController.GetInstance().GetCommanderPos();
                }

                Float3 nearestenemypos = enemyselector.ChooseAttackPoint(approximateattackpos);
                if (nearestenemypos != null)
                {
                    attackpackcoordinator.SetTarget(nearestenemypos);
                    packcoordinatorselector.ActivatePackCoordinator(attackpackcoordinator);
                    LastAttackPos = nearestenemypos;
                }
                else
                {
                    if (TankDefsById.Count > MinTanksForSpreadSearch)
                    {
                        spreadsearchpackcoordinator.SetTarget(nearestenemypos);
                        packcoordinatorselector.ActivatePackCoordinator(spreadsearchpackcoordinator);
                    }
                    else
                    {
                        guardpackcoordinator.SetTarget(CommanderController.GetInstance().commanderid);
                        packcoordinatorselector.ActivatePackCoordinator(guardpackcoordinator);
                        // movetopackcoordinator.SetTarget( CommanderController.GetInstance().GetCommanderPos() );
                        //packcoordinatorselector.ActivatePackCoordinator( movetopackcoordinator );
                    }
                }
            }
            else
            {
                guardpackcoordinator.SetTarget(CommanderController.GetInstance().commanderid);
                packcoordinatorselector.ActivatePackCoordinator(guardpackcoordinator);
                //movetopackcoordinator.SetTarget( CommanderController.GetInstance().GetCommanderPos() );
                //packcoordinatorselector.ActivatePackCoordinator( movetopackcoordinator );
            }
        }