예제 #1
0
 void MakeTurn() //AI script to make actions on it's turn
 {
     if (Player.turnCount == 1)
     {
         houses.lvlUp();
         townhall.lvlUp();
     }
     if (behaviour) //if this AI is "builder" type
     {
         if (Player.turnCount % Random.Range(3, 7) == 0 && player.money > 500)
         {
             houses.lvlUp();
             townhall.lvlUp();
         }
         if (Player.turnCount % Random.Range(7, 9) == 0)
         {
             walls.lvlUp();
             barracks.lvlUp();
             for (int i = 0; i < 5; i++)
             {
                 army.HireCavalry();
                 army.HireInfantry();
                 army.HireShooter();
                 army.HireRookie();
             }
         }
         if (Player.turnCount % Random.Range(20, 30) == 0)
         {
             crusade.ConfirmCrusade(army.rookie / 2, army.shooter / 2, army.infantry / 2, army.cavalry / 2);
             rnd = Random.Range(0, 100);
         }
     }
     else //if this AI is "aggressive" type
     {
         if (player.money > 300)
         {
             barracks.lvlUp();
             for (int i = 0; i < 5; i++)
             {
                 army.HireCavalry();
                 army.HireInfantry();
                 army.HireShooter();
                 army.HireRookie();
             }
         }
         if (Player.turnCount % Random.Range(5, 9) == 0)
         {
             townhall.lvlUp();
             houses.lvlUp();
             if (!crusade.Crusade)
             {
                 crusade.ConfirmCrusade(army.rookie * 3 / 4, army.shooter, army.infantry, army.cavalry);
                 rnd = Random.Range(0, 100);
             }
         }
     }
     if (crusade.Crusade)
     {
         if (rnd <= 33 && player.Enemy1.gameObject.activeSelf)
         {
             attackPoint = player.Enemy1.crusade.CrusadeSquad.transform.localPosition;
         }
         else if (rnd > 33 && rnd <= 66 && player.Enemy2.gameObject.activeSelf)
         {
             attackPoint = player.Enemy2.crusade.CrusadeSquad.transform.localPosition;
         }
         else if (rnd > 66 && rnd <= 100 && player.Enemy3.gameObject.activeSelf)
         {
             attackPoint = player.Enemy3.crusade.CrusadeSquad.transform.localPosition;
         }
         else if (player.Enemy1.gameObject.activeSelf)
         {
             attackPoint = player.Enemy1.crusade.CrusadeSquad.transform.localPosition;
         }
         else if (player.Enemy2.gameObject.activeSelf)
         {
             attackPoint = player.Enemy2.crusade.CrusadeSquad.transform.localPosition;
         }
         else if (player.Enemy3.gameObject.activeSelf)
         {
             attackPoint = player.Enemy3.crusade.CrusadeSquad.transform.localPosition;
         }
         MoveToAttack(attackPoint);
     }
     player.EndTurn();
     army.EndTurn();
     crusade.EndTurn();
 }