Exemplo n.º 1
0
        ///<summary>
        ///sets up the game environment from map file
        ///</summary>
        ///<param name="filename"></param>
        ///<returns></returns>
        public bool LoadMap(string filename)
        {
            //clear any current bots and projectiles
            Clear();

            _map = new Map.Map();

            //make sure the entity manager is reset
            EntityManager.Instance.Reset();

            //load the new map data
            if (_map.LoadMap(filename, out _mapData))
            {
                _pathManager =
                    new PathManager(
                        Parameters.MaxSearchCyclesPerUpdateStep);

                AddBots(Parameters.NumBots);

                return true;
            }

            return false;
        }
Exemplo n.º 2
0
        ///<summary>
        ///constructor with map file parameter
        ///</summary>
        ///<param name="filename"></param>
        public GameManager(string filename)
        {
            Assert.Fatal(null == _instance, "Singleton already created.");
            _instance = this;

            _selectedBot = null;
            MyGame.Instance.GamePaused = false;
            RemoveABot = false;
            _map = null;
            _pathManager = null;

            _botList = new List<BotEntity>();
            _projectiles = new List<Projectile>();
            _graveMarkerList = new List<GraveMarker>();

            _minimapComponentList = new List<MinimapComponent>();

            ////4 upper right minimaps

            //     _minimapComponentList.Add(CreateMinimapComponent(
            //       new Vector2(0, 0),
            //      new Vector2(32.0f, 32.0f),
            //     new Vector2(64.0f, 0.0f),
            //    new Vector2(128.0f, 128.0f),
            //   true));
            //   _minimapComponentList.Add(CreateMinimapComponent(
            //    new Vector2(0, 0),
            //  new Vector2(64.0f, 64.0f),
            //   new Vector2(768.0f, 0.0f),
            //  new Vector2(256.0f, 256.0f),
            //  true
            // ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(512.0f, 256.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(768.0f, 256.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));

            ////4 lower left minimaps
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(0.0f, 512.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(256.0f, 512.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(0.0f, 768.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(256.0f, 768.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));

            try
            {
                Options = MyGame.Instance.Content.Load<OptionsData>(@"data\maps\Options");
            }
            catch (Exception e)
            {
                Assert.Fatal(false,
                             "GameManager.GameManager: Bad options filename -> " + e.Message);
                MyGame.Instance.Exit();
            }

            try
            {
                Parameters = MyGame.Instance.Content.Load<ParameterData>(@"data\maps\Parameters");
            }
            catch (Exception e)
            {
                Assert.Fatal(false,
                             "GameManager.GameManager: Bad parameters filename -> " + e.Message);
                MyGame.Instance.Exit();
            }

            //load in the map
            LoadMap(filename);

            int keyboardId = InputManager.Instance.FindDevice("keyboard");
            int gamepad = InputManager.Instance.FindDevice("gamepad0");
            InputMap map = PlayerManager.Instance.GetPlayer(0).InputMap;

            if (keyboardId > 0)
            {
                map.BindAction(
                    keyboardId,
                    (int) Keys.Space,
                    selectNextBot);
                map.BindAction(
                    keyboardId,
                    (int) Keys.X,
                    killBot);
            }
            if (gamepad > 0)
            {
                map.BindAction(
                    gamepad,
                    (int) XGamePadDevice.GamePadObjects.X,
                    selectNextBot);
                map.BindAction(
                    gamepad,
                    (int)XGamePadDevice.GamePadObjects.Y,
                    killBot);
            }
            if (Parameters.PlayCaptureTheFlag)
                _map.AddFlagsToMap();
        }