public void GoToDestination(StateMainGame mg)
        {
            switch (Destination)
            {
            case "menu":
            {
                int nObjectManager = 4;
                GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
                objectManagerArray[0] = new ButtonManger(@"./Data/XML/buttonmanager.xml");
                objectManagerArray[1] = new BackgroundManager(@"./Data/XML/menubg.xml");
                objectManagerArray[2] = new MenuFrameManager(@"./Data/XML/menuframe.xml");
                objectManagerArray[3] = new GameTitleManager(@"./Data/XML/gametitle.xml");

                GlobalVariables.dX = 0;
                GlobalVariables.dY = 0;

                mg.Owner.GameState.ExitState();
                mg.Owner.GameState = new StateLoading();
                mg.Owner.GameState.InitState(null, mg.Owner);
                ((StateLoading)mg.Owner.GameState).GetDataLoading(mg.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenu));
                mg.Owner.GameState.EnterState();
                mg.Owner.ResetElapsedTime();
            }
            break;

            case "map01":
            {
                mg._map       = (Map)mg._objectManagerArray[1].CreateObject(0);
                mg._map.Owner = mg;
                mg._char.SetMap(mg._map);
                mg._listMonsters = mg._map.InitMonsterList((MonsterManager)mg._objectManagerArray[2], @"Data\Map\map01\map01_monster.xml");
                mg._frog.SetCharacter(mg._char);

                mg._listPortral    = mg._map.InitPortralList((PortralManager)mg._objectManagerArray[4], @"Data\Map\map01\map01_portral.xml");
                mg._char.X         = DestX * GlobalVariables.MapCollisionDim;
                mg._char.Y         = DestY * GlobalVariables.MapCollisionDim;
                GlobalVariables.dX = Math.Min(-mg._char.X + GlobalVariables.ScreenWidth / 2, 0);
                GlobalVariables.dY = Math.Min(-mg._char.Y + GlobalVariables.ScreenHeight / 2, 0);
                mg._char.DestPoint = new Point((int)mg._char.X, (int)mg._char.Y);
            }
            break;

            case "map02":
            {
                mg._map       = (Map)mg._objectManagerArray[1].CreateObject(1);
                mg._map.Owner = mg;
                mg._char.SetMap(mg._map);
                mg._listMonsters = mg._map.InitMonsterList((MonsterManager)mg._objectManagerArray[2], @"Data\Map\map02\map02_monster.xml");
                mg._frog.SetCharacter(mg._char);

                mg._listPortral    = mg._map.InitPortralList((PortralManager)mg._objectManagerArray[4], @"Data\Map\map02\map02_portral.xml");
                mg._char.X         = DestX * GlobalVariables.MapCollisionDim;
                mg._char.Y         = DestY * GlobalVariables.MapCollisionDim;
                GlobalVariables.dX = Math.Min(-mg._char.X + GlobalVariables.ScreenWidth / 2, 0);
                GlobalVariables.dY = Math.Min(-mg._char.Y + GlobalVariables.ScreenHeight / 2, 0);
                mg._char.DestPoint = new Point((int)mg._char.X, (int)mg._char.Y);
            }
            break;
            }
        }
예제 #2
0
//--------------------Su kien New Game frame------------------
        void StateMenu_Move_Complete_NewGame(object sender, EventArgs e)
        {
            if (_indexOfNextState != 0)
            {
                return;
            }
            GameFrame _frame = (GameFrame)sender;

            if (_frame.IsVisible == false)
            {
                int nObjectManager = 12;
                GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];

                objectManagerArray[1]  = new MapManager(@"Data\Map\map.xml");
                objectManagerArray[0]  = new PlayerCharacterManager(@"Data\character\character.xml");
                objectManagerArray[2]  = new MonsterManager(@"Data\monster\monster.xml");
                objectManagerArray[3]  = new ProcessBarManager(@"Data\XML\processbar-stateloading.xml");
                objectManagerArray[4]  = new PortralManager(@"Data\Portral\Portral.xml");
                objectManagerArray[5]  = new MapObstacleManager(@"Data\MapObstacle\MapObstacle.xml");
                objectManagerArray[6]  = new ProjectileManager(@"Data\Projectile\Projectile.xml");
                objectManagerArray[7]  = new SkillManager(@"Data\Skill\Skill.xml");
                objectManagerArray[8]  = new GameFrameManager(@"Data\XML\gameframe-statemaingame.xml");
                objectManagerArray[9]  = new ProcessBarManager(@"Data\XML\processbar-statemaingame.xml");
                objectManagerArray[10] = new ButtonManger(@"Data\XML\buttonmanager-statemaingame.xml");
                objectManagerArray[11] = new LabelManager(@"Data\XML\labelmanager-statemaingame.xml");


                Owner.GameState = new StateLoading();
                Owner.GameState.InitState(null, Owner);
                ((StateLoading)Owner.GameState).GetDataLoading(Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMainGame));
                Owner.GameState.EnterState();
            }
        }
