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);
            }
        }
        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);
                }
            }
        }