private void FrmMap_KeyDown(object sender, KeyEventArgs e) { MoveDir dir = MoveDir.NO_MOVE; switch (e.KeyCode) { case Keys.Left: dir = MoveDir.LEFT; break; case Keys.Right: dir = MoveDir.RIGHT; break; case Keys.Up: dir = MoveDir.UP; break; case Keys.Down: dir = MoveDir.DOWN; break; case Keys.I: game.ChangeState(GameState.INVENTORY); break; case Keys.Q: Game.GetGame().Character.undead = true; Console.WriteLine("TRUE NOW, at least it should"); break; } if (dir != MoveDir.NO_MOVE) { character.Move(dir); if (game.State == GameState.FIGHTING) { FrmArena frmArena = new FrmArena(); frmArena.Show(); } } if (game.State == GameState.INVENTORY) { FrmInventory frmInventory = new FrmInventory(); frmInventory.Show(); } else if (character.pos.row == 5 && character.pos.col == 9) { game.ChangeState(GameState.BUY); } if (game.State == GameState.BUY) { FrmShop frmShop = new FrmShop(); frmShop.Show(); } }
private void FrmMap_KeyDown(object sender, KeyEventArgs e) { MoveDir dir = MoveDir.NO_MOVE; switch (e.KeyCode) { case Keys.Left: dir = MoveDir.LEFT; break; case Keys.Right: dir = MoveDir.RIGHT; break; case Keys.Up: dir = MoveDir.UP; break; case Keys.Down: dir = MoveDir.DOWN; break; case Keys.I: FrmInventory frmInventory = new FrmInventory(); frmInventory.Show(); break; } if (dir != MoveDir.NO_MOVE) { character.Move(dir); if (game.State == GameState.FIGHTING) { FrmArena frmArena = new FrmArena(); frmArena.Show(); } if (game.State == GameState.BOSSFIGHT) { FrmBossFight frmBossFight = new FrmBossFight(); character.inventory.AddWeapon(Killer); frmBossFight.Show(); } if (game.State == GameState.NEXT_LEVEL) { //TODO:ZAB this.level_on += 1; game.ChangeState(GameState.LOADING); // needs character so he moves on level 2 and more string loadmap = "Resources/level" + level_on.ToString() + ".txt"; CharWeaponList = character.inventory.ReturnWeaponList(); character = map.LoadMap(loadmap, grpMap, str => Resources.ResourceManager.GetObject(str) as Bitmap); character.inventory.SetWeaponList(CharWeaponList); if (level_on == 2) { character.inventory.AddWeapon(Crawler); } if (level_on == 3) { character.inventory.AddWeapon(Destroyer); } Width = grpMap.Width + 25; Height = grpMap.Height + 50; //moves chararter back to start of level character.BackToStart(); //code below resets the character to level 1 //game.SetCharacter(character); } if (game.State == GameState.DEAD) { //TODO : ZAB game.ChangeState(GameState.DEAD); FrmGameOver frmGameOver = new FrmGameOver(); frmGameOver.Show(); } } }