예제 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.graphics.IsFullScreen = true;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            GlobalVariables.Sf = Content.Load <SpriteFont>("sf");

            GlobalVariables.ScreenHeight = this.Window.ClientBounds.Height;
            GlobalVariables.ScreenWidth  = this.Window.ClientBounds.Width;

            //Khởi tạo 2 biến mouseState
            GlobalVariables.CurrentMouseState  = new MouseState();
            GlobalVariables.PreviousMouseState = new MouseState();

            GlobalVariables.GameCursor = new Cursor();
            GlobalVariables.GameCursor.Init(Content);

            //_gameState = new StateMenu();
            //_gameState.InitState(Content, this);
            //_gameState.EnterState();

            int nObjectManager = 3;

            GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
            objectManagerArray[0] = new BackgroundManager(@"./Data/XML/menubg.xml");
            objectManagerArray[1] = new GameFrameManager(@"./Data/XML/gameframe-statemenu.xml");
            objectManagerArray[2] = new ButtonManger(@"./Data/XML/buttonmanager-statemenu.xml");
            _gameState            = new StateLoading();
            _gameState.InitState(null, this);
            ((StateLoading)_gameState).GetDataLoading(Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenuManager));
            _gameState.EnterState();

            //int nObjectManager = 12;
            //GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];

            //objectManagerArray[1] = new MapManager(@"Data\Map\map.xml");
            //objectManagerArray[0] = new PlayerCharacterManager(@"Data\character\character.xml");
            //objectManagerArray[2] = new MonsterManager(@"Data\monster\monster.xml");
            //objectManagerArray[3] = new ProcessBarManager(@"Data\XML\processbar-stateloading.xml");
            //objectManagerArray[4] = new PortralManager(@"Data\Portral\Portral.xml");
            //objectManagerArray[5] = new MapObstacleManager(@"Data\MapObstacle\MapObstacle.xml");
            //objectManagerArray[6] = new ProjectileManager(@"Data\Projectile\Projectile.xml");
            //objectManagerArray[7] = new SkillManager(@"Data\Skill\Skill.xml");
            //objectManagerArray[8] = new GameFrameManager(@"Data\XML\gameframe-statemaingame.xml");
            //objectManagerArray[9] = new ProcessBarManager(@"Data\XML\processbar-statemaingame.xml");
            //objectManagerArray[10] = new ButtonManger(@"Data\XML\buttonmanager-statemaingame.xml");
            //objectManagerArray[11] = new LabelManager(@"Data\XML\labelmanager-statemaingame.xml");

            //_gameState = new StateLoading();
            //_gameState.InitState(null, this);
            //((StateLoading)_gameState).GetDataLoading(Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMainGame));
            //_gameState.EnterState();
        }
        //Su kien button OK
        public void OKButton_Click(object sender, EventArgs e)
        {
            int nObjectManager = 3;

            GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
            objectManagerArray[0] = new BackgroundManager(@"./Data/XML/menubg.xml");
            objectManagerArray[1] = new GameFrameManager(@"./Data/XML/gameframe-statemenu.xml");
            objectManagerArray[2] = new ButtonManger(@"./Data/XML/buttonmanager-statemenu.xml");

            _stateOwner.Owner.GameState = new StateLoading();
            _stateOwner.Owner.GameState.InitState(null, _stateOwner.Owner);
            ((StateLoading)_stateOwner.Owner.GameState).GetDataLoading(_stateOwner.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenuManager));
            _stateOwner.Owner.GameState.EnterState();
        }
        public void GoToDestination(StateMainGame mg)
        {
            switch (Destination)
            {
                case "menu":
                    {
                        int nObjectManager = 4;
                        GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
                        objectManagerArray[0] = new ButtonManger(@"./Data/XML/buttonmanager.xml");
                        objectManagerArray[1] = new BackgroundManager(@"./Data/XML/menubg.xml");
                        objectManagerArray[2] = new MenuFrameManager(@"./Data/XML/menuframe.xml");
                        objectManagerArray[3] = new GameTitleManager(@"./Data/XML/gametitle.xml");

                        GlobalVariables.dX = 0;
                        GlobalVariables.dY = 0;

                        mg.Owner.GameState.ExitState();
                        mg.Owner.GameState = new StateLoading();
                        mg.Owner.GameState.InitState(null, mg.Owner);
                        ((StateLoading)mg.Owner.GameState).GetDataLoading(mg.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenu));
                        mg.Owner.GameState.EnterState();
                        mg.Owner.ResetElapsedTime();
                    }
                    break;
                case "map01":
                    {
                        mg._map = (Map)mg._objectManagerArray[1].CreateObject(0);
                        mg._map.Owner = mg;
                        mg._char.SetMap(mg._map);
                        mg._listMonsters = mg._map.InitMonsterList((MonsterManager)mg._objectManagerArray[2], @"Data\Map\map01\map01_monster.xml");
                        mg._frog.SetCharacter(mg._char);

                        mg._listPortral = mg._map.InitPortralList((PortralManager)mg._objectManagerArray[4], @"Data\Map\map01\map01_portral.xml");
                        mg._char.X = DestX * GlobalVariables.MapCollisionDim;
                        mg._char.Y = DestY * GlobalVariables.MapCollisionDim;
                        GlobalVariables.dX = Math.Min(-mg._char.X + GlobalVariables.ScreenWidth / 2, 0);
                        GlobalVariables.dY = Math.Min(-mg._char.Y + GlobalVariables.ScreenHeight / 2, 0);
                        mg._char.DestPoint = new Point((int)mg._char.X, (int)mg._char.Y);
                    }
                    break;
                case "map02":
                    {
                        mg._map = (Map)mg._objectManagerArray[1].CreateObject(1);
                        mg._map.Owner = mg;
                        mg._char.SetMap(mg._map);
                        mg._listMonsters = mg._map.InitMonsterList((MonsterManager)mg._objectManagerArray[2], @"Data\Map\map02\map02_monster.xml");
                        mg._frog.SetCharacter(mg._char);

                        mg._listPortral = mg._map.InitPortralList((PortralManager)mg._objectManagerArray[4], @"Data\Map\map02\map02_portral.xml");
                        mg._char.X = DestX * GlobalVariables.MapCollisionDim;
                        mg._char.Y = DestY * GlobalVariables.MapCollisionDim;
                        GlobalVariables.dX = Math.Min(-mg._char.X + GlobalVariables.ScreenWidth / 2, 0);
                        GlobalVariables.dY = Math.Min(-mg._char.Y + GlobalVariables.ScreenHeight / 2, 0);
                        mg._char.DestPoint = new Point((int)mg._char.X, (int)mg._char.Y);
                    }
                    break;
            }
        }
        public override void UpdateState(GameTime gameTime)
        {
            base.UpdateState(gameTime);
            if (!GlobalVariables.IsPauseGame)
            {

                float minX = Math.Abs(GlobalVariables.dX);
                float maxX = Math.Abs(GlobalVariables.dX) + GlobalVariables.ScreenWidth;
                float minY = Math.Abs(GlobalVariables.dY);
                float maxY = Math.Abs(GlobalVariables.dY) + GlobalVariables.ScreenHeight;
                GlobalVariables.GameCursor.IsIdle = true;
                GlobalVariables.AlreadyUseLeftMouse = false;
                GlobalVariables.AlreadyUseRightMouse = false;

                _healthBar.Update(gameTime);
                _lhSkillSelectionFrame.Update(gameTime);
                _rhSkillSelectionFrame.Update(gameTime);
                _skillBoard.Update(gameTime);
                _infoBoard.Update(gameTime);

                _listToDraw.Clear();
                _map.Update(gameTime);

                for (int i = 0; i < _listObstacle.Count; ++i)
                {
                    if (minX < _listObstacle[i].X && _listObstacle[i].X < maxX && minY < _listObstacle[i].Y && _listObstacle[i].Y < maxY)
                    {
                        _listObstacle[i].Update(gameTime);
                        _listToDraw.Add(_listObstacle[i]);
                    }
                }

                for (int i = 0; i < _listPortral.Count; ++i)
                {
                    if (minX < _listPortral[i].X && _listPortral[i].X < maxX && minY < _listPortral[i].Y && _listPortral[i].Y < maxY)
                    {
                        _listPortral[i].Update(gameTime);
                        _listToDraw.Add(_listPortral[i]);
                    }
                }

                for (int i = 0; i < _listMonsters.Count; ++i)
                {
                    if (minX < _listMonsters[i].X && _listMonsters[i].X < maxX && minY < _listMonsters[i].Y && _listMonsters[i].Y < maxY)
                    {
                        _listMonsters[i].Update(gameTime);
                        _listToDraw.Add(_listMonsters[i]);

                        if (_listMonsters[i].IsDyed)
                        {
                            _listMonsters.Remove(_listMonsters[i]);
                        }
                    }
                }
                for (int i = 0; i < _listProjectile.Count; ++i)
                {
                    _listProjectile[i].Update(gameTime);
                    if ((_listProjectile[i]._sprite[0].Itexture2D == _listProjectile[i]._sprite[0].Ntexture2D - 1 && _listProjectile[i].IsRemoveAfterEffect) || (_listProjectile[i].LifeTime <= 0 && !_listProjectile[i].IsRemoveAfterEffect))
                        _listProjectile.Remove(_listProjectile[i]);
                }
                _char.Update(gameTime);
                _listToDraw.Add(_char);

                if (_char.IsDyed)
                {
                    int nObjectManager = 4;
                    GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
                    objectManagerArray[0] = new ButtonManger(@"./Data/XML/buttonmanager.xml");
                    objectManagerArray[1] = new BackgroundManager(@"./Data/XML/menubg.xml");
                    objectManagerArray[2] = new MenuFrameManager(@"./Data/XML/menuframe.xml");
                    objectManagerArray[3] = new GameTitleManager(@"./Data/XML/gametitle.xml");

                    GlobalVariables.dX = 0;
                    GlobalVariables.dY = 0;

                    Owner.GameState.ExitState();
                    Owner.GameState = new StateLoading();
                    Owner.GameState.InitState(null, this.Owner);
                    ((StateLoading)Owner.GameState).GetDataLoading(this.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenu));
                    Owner.GameState.EnterState();
                    Owner.ResetElapsedTime();
                }
                if (GlobalVariables.LastBoss.IsDying)
                {
                    if (GlobalVariables.BackgroundSound.Name != "soulsrelease")
                    {
                        GlobalVariables.BackgroundSound = GlobalVariables.SoundBank.GetCue("soulsrelease");
                        GlobalVariables.BackgroundSound.Play();
                    }
                }
                if (GlobalVariables.LastBoss.IsDyed)
                {
                    GlobalVariables.IsPauseGame = true;
                }
                _displayMessageLayer.Update(gameTime);
                _frog.Update(gameTime);
            }
            else
            {
                if (GlobalVariables.LastBoss.IsDyed)
                {
                    Owner.Exit();
                }
                else
                    _subMenu.Update(gameTime);
            }
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.graphics.IsFullScreen = true;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            GlobalVariables.Sf = Content.Load<SpriteFont>("sf");

            GlobalVariables.ScreenHeight = this.Window.ClientBounds.Height;
            GlobalVariables.ScreenWidth = this.Window.ClientBounds.Width;

            //Khởi tạo 2 biến mouseState
            GlobalVariables.CurrentMouseState = new MouseState();
            GlobalVariables.PreviousMouseState = new MouseState();

            GlobalVariables.GameCursor = new Cursor();
            GlobalVariables.GameCursor.Init(Content);

            //_gameState = new StateMenu();
            //_gameState.InitState(Content, this);
            //_gameState.EnterState();

            int nObjectManager = 3;
            GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
            objectManagerArray[0] = new BackgroundManager(@"./Data/XML/menubg.xml");
            objectManagerArray[1] = new GameFrameManager(@"./Data/XML/gameframe-statemenu.xml");
            objectManagerArray[2] = new ButtonManger(@"./Data/XML/buttonmanager-statemenu.xml");
            _gameState = new StateLoading();
            _gameState.InitState(null, this);
            ((StateLoading)_gameState).GetDataLoading(Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenuManager));
            _gameState.EnterState();

            //int nObjectManager = 12;
            //GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];

            //objectManagerArray[1] = new MapManager(@"Data\Map\map.xml");
            //objectManagerArray[0] = new PlayerCharacterManager(@"Data\character\character.xml");
            //objectManagerArray[2] = new MonsterManager(@"Data\monster\monster.xml");
            //objectManagerArray[3] = new ProcessBarManager(@"Data\XML\processbar-stateloading.xml");
            //objectManagerArray[4] = new PortralManager(@"Data\Portral\Portral.xml");
            //objectManagerArray[5] = new MapObstacleManager(@"Data\MapObstacle\MapObstacle.xml");
            //objectManagerArray[6] = new ProjectileManager(@"Data\Projectile\Projectile.xml");
            //objectManagerArray[7] = new SkillManager(@"Data\Skill\Skill.xml");
            //objectManagerArray[8] = new GameFrameManager(@"Data\XML\gameframe-statemaingame.xml");
            //objectManagerArray[9] = new ProcessBarManager(@"Data\XML\processbar-statemaingame.xml");
            //objectManagerArray[10] = new ButtonManger(@"Data\XML\buttonmanager-statemaingame.xml");
            //objectManagerArray[11] = new LabelManager(@"Data\XML\labelmanager-statemaingame.xml");

            //_gameState = new StateLoading();
            //_gameState.InitState(null, this);
            //((StateLoading)_gameState).GetDataLoading(Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMainGame));
            //_gameState.EnterState();
        }
        public override void UpdateState(GameTime gameTime)
        {
            base.UpdateState(gameTime);
            if (!GlobalVariables.IsPauseGame)
            {
                float minX = Math.Abs(GlobalVariables.dX);
                float maxX = Math.Abs(GlobalVariables.dX) + GlobalVariables.ScreenWidth;
                float minY = Math.Abs(GlobalVariables.dY);
                float maxY = Math.Abs(GlobalVariables.dY) + GlobalVariables.ScreenHeight;
                GlobalVariables.GameCursor.IsIdle    = true;
                GlobalVariables.AlreadyUseLeftMouse  = false;
                GlobalVariables.AlreadyUseRightMouse = false;

                _healthBar.Update(gameTime);
                _lhSkillSelectionFrame.Update(gameTime);
                _rhSkillSelectionFrame.Update(gameTime);
                _skillBoard.Update(gameTime);
                _infoBoard.Update(gameTime);

                _listToDraw.Clear();
                _map.Update(gameTime);


                for (int i = 0; i < _listObstacle.Count; ++i)
                {
                    if (minX < _listObstacle[i].X && _listObstacle[i].X < maxX && minY < _listObstacle[i].Y && _listObstacle[i].Y < maxY)
                    {
                        _listObstacle[i].Update(gameTime);
                        _listToDraw.Add(_listObstacle[i]);
                    }
                }

                for (int i = 0; i < _listPortral.Count; ++i)
                {
                    if (minX < _listPortral[i].X && _listPortral[i].X < maxX && minY < _listPortral[i].Y && _listPortral[i].Y < maxY)
                    {
                        _listPortral[i].Update(gameTime);
                        _listToDraw.Add(_listPortral[i]);
                    }
                }

                for (int i = 0; i < _listMonsters.Count; ++i)
                {
                    if (minX < _listMonsters[i].X && _listMonsters[i].X < maxX && minY < _listMonsters[i].Y && _listMonsters[i].Y < maxY)
                    {
                        _listMonsters[i].Update(gameTime);
                        _listToDraw.Add(_listMonsters[i]);

                        if (_listMonsters[i].IsDyed)
                        {
                            _listMonsters.Remove(_listMonsters[i]);
                        }
                    }
                }
                for (int i = 0; i < _listProjectile.Count; ++i)
                {
                    _listProjectile[i].Update(gameTime);
                    if ((_listProjectile[i]._sprite[0].Itexture2D == _listProjectile[i]._sprite[0].Ntexture2D - 1 && _listProjectile[i].IsRemoveAfterEffect) || (_listProjectile[i].LifeTime <= 0 && !_listProjectile[i].IsRemoveAfterEffect))
                    {
                        _listProjectile.Remove(_listProjectile[i]);
                    }
                }
                _char.Update(gameTime);
                _listToDraw.Add(_char);



                if (_char.IsDyed)
                {
                    int nObjectManager = 4;
                    GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
                    objectManagerArray[0] = new ButtonManger(@"./Data/XML/buttonmanager.xml");
                    objectManagerArray[1] = new BackgroundManager(@"./Data/XML/menubg.xml");
                    objectManagerArray[2] = new MenuFrameManager(@"./Data/XML/menuframe.xml");
                    objectManagerArray[3] = new GameTitleManager(@"./Data/XML/gametitle.xml");

                    GlobalVariables.dX = 0;
                    GlobalVariables.dY = 0;

                    Owner.GameState.ExitState();
                    Owner.GameState = new StateLoading();
                    Owner.GameState.InitState(null, this.Owner);
                    ((StateLoading)Owner.GameState).GetDataLoading(this.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenu));
                    Owner.GameState.EnterState();
                    Owner.ResetElapsedTime();
                }
                if (GlobalVariables.LastBoss.IsDying)
                {
                    if (GlobalVariables.BackgroundSound.Name != "soulsrelease")
                    {
                        GlobalVariables.BackgroundSound = GlobalVariables.SoundBank.GetCue("soulsrelease");
                        GlobalVariables.BackgroundSound.Play();
                    }
                }
                if (GlobalVariables.LastBoss.IsDyed)
                {
                    GlobalVariables.IsPauseGame = true;
                }
                _displayMessageLayer.Update(gameTime);
                _frog.Update(gameTime);
            }
            else
            {
                if (GlobalVariables.LastBoss.IsDyed)
                {
                    Owner.Exit();
                }
                else
                {
                    _subMenu.Update(gameTime);
                }
            }
        }
        //--------------------Su kien New Game frame------------------
        void StateMenu_Move_Complete_NewGame(object sender, EventArgs e)
        {
            if (_indexOfNextState != 0)
                return;
            GameFrame _frame = (GameFrame)sender;
            if (_frame.IsVisible == false)
            {
                int nObjectManager = 12;
                GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];

                objectManagerArray[1] = new MapManager(@"Data\Map\map.xml");
                objectManagerArray[0] = new PlayerCharacterManager(@"Data\character\character.xml");
                objectManagerArray[2] = new MonsterManager(@"Data\monster\monster.xml");
                objectManagerArray[3] = new ProcessBarManager(@"Data\XML\processbar-stateloading.xml");
                objectManagerArray[4] = new PortralManager(@"Data\Portral\Portral.xml");
                objectManagerArray[5] = new MapObstacleManager(@"Data\MapObstacle\MapObstacle.xml");
                objectManagerArray[6] = new ProjectileManager(@"Data\Projectile\Projectile.xml");
                objectManagerArray[7] = new SkillManager(@"Data\Skill\Skill.xml");
                objectManagerArray[8] = new GameFrameManager(@"Data\XML\gameframe-statemaingame.xml");
                objectManagerArray[9] = new ProcessBarManager(@"Data\XML\processbar-statemaingame.xml");
                objectManagerArray[10] = new ButtonManger(@"Data\XML\buttonmanager-statemaingame.xml");
                objectManagerArray[11] = new LabelManager(@"Data\XML\labelmanager-statemaingame.xml");

                Owner.GameState = new StateLoading();
                Owner.GameState.InitState(null, Owner);
                ((StateLoading)Owner.GameState).GetDataLoading(Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMainGame));
                Owner.GameState.EnterState();
            }
        }
        //Su kien button OK
        public void OKButton_Click(object sender, EventArgs e)
        {
            int nObjectManager = 3;
            GameObjectManager[] objectManagerArray = new GameObjectManager[nObjectManager];
            objectManagerArray[0] = new BackgroundManager(@"./Data/XML/menubg.xml");
            objectManagerArray[1] = new GameFrameManager(@"./Data/XML/gameframe-statemenu.xml");
            objectManagerArray[2] = new ButtonManger(@"./Data/XML/buttonmanager-statemenu.xml");

            _stateOwner.Owner.GameState = new StateLoading();
            _stateOwner.Owner.GameState.InitState(null, _stateOwner.Owner);
            ((StateLoading)_stateOwner.Owner.GameState).GetDataLoading(_stateOwner.Owner.Content, @"./Data/XML/loadingtomenu.xml", objectManagerArray, typeof(StateMenuManager));
            _stateOwner.Owner.GameState.EnterState();
        }