コード例 #1
0
        //loads items for general store
        public void loadGeneral()
        {
            Potions smallPotion = new Potions("Small Potion", 5, 0, 0, 0, "Grants 5 hp", 3, 1);
            Potions potion      = new Potions("Potion", 10, 0, 0, 0, "Grants 10 hp", 7, 1);
            Potions largePotion = new Potions("large Potion", 16, 0, 0, 0, "Grants 16 hp", 15, 1);
            Potions vigor       = new Potions("Vigor", 0, 2, 2, 3, "Lightly increases mp and str for 3 rounds", 15, 1);

            generalStoreitems.Add(smallPotion);
            generalStoreitems.Add(potion);
            generalStoreitems.Add(largePotion);
            generalStoreitems.Add(vigor);
        }
コード例 #2
0
        //load file
        private void button1_Click(object sender, EventArgs e)
        {
            Inventory tempInven = new Inventory();

            inventory.player      = tempInven.player;
            inventory             = tempInven;
            inventory.playerItems = tempInven.playerItems;
            OpenFileDialog open = new OpenFileDialog();

            open.Title  = "Load a file";
            open.Filter = "Text File | *.txt";
            if (open.ShowDialog() == DialogResult.OK)
            {
                StreamReader reader = new StreamReader(open.FileName);
                string       s      = "";

                List <string> lines = new List <string>();

                while ((s = reader.ReadLine()) != null)
                {
                    lines.Add(s);
                }

                if (lines[0] == "Fighter")
                {
                    Fighter fighter = new Fighter(lines[1]);
                    fighter.maxhp     = int.Parse(lines[2]);
                    fighter.currenthp = int.Parse(lines[3]);
                    fighter.mp        = int.Parse(lines[4]);
                    fighter.str       = int.Parse(lines[5]);
                    fighter.level     = int.Parse(lines[6]);
                    fighter.exp       = int.Parse(lines[7]);
                    fighter.progress  = int.Parse(lines[8]);
                    inventory.player  = fighter;
                }
                else if (lines[0] == "Wizard")
                {
                    Wizard fighter = new Wizard(lines[1]);
                    fighter.maxhp     = int.Parse(lines[2]);
                    fighter.currenthp = int.Parse(lines[3]);
                    fighter.mp        = int.Parse(lines[4]);
                    fighter.str       = int.Parse(lines[5]);
                    fighter.level     = int.Parse(lines[6]);
                    fighter.exp       = int.Parse(lines[7]);
                    fighter.progress  = int.Parse(lines[8]);
                    inventory.player  = fighter;
                }
                inventory.playerGold = int.Parse(lines[9]);

                for (int i = 0; i < lines.Count; i++)
                {
                    if (lines[i] == "@")
                    {
                        switch (int.Parse(lines[i + 1]))
                        {
                        case 0:
                            Potions potion = new Potions(lines[i + 2], int.Parse(lines[i + 3]), int.Parse(lines[i + 4]), int.Parse(lines[i + 5]), int.Parse(lines[i + 6]), lines[i + 7], decimal.Parse(lines[i + 8]), decimal.Parse(lines[i + 9]));
                            inventory.playerItems.Add(potion);
                            break;

                        case 1:
                            string  name        = lines[i + 2];
                            int     hp          = int.Parse(lines[i + 3]);
                            int     str         = int.Parse(lines[i + 4]);;
                            int     mp          = int.Parse(lines[i + 5]);
                            int     rounds      = int.Parse(lines[i + 6]);
                            string  description = lines[i + 7];
                            decimal cost        = decimal.Parse(lines[i + 8]);
                            decimal sellprice   = decimal.Parse(lines[i + 9]);

                            Weapon weapon = new Weapon(name, str, mp, cost, description, sellprice);
                            inventory.playerItems.Add(weapon);
                            break;
                        }
                    }
                }
                //spells
                for (int i = 0; i < lines.Count; i++)
                {
                    if (lines[i] == "$$")
                    {
                        string  name        = lines[i + 1];
                        int     mp          = int.Parse(lines[i + 2]);
                        int     str         = int.Parse(lines[i + 3]);;
                        int     hp          = int.Parse(lines[i + 4]);
                        string  description = lines[i + 5];
                        int     rounds      = int.Parse(lines[i + 6]);
                        int     spellType   = int.Parse(lines[i + 7]);
                        int     itemType    = int.Parse(lines[i + 8]);
                        decimal cost        = decimal.Parse(lines[i + 10]);
                        decimal sellprice   = decimal.Parse(lines[i + 9]);

                        Spells spell = new Spells(name, mp, hp, str, rounds, spellType, description, cost, sellprice);
                        inventory.spells.Add(spell);
                    }
                }


                this.Close();
                thread = new Thread(openTown);
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
        }
コード例 #3
0
        //button one click
        private void btnOne_Click(object sender, EventArgs e)
        {
            buttonClick();

            switch (progression)
            {
            //To the cave
            case 0:
                progression = 1;
                break;

            //striaght ahead in the cave
            case 1:
                progression = 3;
                break;

            //hatchet in the tree
            case 2:
                if (treeWin == false)
                {
                    Random rng       = new Random();
                    int    treeSwing = rng.Next(1, 11);
                    inventory.player.currenthp = inventory.player.currenthp - treeSwing;
                    MessageBox.Show($"As you try to take the hatchet the tree comes to life and attacks you with it's branch for {treeSwing} damage!");

                    Monster tree  = new Monster("Tree", 1, 3, 20, 0, "hurled razor leaves at you", "slapped you with a branch");
                    bool    dub   = false;
                    Fight   fight = new Fight(inventory, tree, dub);
                    fight.specialWin += special;
                    fight.ShowDialog();

                    if (specialWin == true)
                    {
                        if (inventory.player is Fighter)
                        {
                            Weapon hatchet = new Weapon("Hatchet", 20, 0, 0, "Magic infused hatchet that will deal up to 20 damage.", 100);
                            inventory.playerItems.Add(hatchet);
                        }
                        else if (inventory.player is Wizard)
                        {
                        }
                        MessageBox.Show("You successfull pull the hatchet from the tree and it is added to your inventory.");
                        text[progression] = "The tree has returned to normal. All you can do is turn back.";
                        treeWin           = true;
                        specialWin        = false;
                        btnOne.Visible    = false;
                    }
                }
                if (treeWin == true)
                {
                    btnOne.Visible = false;
                }

                break;

            //chest
            case 3:
                if (chest == false)
                {
                    Potions smallPotion = new Potions("Small Potion", 5, 0, 0, 0, "Grants 5 hp", 3, 1);
                    inventory.playerItems.Add(smallPotion);
                    inventory.playerItems.Add(smallPotion);
                    MessageBox.Show("The chest contained x2 Small potions!");
                    textBox1.Text = "You venture straight ahead into the darkness. Continuing onwards you can start to make out a small source of light and sprint forwards. You reach a room lit by a torch on the wall. To the right there is a path to follow. Will you continue or cower away?";
                    chest         = true;
                }
                break;

            //boss
            case 5:
                progression = 6;
                break;
            }

            progressionChange();
        }
コード例 #4
0
        private void btnUse_Click(object sender, EventArgs e)
        {
            if (cmbItems.SelectedIndex != -1)
            {
                Potions selectedPotion = potions[cmbItems.SelectedIndex];

                //if potion is raising mp and str
                if (selectedPotion.Mp > 0 && selectedPotion.Str > 0)
                {
                    inventory.player.mp  = selectedPotion.Mp + inventory.player.mp;
                    inventory.player.str = selectedPotion.Str + inventory.player.str;
                    MessageBox.Show($"Your mp has been raised by {selectedPotion.Mp} and your str by {selectedPotion.Str} for {selectedPotion.Rounds} rounds!");
                    PotionRoundscs pot = new PotionRoundscs();
                    pot.currentRound = currentRound;
                    pot.potion       = selectedPotion;
                    potionRounds?.Invoke(this, pot);
                    for (int i = 0; i < inventory.playerItems.Count; i++)
                    {
                        if (inventory.playerItems[i] == selectedPotion)
                        {
                            inventory.playerItems.RemoveAt(i);
                        }
                    }
                }

                //if potion is raising Mp
                else if (selectedPotion.Mp > 0 && selectedPotion.Str < 0)
                {
                    inventory.player.mp = selectedPotion.Mp + inventory.player.mp;
                    MessageBox.Show($"Your mp has been raised by {selectedPotion.Mp}  for {selectedPotion.Rounds} rounds!");
                    PotionRoundscs pot = new PotionRoundscs();
                    pot.currentRound = currentRound;
                    pot.potion       = selectedPotion;
                    potionRounds?.Invoke(this, pot);
                    for (int i = 0; i < inventory.playerItems.Count; i++)
                    {
                        if (inventory.playerItems[i] == selectedPotion)
                        {
                            inventory.playerItems.RemoveAt(i);
                        }
                    }
                }

                //if potion is raising Str
                else if (selectedPotion.Str > 0 && selectedPotion.Mp < 0)
                {
                    inventory.player.str = selectedPotion.Str + inventory.player.str;
                    MessageBox.Show($"Your str has been raised by {selectedPotion.Str} for {selectedPotion.Rounds} rounds!");
                    PotionRoundscs pot = new PotionRoundscs();
                    pot.currentRound = currentRound;
                    pot.potion       = selectedPotion;
                    potionRounds?.Invoke(this, pot);
                    for (int i = 0; i < inventory.playerItems.Count; i++)
                    {
                        if (inventory.playerItems[i] == selectedPotion)
                        {
                            inventory.playerItems.RemoveAt(i);
                        }
                    }
                }

                //if potion is restoring health
                else if (selectedPotion.Health > 0)
                {
                    inventory.player.currenthp = inventory.player.currenthp + selectedPotion.Health;
                    if (inventory.player.currenthp > inventory.player.maxhp)
                    {
                        inventory.player.currenthp = inventory.player.maxhp;
                    }

                    MessageBox.Show($"You hp has been restore to {inventory.player.currenthp}!");
                    for (int i = 0; i < inventory.playerItems.Count; i++)
                    {
                        if (inventory.playerItems[i] == selectedPotion)
                        {
                            inventory.playerItems.RemoveAt(i);
                        }
                    }
                }
            }
            this.Close();
        }
コード例 #5
0
ファイル: Fight.cs プロジェクト: Briffon/Kingdom-of-Britainia
 //event hand method for potion round tracker
 public void potionRounds(object sender, PotionRoundscs e)
 {
     pBuff      = e.potion;
     pBuffRound = e.currentRound;
     pActive    = true;
 }