示例#1
0
        public void StartGame()
        {
            if (GameState == eGameState.Loading)
            {
                GameState = eGameState.Playing;
                ClearWaitTimer();

                if (m_teamType == eTeamType.Leader)
                {
                    m_redLeader = SelectLeader(m_redTeam);
                    m_redLeader.SetCaptain(true);
                    m_blueLeader = SelectLeader(m_blueTeam);
                    m_blueLeader.SetCaptain(true);
                }

                Player[] list = GetAllFightPlayersSafe();

                MapPoint   mapPos = MapMgr.GetMapRandomPos(m_map.Info.ID);
                GSPacketIn pkg    = new GSPacketIn((byte)ePackageType.GAME_START);
                pkg.WriteInt(list.Length);
                foreach (Player p in list)
                {
                    Point pos = GetPlayerPoint(mapPos, p.Team);
                    p.SetXY(pos);
                    m_map.AddPhysical(p);
                    p.StartMoving();

                    p.StartGame();

                    pkg.WriteInt(p.Id);
                    pkg.WriteInt(p.X);
                    pkg.WriteInt(p.Y);
                    pkg.WriteInt(p.Direction);
                    pkg.WriteInt(p.Blood);
                    pkg.WriteBoolean(p.IsCaptain);
                }

                SendToAll(pkg);

                WaitTime(list.Length * 1000);

                OnGameStarted();
            }
        }