Пример #1
0
        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;
            }
            if (dir != MoveDir.NO_MOVE)
            {
                character.Move(dir);
                if (game.State == GameState.FIGHTING)
                {
                    FrmArena frmArena = new FrmArena();
                    frmArena.Show();
                }
            }
        }
Пример #2
0
        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;
            }
            if (dir != MoveDir.NO_MOVE)
            {
                character.Move(dir);
                if (game.State == GameState.FIGHTING)
                {
                    FrmArena frmArena = new FrmArena(inventory, "reg");
                    frmArena.Show();
                }
                if (game.State == GameState.LVL2)    // if the player lands on the lvl 2 square, the old map is hidden and the new map is formed
                {
                    FrmMap frmMap = new FrmMap(true, true);
                    frmMap.Show();
                    this.Close();
                }
                else if (game.State == GameState.LVL1)   // for when in lvl 2, go back to lvl 1 if on square
                {
                    FrmMap frmMap = new FrmMap(true, true);
                    frmMap.Show();
                    this.Close();
                }
                else if (game.State == GameState.TITLE_SCREEN)
                {
                    var newForm = new FrmMainMenu();
                    newForm.Show();
                    this.Close();
                }
                if (game.State == GameState.BOSS)
                {
                    FrmArena frmArena = new FrmArena(inventory, "boss");
                    frmArena.Show();
                }
            }
        }
Пример #3
0
        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();
            }
        }
Пример #4
0
        private void FrmMap_KeyDown(object sender, KeyEventArgs e)
        {
            // disallow input if we're in the middle of a fight
            if (game.State == GameState.FIGHTING)
            {
                return;
            }

            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.S:
                // SAVE HERE
                DialogResult result = MessageBox.Show("Do you want to save the current game state?", "SAVE GAME", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    Save.SaveGame();
                }
                break;

            case Keys.L:
                DialogResult response = MessageBox.Show("You are about to load a saved game. Is this correct?", "SAVE GAME", MessageBoxButtons.YesNo);
                if (response == DialogResult.Yes)
                {
                    var savelines = GameLibrary.Load.LoadGame();
                    Reload(savelines[0], savelines);
                }
                break;

            case Keys.Q:
                ExitGame();
                break;

            case Keys.I:
                FrmStats stats = new FrmStats();
                stats.Show();
                break;
            }
            if (dir != MoveDir.NO_MOVE)
            {
                // tell the character to move and check if the move was valid
                switch (character.Move(dir))
                {
                case Task.MOVE:
                    // check for enemy encounter
                    if (rand.NextDouble() < encounterChance)
                    {
                        encounterChance = 0.15;
                        Game.GetGame().ChangeState(GameState.FIGHTING);
                    }
                    else
                    {
                        encounterChance += 0.10;
                    }
                    if (game.State == GameState.FIGHTING)
                    {
                        FrmArena frmArena = new FrmArena();
                        frmArena.Show();
                    }
                    break;

                case Task.FIGHT_BOSS:
                    FrmBossArena frmBoss = new FrmBossArena();
                    frmBoss.Show();
                    break;

                case Task.LEAVE_LEVEL:
                    //this should give player option of which level to go to
                    int currentLevel = Game.GetGame().Level;
                    Game.GetGame().NextLevel();
                    if (currentLevel != Game.GetGame().Level)
                    {
                        ChangeMap("Resources/level" + Game.GetGame().Level + ".txt", Game.GetGame().Character);
                    }
                    break;

                case Task.EXIT_GAME:
                    ExitGame();
                    break;
                }
            }
        }
Пример #5
0
        private void FrmMap_KeyDown(object sender, KeyEventArgs e)
        {
            // don't allow movement if the player is in a fight
            if (game.State == GameState.FIGHTING)
            {
                return;
            }

            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.O:
                if (game.State != GameState.OPTIONS)
                {
                    FrmOptions frmOptions = new FrmOptions();
                    frmOptions.StartPosition = FormStartPosition.CenterScreen;
                    frmOptions.Show();
                    Console.WriteLine("showed");
                }
                break;
            }
            if (dir != MoveDir.NO_MOVE)
            {
                character.Move(dir);
                if (game.State == GameState.CHANGE_LEVEL1) //TLF
                {
                    this.Hide();                           // hides/close old window
                    Game.GetGame().ChangeState(GameState.ON_MAP);
                    FrmMap frmMap = new FrmMap("Resources/level.txt");
                    frmMap.Show();    // shows LEVEL 1 window
                }
                if (game.State == GameState.CHANGE_LEVEL)
                {
                    this.Hide();      // hides/close old window
                    Game.GetGame().ChangeState(GameState.ON_MAP);
                    FrmMap frmMap = new FrmMap("Resources/level2.txt");
                    frmMap.Show();                   // shows level 2 window
                }
                if (game.State == GameState.RESPAWN) //will take you back to titleScreen TLF
                {
                    this.Hide();                     // hides/close old window
                    Game.GetGame().ChangeState(GameState.ON_MAP);
                    FrmMap frmMap = new FrmMap("Resources/titleScreen.txt");
                    frmMap.Show();    // shows Title screen window
                }


                if (game.State == GameState.FIGHTING)
                {
                    FrmArena frmArena = new FrmArena();
                    frmArena.Show();
                }
                if (game.State == GameState.QUIT)//TLF
                {
                    // Changed this.Hide() to Close() because
                    // this.Hide() keeps the program running
                    // while Close() quits it altogether

                    //Application.Exit() would also work TLF

                    // BYR: You're right fam
                    Application.Exit();
                }
            }
        }
Пример #6
0
        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();
                }
            }
        }