Ejemplo n.º 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);
        }
    }
Ejemplo n.º 2
0
    // sorts players by troop count
    public void ByTroopCount()
    {
        numberOfPlayers = boardSetUp.numberOfPlayers;
        // build a list{player number, number of troops owned} from troopCounter dictionary
        TroopRankStatic = new List <int[]> ();
        for (int i = 1; i <= numberOfPlayers; i++)
        {
            TroopRankStatic.Add(new int[2]);
            TroopRankStatic [i - 1] [0] = i;
            TroopRankStatic [i - 1] [1] = troopCount.troopCounter ["Player" + i];
        }
        // list of only the troop counts (values only)
        TroopValues = new List <int>();
        for (int j = 0; j < numberOfPlayers; j++)
        {
            TroopValues.Add(TroopRankStatic [j] [1]);
        }

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

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

        // iterate through the ordered TroopValues
        for (int k = 0; k < numberOfPlayers; k++)
        {
            // iterate through TroopRankStatic territory counts
            for (int l = 0; l < TroopRankStatic.Count; l++)
            {
                // build list of players ranked by troop counts
                if (TroopValues [k] == TroopRankStatic [l] [1])
                {
                    TroopCountPlayerRanks.Add(TroopRankStatic [l] [0]);
                    // remove the player just chosen to prevent duplicates
                    TroopRankStatic.RemoveAt(l);
                    // jump out of loop and move onto next k
                    l = numberOfPlayers;
                }
            }
        }
        // Only runs when troop count rank is active
        if (activeCatagory)
        {
            // update troop count display
            playerRank.RankedTroopCount();
        }
    }