Ejemplo n.º 1
0
 public void startTurn()
 {
     producersWithNeed.Clear();
     harvestAll();
     producers.Sort(Producer.qoutaComparison);
     foreach (Producer p in producers)
     {
         Improvement I = GlobalMarket.searchImprovementsForUnsold(improvements, p.neededResource);
         p.qouta = p.generateQouta();
         double amountSold = I.resource.spendResource(p.qouta);
         double cost       = I.getHarvestCost(amountSold);
         I.receiveMoney(cost);
         p.qouta -= amountSold;
         p.recieveResources(amountSold);
         p.updateCost(cost);
         if (p.qouta > 0)
         {
             producersWithNeed.Add(p);
         }
     }
     foreach (Store s in stores)
     {
         foreach (PlayerResource pr in s.neededResources)
         {
             Producer p = GlobalMarket.searchProducersForUnsold(producers, pr);
             s.generateQouta();
             double amountSold = p.resource.spendResource(s.qouta);
             double cost       = p.setSalePrice(s.owner, amountSold);
             p.receiveMoney(cost);
             s.qouta -= amountSold;
             s.recieveResources(pr.resourceName, amountSold);
             s.cost += cost;
             if (s.qouta > 0)
             {
                 storesWithNeed.Add(s);
             }
         }
     }
 }
Ejemplo n.º 2
0
    //Called before other Starts()
    void Awake()
    {
        gameMap = GameObject.FindObjectOfType <HexMap>();
        gameMap.Begin();
        turn    = 1;
        players = new List <Player>();
        int numPlayers = 1;

        players.Add(new Player(0, true));
        for (int i = 1; i < numPlayers; i++)
        {
            players.Add(new AIPlayer(i, Random.Range(0, 1) > .5f));
        }
        unitToGameObject = new Dictionary <Unit, GameObject>();
        //Debug.Log("Game Manager started");
        foreach (Player p in players)
        {
            Hex[,] hexes = HexMap.hexes;
            City c = new City(hexes, true, true, p);
            if (p.communist)
            {
                c = new CommunistCity(hexes, true, true, p);
            }
            else if (!p.communist)
            {
                c = new CapitalistCity(hexes, true, true, p);
            }
            p.city = c;
        }
        g = new GlobalMarket();
        Camera cam = FindObjectOfType <Camera>();

        gameMap.colorHexes(cam.transform.position);
        playing = players[0];
        playing.StartTurn();
        unitToGameObject = new Dictionary <Unit, GameObject>();
    }