示例#1
0
        // her player in kullanacagi board i da almamiz gerek. ya da bu bilgiyi user dan cekebiliriz.   TODO
        /// <summary>
        /// Userlari kullanarak playerlar olusturur. Bu userlar icin setState(GAME) fonksiyonunu cagirir.
        /// GameState i ReadyWait e setler.
        /// </summary>
        /// <param name="users"></param>
        public Game(List<User> users)
        {
            foreach (User user in users)
            {
                Player pTemp = new Player(user, this );
                players.AddLast(pTemp);
                statPlayers.Add(pTemp);
                user.player = pTemp;
            }

            remainingPlayerCount += users.Count;

            float distance = calculateBoardDistanceToCenter(users.Count);

            for (int i=0; i<users.Count; i++)
            {
                Vector3 rotation = new Vector3(0, i * 360.0f / users.Count, 0);
                users[i].player.board.rotation = rotation;
                users[i].player.board.position = new Vector3((float)Math.Cos(-1*rotation.y * (Math.PI / 180.0)) * distance, 0, (float) (Math.Sin(-1*rotation.y * (Math.PI / 180.0)) * distance));
                users[i].player.board.nextBoard = users[(i + 1)%users.Count].player.board;
                users[i].player.board.prevBoard = users[(i + users.Count - 1) % users.Count].player.board;
            }

            this.statTracker = new StatTracker(this);

            setStateReadyWait();
        }
        public static void sendMessage(ICollection<Player> recievers , StatTracker statTracker)
        {
            RawMessage bigMsg = new RawMessage();

            bigMsg.putInt("id", TypeIdGenerator.getMessageId(typeof(GEndGameStatisticsResult)));
            bigMsg.putInt("c",statTracker.playerStatsList.Count);

            int[] playerIDs = new int[statTracker.playerStatsList.Count];
            int [] minionsKilled = new int[statTracker.playerStatsList.Count];
            int[] minionsSend = new int[statTracker.playerStatsList.Count];
            int[] towersBuilt = new int[statTracker.playerStatsList.Count];
            int[] missilesFired = new int[statTracker.playerStatsList.Count];
            int[] minionsPassed = new int[statTracker.playerStatsList.Count];
            float[] moneyEarned = new float[statTracker.playerStatsList.Count];
            float[] moneySpend = new float[statTracker.playerStatsList.Count];
            int[] cashs = new int[statTracker.playerStatsList.Count];
            int[] incomes = new int[statTracker.playerStatsList.Count];

            for(int i = 0; i < statTracker.playerStatsList.Count; i++)
            {
                playerIDs[i] = statTracker.playerStatsList[i].ownerPlayer.id;
                minionsKilled[i] = statTracker.playerStatsList[i].minionsKilled;
                minionsSend[i] = statTracker.playerStatsList[i].minionsSend;
                towersBuilt[i] = statTracker.playerStatsList[i].towersBuilt;
                missilesFired[i] = statTracker.playerStatsList[i].missilesFired;
                minionsPassed[i] = statTracker.playerStatsList[i].minionsPassed;
                moneyEarned[i] = statTracker.playerStatsList[i].moneyEarned;
                moneySpend[i] = statTracker.playerStatsList[i].moneySpend;
                cashs[i] = statTracker.playerStatsList[i].cash;
                incomes[i] = statTracker.playerStatsList[i].income;
            }

            bigMsg.putIntArray("pids", playerIDs);
            bigMsg.putIntArray("mk",minionsKilled);
            bigMsg.putIntArray("ms", minionsSend);
            bigMsg.putIntArray("tb", towersBuilt);
            bigMsg.putIntArray("mf", missilesFired);
            bigMsg.putIntArray("mp", minionsPassed);
            bigMsg.putFloatArray("mme", moneyEarned);
            bigMsg.putFloatArray("mms", moneySpend);
            bigMsg.putIntArray("cs", cashs);
            bigMsg.putIntArray("inc",incomes);

            foreach (Player p in recievers)
            {
                p.user.session.client.SendMessage(bigMsg);
            }
        }