public void DoAI(FactionScript faction)
    {
        foreach(ArmyCounter army in faction.m_armies)
        {
            if(!army.HasPath)
            {
                bool success = false;

                while(!success)
                {
                    int x = (int)(Random.value * m_worldGrid.TileCountX);
                    int y = (int)(Random.value * m_worldGrid.TileCountY);

                    WorldTileScript tile = m_worldGrid.GetTile(x, y);

                    if(tile.IsPassable)
                    {
                        success = true;
                        if(army == faction.HomeArmy)
                        {
                            army.SetObjective(tile);
                        }
                        else
                        {
                            bool hasOrders = false;
                            foreach(OrdersCourierScript courier in faction.m_orders)
                            {
                                if(courier.TargetArmy == army)
                                {
                                    hasOrders = true;
                                    break;
                                }
                            }
                            if(hasOrders)
                            {
                                continue;
                            }

                            Transform ordersOrigin = faction.HomeArmy.transform;
                            Transform orders = (Transform)Instantiate(OrdersPrefab, ordersOrigin.position, ordersOrigin.rotation);
                            OrdersCourierScript os = orders.gameObject.GetComponent<OrdersCourierScript>();
                            os.TargetArmy = army;
                            os.TargetArmyNewObjective = tile;
                            os.Faction = faction;
                            os.Tile = faction.HomeArmy.Tile;
                            faction.m_orders.Add(os);
                        }
                    }
                }
            }
        }
    }
예제 #2
0
 void Update()
 {
     if (faction == Faction.Player)
     {
         ownerFaction = gameManager.player;
     }
     else if (faction == Faction.Blue)
     {
         ownerFaction = gameManager.blue;
     }
     else if (faction == Faction.Red)
     {
         ownerFaction = gameManager.red;
     }
     else if (faction == Faction.Green)
     {
         ownerFaction = gameManager.green;
     }
 }
예제 #3
0
파일: Boat.cs 프로젝트: Boothand/Galapagame
    internal override void BaseUpdate()
    {
        base.BaseUpdate();

        if (stats.faction == Stats.Faction.Player)
        {
            myFaction = gameManager.player;
        }
        else if (stats.faction == Stats.Faction.Blue)
        {
            myFaction = gameManager.blue;
        }
        else if (stats.faction == Stats.Faction.Red)
        {
            myFaction = gameManager.red;
        }
        else if (stats.faction == Stats.Faction.Green)
        {
            myFaction = gameManager.green;
        }
    }
예제 #4
0
 private void Start()
 {
     playerMovement = GetComponent <PlayerMovement>();
     factionScript  = GetComponent <FactionScript>();
 }
예제 #5
0
 void Start()
 {
     text = GetComponent<Text>();
     faction = GameObject.Find("GameManager").GetComponent<GameManager>().player;
 }