Пример #1
0
    // when code is run change catagories - Index 1 is the active category
    public void RotateCategory()
    {
        if (!phases.openingPhase)
        {
            // changes category
            switch (categoryButton.text)
            {
            case "Troop Count":
                categoryButton.text = "Territory Count";
                playerRank.RankedTerrCount();
                break;

            case "Territory Count":
                categoryButton.text = "Soldier Bonus";
                playerRank.RankedSoldierBonus();
                break;

            default:     // case for "Soldier Bonus"
                categoryButton.text = "Troop Count";
                playerRank.RankedTroopCount();
                break;
            }
            // allows the active category display to update - via other rank scripts
            troopRank.UpdateTroopCountDisplay(categoryButton.text);
            territoryRank.UpdateTerritoryRankDisplay(categoryButton.text);
            soldierBonusRank.UpdateSoldierBonusDisplay(categoryButton.text);
        }
    }
Пример #2
0
    // Ranks players based on territory count -- called in GameStats
    public void BySolBonusRank(int numberOfPlayers)
    {
        // build a list{player number(0), number of territories owned(1)} from landcounter dictionary
        SolBonusRankStatic = new List <int[]> ();
        for (int i = 1; i <= numberOfPlayers; i++)
        {
            SolBonusRankStatic.Add(new int[2]);
            SolBonusRankStatic [i - 1] [0] = i;
            SolBonusRankStatic [i - 1] [1] = soldierBonus.soldierIncome["Player" + i];
        }
        // list of only the territory counts (values only)
        SoldierBonus = new List <int>();
        for (int j = 0; j < numberOfPlayers; j++)
        {
            SoldierBonus.Add(SolBonusRankStatic[j][1]);
        }

        // sort list highest to lowest
        SoldierBonus.Sort();
        SoldierBonus.Reverse();

        // list of players in ranked order
        SolBonusPlayerRanks = new List <int> ();

        // iterate through the ordered TerritoryCounts
        for (int k = 0; k < numberOfPlayers; k++)
        {
            // iterate through TerrRankStatic territory counts
            for (int l = 0; l < SolBonusRankStatic.Count; l++)
            {
                // build list of players ranked by territory counts
                if (SoldierBonus [k] == SolBonusRankStatic [l] [1])
                {
                    SolBonusPlayerRanks.Add(SolBonusRankStatic [l] [0]);
                    // remove the player just chosen to prevent duplicates
                    SolBonusRankStatic.RemoveAt(l);
                    // jump out of loop and move onto next k
                    l = numberOfPlayers;
                }
            }
        }
        // only runs the soldier bonus rank is active
        if (activeCatagory)
        {
            // updates soldier bonus rank display
            playerRank.RankedSoldierBonus();
        }
    }