Пример #1
0
        public static bool BattleLoop(Adventurer adventurer, Universe universe, Slime slime)
        {
            TextBoxViews.ClearMapBox();
            TextBoxViews.RedrawBox(universe, 6);

            bool blocked;
            bool stillAlive = true;

            TextBoxViews.ReWriteToMessageBox(universe, "A slime attacks!");
            Random random = new Random();

            do
            {
                TextDrawings.DisplaySlime(slime);

                TextBoxViews.WriteToEvent("Slime : " + slime.Health);
                TextBoxViews.DisplayPlayerInfo(adventurer);

                blocked = Attack(adventurer, universe, slime);

                TextBoxViews.WriteToEvent("Slime : " + slime.Health);

                if (slime.Health > 0)
                {
                    SlimeATK(adventurer, universe, slime, blocked);
                }
            } while ((adventurer.Health > 0) && (slime.Health > 0));
            if (adventurer.Health > 0)
            {
                int coinDrop;
                int gelDrop;
                int expGain;

                coinDrop = random.Next(10, 30);
                gelDrop  = random.Next(5, 15);
                expGain  = random.Next(10, slime.ExpGiv);

                TextBoxViews.WriteToMessageBox(universe, $"You have succeeded in battle and have recieved {coinDrop} coins and {gelDrop} gel.");

                adventurer.Coins += coinDrop;
                adventurer.ItemsDictionary[Item.Items.SlimeGel] += gelDrop;
                adventurer.Experinece += expGain;
                if (adventurer.Experinece >= adventurer.MaxExperience)
                {
                    Adventurer.PlayerLevelUp(adventurer, universe);
                }
            }
            else
            {
                stillAlive = false;
            }
            TextBoxViews.ClearMapBox();
            TextBoxViews.RemoveContent(universe, 3);
            TextBoxViews.DisplayMenu(universe);
            TextBoxViews.DisplayPlayerInfo(adventurer);

            return(stillAlive);
        }
Пример #2
0
        /// <summary>
        /// Checks the player's position Handles BOTH mainworld and House Locations
        /// </summary>
        /// <param name="universe"></param>
        /// <param name="adventurer"></param>
        public static void CheckPlayerPosition(Universe universe, Adventurer adventurer)
        {
            if (!adventurer.InaHouse)
            {
                switch (adventurer.MapLocation)
                {
                case Humanoid.Location.MainWorld:
                    foreach (Towns town in universe.TownList)
                    {
                        if (adventurer.Ypos == town.Ypos && adventurer.Xpos == town.Xpos)
                        {
                            TextBoxViews.RedrawBox(universe, 6);
                            TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString());


                            TextBoxViews.ClearMapBox();
                            adventurer.MapLocation = town.TownLocName;
                            adventurer.PreviousLocations.Add(adventurer.MapLocation);
                            adventurer.Xpos = 40;
                            adventurer.Ypos = 48;
                        }
                    }
                    TextBoxViews.RedrawBox(universe, 6);
                    TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString());
                    break;

                case Humanoid.Location.TutTown:
                    if (adventurer.Ypos >= 50)
                    {
                        TextBoxViews.ClearMapBox();
                        adventurer.MapLocation = Humanoid.Location.MainWorld;
                        adventurer.Xpos        = universe.TownList[0].Xpos;
                        adventurer.Ypos        = universe.TownList[0].Ypos;
                        adventurer.PreviousLocations.Add(adventurer.MapLocation);
                        Map.QuestTrigger(adventurer, universe, Adventurer.Quest.LeaveHome);
                        TextBoxViews.RedrawBox(universe, 6);
                        TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString());
                    }
                    foreach (var house in universe.HouseList)
                    {
                        if ((adventurer.Xpos == house.EnterPosition[0]) && (adventurer.Ypos == house.EnterPosition[1]) && (house.HouseLoc == Humanoid.Location.TutTown))
                        {
                            adventurer.InaHouse    = true;
                            house.PlayerInside     = true;
                            adventurer.Xpos        = 56;
                            adventurer.Ypos        = 32;
                            adventurer.InHouseName = house.HouseName;
                            TextBoxViews.RedrawBox(universe, 6);
                            TextBoxViews.WriteToEvent(adventurer.InHouseName.ToString());

                            TextBoxViews.ClearMapBox();
                        }
                    }
                    TextBoxViews.RedrawBox(universe, 6);
                    TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString());

                    break;

                case Humanoid.Location.CherryGrove:
                    Map.QuestTrigger(adventurer, universe, Adventurer.Quest.TheNewGuyInTown);
                    if (adventurer.Ypos >= 50)
                    {
                        TextBoxViews.ClearMapBox();
                        adventurer.MapLocation = Humanoid.Location.MainWorld;

                        adventurer.Xpos = universe.TownList[1].Xpos;
                        adventurer.Ypos = universe.TownList[1].Ypos;
                        adventurer.PreviousLocations.Add(adventurer.MapLocation);
                    }
                    foreach (var house in universe.HouseList)
                    {
                        if ((adventurer.Xpos == house.EnterPosition[0]) && (adventurer.Ypos == house.EnterPosition[1]) && (house.HouseLoc == Humanoid.Location.CherryGrove))
                        {
                            adventurer.InaHouse    = true;
                            house.PlayerInside     = true;
                            adventurer.Xpos        = 56;
                            adventurer.Ypos        = 32;
                            adventurer.InHouseName = house.HouseName;

                            TextBoxViews.RedrawBox(universe, 6);
                            TextBoxViews.WriteToEvent(adventurer.InHouseName.ToString());

                            TextBoxViews.ClearMapBox();
                        }
                    }
                    TextBoxViews.RedrawBox(universe, 6);
                    TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString());
                    break;

                case Humanoid.Location.Cave:
                    if (adventurer.Ypos >= 50)
                    {
                        TextBoxViews.ClearMapBox();
                        adventurer.MapLocation = Humanoid.Location.MainWorld;


                        adventurer.Xpos = universe.TownList[3].Xpos;
                        adventurer.Ypos = universe.TownList[3].Ypos;
                        adventurer.PreviousLocations.Add(adventurer.MapLocation);
                    }

                    break;

                default:
                    break;
                }
            }
            else if (adventurer.InaHouse)
            {
                switch (adventurer.InHouseName)
                {
                case House.houseName.None:
                    break;

                case House.houseName.PlayerHome:

                    Map.QuestTrigger(adventurer, universe, Adventurer.Quest.GoHome);

                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                case House.houseName.HealHouse:
                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                case House.houseName.Market:
                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                case House.houseName.CerriHouse:

                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                case House.houseName.AmastaHouse:
                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                case House.houseName.AristaHouse:
                    if (adventurer.Xpos == 56 && adventurer.Ypos == 33)
                    {
                        adventurer.InaHouse = false;

                        foreach (var house in universe.HouseList)
                        {
                            if (adventurer.InHouseName == house.HouseName)
                            {
                                house.PlayerInside     = false;
                                adventurer.InHouseName = House.houseName.None;

                                adventurer.Xpos = house.EnterPosition[0];
                                adventurer.Ypos = house.EnterPosition[1] + 1;
                            }
                        }
                        TextBoxViews.ClearMapBox();
                    }
                    break;

                default:
                    break;
                }
            }
        }