Beispiel #1
0
        //make a loop to hold player movement and other values
        public static bool GameLoop(Adventurer adventurer, Universe universe)
        {
            Random random    = new Random();
            int    encounter = 0;
            bool   playing   = true;
            bool   win       = false;

            TextBoxViews.DisplayPlayerInfo(adventurer);
            TextBoxViews.DisplayHeader();
            Console.CursorVisible = false;
            while (playing)
            {
                TextBoxViews.DisplayPosition(adventurer);
                playing = Map.movement(adventurer, universe);
                Map.CheckPosition(adventurer, universe);
                encounter = random.Next(1, 30);
                if (encounter < 2 && adventurer.MapLocation == Humanoid.Location.MainWorld)
                {
                    Slime slime = new Slime();
                    Slime.InitializeNewSlime(slime);
                    playing = Battle.BattleLoop(adventurer, universe, slime);
                }
                if (universe.TripleTrouble[0].Defeated && universe.TripleTrouble[1].Defeated && universe.TripleTrouble[2].Defeated)
                {
                    adventurer.playerWin = true;
                    playing = false;
                }
                if (adventurer.diedOnFinal)
                {
                    playing = false;
                }
            }
            return(win);
        }
Beispiel #2
0
        /// <summary>
        /// lets you talk to NPC's
        /// Cycles through set text each npc has
        /// </summary>
        /// <param name="adventurer"></param>
        /// <param name="universe"></param>
        public static void NPCTalk(Adventurer adventurer, Universe universe)
        {
            int xPos = adventurer.Xpos;
            int yPos = adventurer.Ypos;


            if (adventurer.InaHouse && adventurer.InHouseName == House.houseName.Market)
            {
                switch (adventurer.LookDirection)
                {
                case Humanoid.Direction.LEFT:
                    xPos -= 2;
                    break;

                case Humanoid.Direction.RIGHT:
                    xPos++;
                    break;

                case Humanoid.Direction.UP:
                    yPos--;
                    break;

                case Humanoid.Direction.DOWN:
                    yPos++;
                    break;

                default:

                    break;
                }
            }
            else
            {
                switch (adventurer.LookDirection)
                {
                case Humanoid.Direction.LEFT:
                    xPos--;
                    break;

                case Humanoid.Direction.RIGHT:
                    xPos++;
                    break;

                case Humanoid.Direction.UP:
                    yPos--;
                    break;

                case Humanoid.Direction.DOWN:
                    yPos++;
                    break;

                default:

                    break;
                }
            }

            bool trig = true;

            string text = "There is no-one to talk with in front of you, Are you going insane?";

            foreach (NPC npc in universe.NPCList)
            {
                if (npc.Xpos == xPos && npc.Ypos == yPos)
                {
                    TextBoxViews.RedrawBox(universe, 7);
                    TextBoxViews.WriteToNpcNameBox(npc.Name);

                    text = npc.messages[npc.listCurrent];
                    npc.listCurrent++;
                    if (npc.MapLocation == adventurer.MapLocation)
                    {
                        if (npc.Name == "Merchant")
                        {
                            TextBoxViews.MerchantMessage(universe, adventurer);
                            trig = false;
                            QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping);
                        }
                        else if (npc.Name == "OLD MAN")
                        {
                            QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan);
                        }
                        else if (npc.Name == "Cerri")
                        {
                            if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1)
                            {
                                TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!");
                                adventurer.ItemsDictionary[Item.Items.Parcel]--;
                                TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles.");
                                adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2;
                                trig = false;
                                QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel);
                            }
                        }
                        else if (npc.Name == "Arista")
                        {
                            adventurer.Health = adventurer.MaxHealth;
                        }
                    }
                    else if (adventurer.InHouseName == npc.InHouseName)
                    {
                        if (npc.Name == "Merchant")
                        {
                            TextBoxViews.MerchantMessage(universe, adventurer);
                            trig = false;
                            QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping);
                        }
                        else if (npc.Name == "OLD MAN")
                        {
                            QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan);
                        }
                        else if (npc.Name == "Cerri")
                        {
                            if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1)
                            {
                                TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!");
                                adventurer.ItemsDictionary[Item.Items.Parcel]--;
                                TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles.");
                                adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2;
                                trig = false;
                                QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel);
                            }
                        }
                        else if (npc.Name == "Arista")
                        {
                            adventurer.Health = adventurer.MaxHealth;
                        }
                    }



                    if (npc.listCurrent >= npc.listMax)
                    {
                        npc.listCurrent = 0;
                    }
                    TextBoxViews.RemoveBox(universe, 7);
                    TextBoxViews.RemoveContent(universe, 7);
                }
            }
            if (adventurer.MapLocation == Humanoid.Location.Cave)
            {
                foreach (var enemy in universe.TripleTrouble)
                {
                    if (!enemy.Defeated && (enemy.Ypos == yPos) && (enemy.Xpos == xPos))
                    {
                        TextBoxViews.WriteToMessageBox(universe, "I will Beat you!!!");
                        enemy.Defeated = true;
                        Slime slime = new Slime();
                        Slime.InitializeNewSlime(slime, true);
                        adventurer.diedOnFinal = !Battle.BattleLoop(adventurer, universe, slime);
                    }
                }
            }
            if (trig)
            {
                TextBoxViews.WriteToMessageBox(universe, text);
            }
        }