示例#1
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();
        }