示例#1
0
        public void drawMe(SpriteBatch sBatch, SessionController sessionManager)
        {
            if (gameWorld.Map != null)
            {
                gameWorld.Map.drawMe(sBatch);
            }

            foreach (NetworkGamer player in sessionManager.NetSession.AllGamers)
            {
                ((SpaceMarine)player.Tag).Draw(sBatch);
            }
            foreach (Asteroid asteroid in gameWorld.Asteroids)
            {
                asteroid.Draw(sBatch);
            }
            foreach (PickupItem item in gameWorld.PickupItems)
            {
                item.Draw(sBatch);
            }

            m_crossHair.Draw(sBatch);
        }
示例#2
0
        public GameController(Game1 Game, AssetManager assetManager, SessionController sessionManager, GraphicsDevice graphicsDevice)
        {
            m_graphicsDevice  = graphicsDevice;
            gameWorld         = new World(assetManager);
            m_crossHair       = new CrossHair(assetManager.SpriteLib["Crosshair"]);
            m_camera          = new Camera2D(graphicsDevice.Viewport, Vector2.Zero);
            m_controller      = new PolyInputController();
            m_matchController = new MatchController();
            m_sessionManager  = sessionManager;
            try
            {
                if (sessionManager.RecievedMapName != "")
                {
                    m_matchController = sessionManager.RecievedMatch;
                    gameWorld.LoadMap(sessionManager.RecievedMapName, m_matchController);
                }
                else
                {
                    setMatch(Game.SelectedMatch);
                    gameWorld.LoadMap(Game.SelectedMap, m_matchController);
                }
            }
            catch (Exception ex)
            {
                Game1.currentGameState = GameState.Menu;
                gameWorld = null;
                if (sessionManager.isHost)
                {
                    sessionManager.NetSession.EndGame();
                }
                Game.Exception = ex;
                return;
            }


            m_spawnManager                 = new SpawnController();
            m_spawnManager.SpawnList       = gameWorld.SpawnPoints;
            m_spawnManager.WeaponSpawnList = gameWorld.WeaponSpawns;
            m_spawnManager.SpawnAllWeapons(gameWorld.PickupItems);

            foreach (NetworkGamer gamer in sessionManager.NetSession.LocalGamers)
            {
                if (gamer.IsLocal)
                {
                    localPlayer = (SpaceMarine)gamer.Tag;
                }
            }
            m_matchController.NoTeam.AddTeamMember(localPlayer);

            if (sessionManager.RecievedItemList != null)
            {
                gameWorld.PickupItems = sessionManager.RecievedItemList;
                foreach (PickupItem item in gameWorld.PickupItems)
                {
                    if (item.GetType().BaseType == typeof(Weapon))
                    {
                        ((Weapon)item).SpawnPont = getSpawn(item);
                    }

                    else if (item.GetType() == typeof(Flag))
                    {
                        if (((Flag)item).Team == 1)
                        {
                            ((Flag)item).Base = gameWorld.BlueBase;
                        }
                        if (((Flag)item).Team == 2)
                        {
                            ((Flag)item).Base = gameWorld.RedBase;
                        }
                    }
                }
            }



            if (gameWorld.CurrentMatch == MatchType.CTF)
            {
                if (sessionManager.isHost)
                {
                    gameWorld.BlueBase.SpawnFlag(gameWorld.PickupItems);
                    gameWorld.RedBase.SpawnFlag(gameWorld.PickupItems);
                }
            }

            sessionManager.GameManager = this;
        }