Пример #1
0
    // Use this for initialization
    void Start()
    {
        //firstWinningPlayerIndex = -1;
        IComparer playerOrderer = new PlayerSorter();

        Array.Sort(players, playerOrderer);
        foreach (GameObject player in players)
        {
            if (player.GetComponent <PlayerInput>() == null || player.GetComponent <PlayerControl>() == null)
            {
                Debug.LogError("Player Input or Player Control on " + player + " is null");
                Debug.Break();
            }
        }
        powerUps   = GameObject.FindGameObjectsWithTag("PowerUp");
        playersWon = new bool[players.Length];
        print("Num Players: " + players.Length);
        for (int i = 0; i < playersWon.Length; i++)
        {
            playersWon[i] = false;
        }
        players[curPlayerIndex].GetComponent <PlayerInput>().enabled = true;
        players[curPlayerIndex].GetComponent <Indicator>().setActive(true);
        StartCoroutine(CheckTurnSwitch());
    }
Пример #2
0
        private void SortPlayers()
        {
            string allInput = mTextBox.Text.Replace("\r\n", "\n");
            PlayerSorter ps = new PlayerSorter(mTool.GetKey(listAttributesToolStripMenuItem.Checked, listApperanceToolStripMenuItem.Checked));

            if (File.Exists(mSortStringFileName))
                ps.FormulasString = File.ReadAllText(mSortStringFileName);

            string teamPattern = "Team";

            try
            {
                int index = 0;
                int nn = -1;
                string current = "";
                string modified = "";
                string result = allInput;
                do
                {
                    index = allInput.IndexOf(teamPattern, index);
                    if (index > -1)
                    {
                        nn = allInput.IndexOf("\n\n", index);
                        if (nn < 0)
                            nn = allInput.Length;
                        current = allInput.Substring(index, nn - index);
                        modified = ps.SortTeam(current);
                        result = result.Replace(current, modified);
                        index = nn;
                    }
                } while (index > -1);

                SetText(result);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                    String.Concat("Error sorting players. \nCheck formulas file for errors.\n", ex.Message, "\n", ex.InnerException.Message),
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }