Ejemplo n.º 1
0
        public static Entity StartBattle(Monster monster, Player player)
        {
            Entity victim = null;
            Spell  spellToCast;

            BattleActive = true;
            ConsoleKeyInfo battleCommand;

            do
            {
                switch (currentState)
                {
                case BattleState.INIT:
                {
                    UI.ClearMessageBox();
                    UI.BattleUIBuffer.Clear();
                    UI.CurrentBattleConsoleLine = 34;
                    Console.SetCursorPosition(0, 0);

                    UI.WriteBattleInstructions();
                    UI.WriteToBattleInfoArea("A battle with " + monster.Name + " begins!", UI.DEFAULT);
                    currentState = BattleState.CHOOSE_PLAYER_ACTION;
                    break;
                }

                case BattleState.CHOOSE_PLAYER_ACTION:
                {
                    do
                    {
                        IsValid       = true;
                        battleCommand = Console.ReadKey(true);

                        switch (battleCommand.Key)
                        {
                        case ConsoleKey.A:
                        {
                            player.AttackWithWeapon(monster);
                            break;
                        }

                        case ConsoleKey.S:
                        {
                            spellToCast = ChooseSpell(player);

                            if (spellToCast != null)
                            {
                                Spell.CastSpell(spellToCast, player, monster);
                                break;
                            }
                            else
                            {
                                IsValid = false;
                            }
                            break;
                        }

                        default:
                        {
                            UI.WriteToBattleInfoArea("Please choose a correct command", UI.DEFAULT);
                            IsValid = false;
                            break;
                        }
                        }

                        UI.ClearBattleMenuScreen();
                    } while (!IsValid);
                    //currentState = BattleState.PROCESS_PLAYER_ACTION;
                    break;
                }

                case BattleState.PROCESS_PLAYER_ACTION:
                {
                    switch (battleCommand.Key)
                    {
                    }
                    break;
                }

                case BattleState.CHOOSE_MONSTER_ACTION:
                {
                    break;
                }

                case BattleState.PROCESS_MONSTER_ACTION:
                {
                    break;
                }

                case BattleState.CHECK_FOR_DEATH:
                {
                    break;
                }

                default:
                {
                    break;
                }
                }
            } while (BattleActive);

            return(victim);
        }
Ejemplo n.º 2
0
        public static Entity StartBattle(Monster monster, Player player)
        {
            Entity victim = null;
            Spell  spellToCast;

            BattleActive = true;
            ConsoleKeyInfo battleCommand;

            do
            {
                do
                {
                    isValid       = true;
                    battleCommand = Console.ReadKey(true);

                    switch (battleCommand.Key)
                    {
                    case ConsoleKey.A:
                    {
                        player.AttackWithWeapon(monster);
                        break;
                    }

                    case ConsoleKey.S:
                    {
                        spellToCast = ChooseSpell(player);

                        if (spellToCast != null)
                        {
                            Spell.CastSpell(spellToCast, player, monster);
                            break;
                        }
                        else
                        {
                            isValid = false;
                        }
                        break;
                    }

                    default:
                    {
                        UI.WriteToBattleInfoArea("Please choose a correct command", UI.DEFAULT);
                        isValid = false;
                        break;
                    }
                    }

                    UI.ClearBattleMenuScreen();
                } while (!isValid);

                if (CheckIfIsDead(monster))
                {
                    UI.WriteToBattleInfoArea("The monster lies dead at your feet. You get " + monster.ExperiencePointsValue + " Experience and " + monster.GoldValue + " Gold.", UI.DEFAULT);
                    BattleActive = false;
                    victim       = monster;
                    break;
                }

                monster.DamagePlayer(player);

                //Update GUI
                UI.DrawGUI(player);

                if (CheckIfIsDead(player))
                {
                    UI.WriteToBattleInfoArea("Sadly, you were defeated by the " + monster.Name + ". Your deeds will never be known to the rest of the world.", UI.DEFAULT);
                    BattleActive = false;
                    victim       = player;
                    break;
                }
            } while (BattleActive);

            UI.CurrentConsoleLine = 46 + UI.UIBuffer.Count;
            return(victim);
        }