public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner) { base.InitState(objectManagerArray, owner); _listOfGameState = new List<GameState>(); _menubg = (Background)objectManagerArray[0].CreateObject(0); //Index = 0; StateMenu _stateMenu = new StateMenu(); _stateMenu.InitState(objectManagerArray, owner); _stateMenu.GameStateOwner = this; //Index = 1 StateLoadGame _stateLoadGame = new StateLoadGame(); _stateLoadGame.InitState(objectManagerArray, owner); _stateLoadGame.GameStateOwner = this; //Index = 2 StateOptions _stateOptions = new StateOptions(); _stateOptions.InitState(objectManagerArray, owner); _stateOptions.GameStateOwner = this; //Index = 3 StateHelps _stateHelps = new StateHelps(); _stateHelps.InitState(objectManagerArray, owner); _stateHelps.GameStateOwner = this; //Index = 4 StateIntro _stateIntro = new StateIntro(); _stateIntro.InitState(objectManagerArray, owner); _stateIntro.GameStateOwner = this; _listOfGameState.Add(_stateMenu); _listOfGameState.Add(_stateLoadGame); _listOfGameState.Add(_stateOptions); _listOfGameState.Add(_stateHelps); _listOfGameState.Add(_stateIntro); }
//Mảng các objectManager: người dùng cần phải biết mảng hiện thời gôm những //objectManager nào và vị trí của nó nằm trong mảng //Sau đó sử dụng lệnh createObject để tạo ra đúng đối tượng mình cần. public virtual void InitState(GameObjectManager[] objectManagerArray, MainGame owner) { Owner = owner; }
//--------------FUNCTION---------------------------------------------------------------------------- public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner) { base.InitState(objectManagerArray, owner); }
//Lấy vào chuỗi xml định nghĩa một số thông tin riêng của Loading state (hình //ảnh backGround, hình ảnh processBar) mảng các objectManager cần load và kiểu //của Game state kế tiếp. public void GetDataLoading(ContentManager content, string xmlInfo, GameObjectManager[] objectManagerArray, Type type) { _nObjectManager = objectManagerArray.Length; _objectManagerArray = new GameObjectManager[_nObjectManager]; for (int i = 0; i < _nObjectManager; i++) { _objectManagerArray[i] = objectManagerArray[i]; //1 step là 1 doi tuong prototype cần load. _stepLengh += _objectManagerArray[i]._nprototype; } _stepLengh++; // them cai innit cho gamestate tip theo. _type = type; //Lưu lại type của state tip theo _xmlInfo = xmlInfo; //Lưu lại chuoi XML luu thong tin rieng cua loadind state XmlDocument _doc = new XmlDocument(); _doc.Load(_xmlInfo); XmlNode _backGroundNote = _doc.DocumentElement.SelectSingleNode("BackGround"); XmlNodeList _imageNoteList = _backGroundNote.SelectNodes("//Image"); _nBackGroundImage = _imageNoteList.Count; _backGroundImage = new GameSprite[_nBackGroundImage]; for (int i = 0; i < _nBackGroundImage; i++) { Texture2D _temp = content.Load<Texture2D>(_imageNoteList[i].SelectSingleNode("Path").InnerText); int _xTemp = int.Parse(_imageNoteList[i].SelectSingleNode("X").InnerText) - (int)GlobalVariables.dX; int _yTemp = int.Parse(_imageNoteList[i].SelectSingleNode("Y").InnerText) - (int)GlobalVariables.dY; _backGroundImage[i] = new GameSprite(_temp, _xTemp, _yTemp); _backGroundImage[i].Xoffset = 0; _backGroundImage[i].Yoffset = 0; } _delayTime = int.Parse(_doc.DocumentElement.SelectSingleNode("DelayTime").InnerText); string _processXMLInfo = _doc.DocumentElement.SelectSingleNode("ProcessBar").SelectSingleNode("ContentName").InnerText; //Truyền va init tại chỗ vì cái ProcessBarManager chỉ xài cho loading state ProcessBarManager pbm = new ProcessBarManager(_processXMLInfo); for (int i = 0; i < pbm._nprototype; i++) { pbm.InitOne(content, i); } _processBar = (ProcessBar)pbm.CreateObject(0); }
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 InitState(GameObjectManager[] objectManagerArray, MainGame owner) { base.InitState(objectManagerArray, owner); //_introFrame = (GameFrame)objectManagerArray[1].CreateObject(7); //_introMotion = _introFrame.Motion.Clone(); //_introDelayTime = _introFrame.DelayTime; _introFrames = (GameFrame)objectManagerArray[1].CreateObject(7); _introFrameMotion = _introFrames.Motion.Clone(); _introFrameDelayTime = _introFrames.DelayTime; _dacPhuFrame = (GameFrame)objectManagerArray[1].CreateObject(13); _minhQuanFrame = (GameFrame)objectManagerArray[1].CreateObject(14); _introGameFrame = (GameFrame)objectManagerArray[1].CreateObject(15); _introFrames.AddChild(_introGameFrame); _introFrames.AddChild(_dacPhuFrame); _introFrames.AddChild(_minhQuanFrame); _currentIntroFrame = 0; _selectMode = (GameFrame)objectManagerArray[1].CreateObject(8); _selectMode.Move_Complete += new GameFrame.OnMoveCompletedHandler(Move_Complete_SelectFrame); _selectMotion = _selectMode.Motion.Clone(); _selectDelayTime = _selectMode.DelayTime; _aboutGameButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(9); _aboutGameButton = (Button)objectManagerArray[2].CreateObject(6); _aboutGameButton.IsPressButton = true; _aboutGameButtonFrame.AddChild(_aboutGameButton); _aboutGameButton.Mouse_Down += new Button.OnMouseDownHandler(AboutGame_Down); _aboutGameButton.Mouse_Hover += new Button.OnMouseHoverHandler(AboutGame_Hover); _aboutMotion = _aboutGameButtonFrame.Motion.Clone(); _aboutDelayTime = _aboutGameButtonFrame.DelayTime; //Set Button này được Click trước _aboutGameButton._sprite[0].Itexture2D = 1; _programer1ButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(10); _programer1Button = (Button)objectManagerArray[2].CreateObject(7); _programer1Button.IsPressButton = true; _programer1ButtonFrame.AddChild(_programer1Button); _programer1Button.Mouse_Down += new Button.OnMouseDownHandler(Programer1_Down); _programer1Button.Mouse_Hover += new Button.OnMouseHoverHandler(Programer1_Hover); _programer1Motion = _programer1ButtonFrame.Motion.Clone(); _programer1DelayTime = _programer1ButtonFrame.DelayTime; _programer2ButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(11); _programer2Button = (Button)objectManagerArray[2].CreateObject(8); _programer2Button.IsPressButton = true; _programer2ButtonFrame.AddChild(_programer2Button); _programer2Button.Mouse_Down += new Button.OnMouseDownHandler(Programer2_Down); _programer2Button.Mouse_Hover += new Button.OnMouseHoverHandler(Programer2_Hover); _programer2Motion = _programer2ButtonFrame.Motion.Clone(); _programer2DelayTime = _programer2ButtonFrame.DelayTime; _exitButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(12); _exitButtonFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(Move_Complete_ExitFrame); _exitButton = (Button)objectManagerArray[2].CreateObject(5); _exitButtonFrame.AddChild(_exitButton); _exitButton.Mouse_Click += new Button.OnMouseClickHandler(Exit_Clicked); _exitButton.Mouse_Hover += new Button.OnMouseHoverHandler(Exit_Hover); _exitMotion = _exitButtonFrame.Motion.Clone(); _exitDelayTime = _exitButtonFrame.DelayTime; }
public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner) { base.InitState(objectManagerArray, owner); _map = (Map)objectManagerArray[1].CreateObject(0); GlobalVariables.MapCollisionDim = _map.CollisionDim; _char = (PlayerCharacter)objectManagerArray[0].CreateObject(0); _char.SetMap(_map); _char.StateOwner = this; _map.Owner = this; _listMonsters = _map.InitMonsterList((MonsterManager)objectManagerArray[2],@"Data\Map\map01\map01_monster.xml"); _frog = new Fog(); _frog.Init(owner.Content); _frog.SetCharacter(_char); _displayMessageLayer = new DisplayMessageLayer(); //Phần ???--------------------------------------------------------------------------- _listPortral = _map.InitPortralList((PortralManager)objectManagerArray[4], @"Data\Map\map01\map01_portral.xml"); _listObstacle = _map.InitObstacle((MapObstacleManager)objectManagerArray[5], @"Data\Map\map01\map01_obstacle.xml"); _objectManagerArray = objectManagerArray; _listToDraw = new List<VisibleGameEntity>(); _char.InitSkill(); //Phần healthbar-------------------------------------------------------------------- _healthBar = new HealthBar(); _healthBar.SetCharacter(_char); List<GameObjectManager> _resourcesForHealthbar = new List<GameObjectManager>(); _resourcesForHealthbar.Add(objectManagerArray[8]); _resourcesForHealthbar.Add(objectManagerArray[9]); _resourcesForHealthbar.Add(objectManagerArray[10]); _resourcesForHealthbar.Add(objectManagerArray[11]); _healthBar.GetResources(_resourcesForHealthbar); //Phần SkillBoard------------------------------------------------------------------ _skillBoard = new SkillBoard(); _skillBoard.SetCharacter(_char); List<GameObjectManager> _resourcesForSkillBoard = new List<GameObjectManager>(); _resourcesForSkillBoard.Add(objectManagerArray[8]); _resourcesForSkillBoard.Add(objectManagerArray[10]); _resourcesForSkillBoard.Add(objectManagerArray[11]); _skillBoard.GetResources(_resourcesForSkillBoard); //Phần Left-hand selection frame _lhSkillSelectionFrame = new LHSkillSelectionFrame(); _lhSkillSelectionFrame.SetCharacter(_char); List<GameObjectManager> _resourceForLHSSelectionFrame = new List<GameObjectManager>(); _resourceForLHSSelectionFrame.Add(_objectManagerArray[8]); _resourceForLHSSelectionFrame.Add(_objectManagerArray[10]); _lhSkillSelectionFrame.GetResources(_resourceForLHSSelectionFrame); //Phần Right-hand selection frame _rhSkillSelectionFrame = new RHSkillSelectionFrame(); _rhSkillSelectionFrame.SetCharacter(_char); _rhSkillSelectionFrame.GetResources(_resourceForLHSSelectionFrame); //Phần subMenu _subMenu = new SubMenu(); List<GameObjectManager> _resourceForSubMenu = new List<GameObjectManager>(); _resourceForSubMenu.Add(_objectManagerArray[8]); _resourceForSubMenu.Add(_objectManagerArray[10]); _subMenu.GetResources(_resourceForSubMenu); _subMenu.GetStateOwner(this); //Phần infoBoard _infoBoard = new InfoBoard(); _infoBoard.SetCharacter(_char); List<GameObjectManager> _resourceForInfo = new List<GameObjectManager>(); _resourceForInfo.Add(_objectManagerArray[8]); _resourceForInfo.Add(_objectManagerArray[10]); _resourceForInfo.Add(_objectManagerArray[11]); _infoBoard.GetResources(_resourceForInfo); }
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(); } }
public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner) { //Trong innit tao base.InitState(objectManagerArray, owner); _newgameFrame = (GameFrame)objectManagerArray[1].CreateObject(0); _newgameFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_NewGame); _newgameButton = (Button)objectManagerArray[2].CreateObject(0); _newgameFrame.AddChild(_newgameButton); _newgameButton.Owner = _newgameFrame; _newgameButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_NewGame); _newgameButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_NewGame); _newgameFrameMotion = _newgameFrame.Motion.Clone(); _newgameDelayTimeGoIn = _newgameFrame.DelayTime; _loadgameFrame = (GameFrame)objectManagerArray[1].CreateObject(1); _loadgameFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Load); _loadgameButton = (Button)objectManagerArray[2].CreateObject(1); _loadgameFrame.AddChild(_loadgameButton); _loadgameButton.Owner = _loadgameFrame; _loadgameButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Load); _loadgameButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Load); _loadgameFrameMotion = _loadgameFrame.Motion.Clone(); _loadgameDelayTimeGoIn = _loadgameFrame.DelayTime; _optionFrame = (GameFrame)objectManagerArray[1].CreateObject(2); _optionFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Option); _optionButton = (Button)objectManagerArray[2].CreateObject(2); _optionFrame.AddChild(_optionButton); _optionButton.Owner = _optionFrame; _optionButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Option); _optionButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Option); _optionFrameMotion = _optionFrame.Motion.Clone(); _optionDelayTimeGoIn = _optionFrame.DelayTime; _helpFrame = (GameFrame)objectManagerArray[1].CreateObject(3); _helpFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Help); _helpButton = (Button)objectManagerArray[2].CreateObject(3); _helpFrame.AddChild(_helpButton); _helpButton.Owner = _helpFrame; _helpButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Help); _helpButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Help); _helpFrameMotion = _helpFrame.Motion.Clone(); _helpDelayTimeGoIn = _helpFrame.DelayTime; _aboutFrame = (GameFrame)objectManagerArray[1].CreateObject(4); _aboutFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_About); _aboutButton = (Button)objectManagerArray[2].CreateObject(4); _aboutFrame.AddChild(_aboutButton); _aboutButton.Owner = _aboutFrame; _aboutButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_About); _aboutButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_About); _aboutFrameMotion = _aboutFrame.Motion.Clone(); _aboutDelayTimeGoIn = _aboutFrame.DelayTime; _quitFrame = (GameFrame)objectManagerArray[1].CreateObject(5); _quitFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Quit); _quitButton = (Button)objectManagerArray[2].CreateObject(5); _quitFrame.AddChild(_quitButton); _quitButton.Owner = _quitFrame; _quitButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Quit); _quitButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Quit); _quitFrameMotion = _quitFrame.Motion.Clone(); _quitDelayTimeGoIn = _quitFrame.DelayTime; _menuFrame = (GameFrame)objectManagerArray[1].CreateObject(6); _menuFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_MenuFrame); _menuFrameMotion = _menuFrame.Motion.Clone(); _menuFrameDelayTimeGoIn = _menuFrame.DelayTime; }
//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(); }