Example #1
0
    public void PowerCity(City city, PowerPlantCard powerPlantCard)
    {
        //if (playerPowerPlants >= city.playerCities)
        //{
        //    if (playerCoal)
        //    {
        //        playerCoal -= city.playerCities;
        //    }

        //    for (playerOil)
        //    {
        //        playerOil -= city.playerCities;
        //    }

        //    for (playerGarbage)
        //    {
        //        playerGarbage -= city.playerCities;
        //    }

        //    for (playerNuclear)
        //    {
        //        playerNuclear -= city.playerCities;
        //    }
        //}
    }
Example #2
0
    //public static IEnumerable<List<T>> SplitList<T>(this IEnumerable<T> list, int nSize = 4)
    //{
    //    for (int i = 0; i < list.Count; i += nSize)
    //    {
    //        yield return locations.GetRange(i, Math.Min(nSize, list.Count - i));
    //    }
    //}

    public static List <Card> LoadFromFile(string path)
    {
        List <Card> tempList = new List <Card>();

        //Get the contents of the file
        var lines = File.ReadAllLines(path);

        foreach (var line in lines)
        {
            //Comment or empty, skip
            if (line.Length == 0 || line[0] == '#' || line[0] == ' ' || string.IsNullOrWhiteSpace(line))
            {
                continue;
            }

            //splits the line into space-delimited chunks
            var chunks = line.Split(' ');
            //UnityEngine.Debug.Log(chunks[0]);

            var  faceValue        = int.Parse(chunks[0].Replace(":", ""));
            var  resource         = chunks[1].Replace(",", "");
            bool isHybrid         = bool.Parse(chunks[2].Replace(",", ""));
            var  powerCities      = int.Parse(chunks[3].Replace(",", ""));
            var  resourceRequired = int.Parse(chunks[4].Replace(",", ""));

            var card = new PowerPlantCard(faceValue, resource, isHybrid, powerCities, resourceRequired);

            tempList.Add(card);
        }

        return(tempList);
    }
Example #3
0
    /**
     * Buys a card for this player
     */
    public void BuyCard(PowerPlantCard powerPlantCard)
    {
        //They have enough money to buy the city: so add it to the list of owned cities
        if (playerElektro >= powerPlantCard.faceValue)
        {
            //Add it to the list of owned cards
            playerPowerPlants.Add(powerPlantCard);

            //Deduct that amount from their money
            playerElektro -= powerPlantCard.faceValue;
        }
        else
        {
            UnityEngine.Debug.Log("you dont have enough money!");
        }
    }
Example #4
0
    public void SetSelectedPlant(PowerPlantCard p)
    {
        bool isBiddable = true;

        for (int i = biddableCount; i < drawedCards.Count; i++)
        {
            if (((PowerPlantCard)drawedCards[i]) == p)
            {
                isBiddable = false;
                break;
            }
        }

        if (!isBiddable)
        {
            return;
        }

        selectedPlant = p;
        currentBid    = p.faceValue;
    }