Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //axWindowsMediaPlayer1.Hide();
            //sfx_player.Hide();
            Config.font.AddFontFile("Resources\\DwarvenAxe BB W00 Regular.ttf");

            manager = new GameStateManager();
            try
            {
                manager.player.myCharacter.Clear();
                XmlTextReader reader = new XmlTextReader("player.xml");
                reader.ReadStartElement("root");
                while (reader.IsStartElement("player"))
                {
                    reader.ReadStartElement("player");
                    gold         = Convert.ToInt32(reader.ReadElementString("gold"));
                    nama         = reader.ReadElementString("nama");
                    hero         = reader.ReadElementString("hero");
                    min_damage   = Convert.ToInt32(reader.ReadElementString("min_damage"));
                    max_damage   = Convert.ToInt32(reader.ReadElementString("max_damage"));
                    maxHp        = Convert.ToInt32(reader.ReadElementString("maxHp"));
                    hp           = Convert.ToInt32(reader.ReadElementString("hp"));
                    speed        = Convert.ToInt32(reader.ReadElementString("speed"));
                    level        = Convert.ToInt32(reader.ReadElementString("level"));
                    stress_level = reader.ReadElementString("hero_stress_level");

                    buff_list.Clear();
                    buff_turn_list.Clear();

                    if (stress_level == "normal")
                    {
                        status = stress_stage.normal;
                    }
                    else
                    {
                        status = stress_stage.depresi;
                    }

                    stress_point = Convert.ToInt32(reader.ReadElementString("hero_stress_point"));

                    equip1 = reader.ReadElementString("equip_1");
                    equip2 = reader.ReadElementString("equip_2");

                    arrEquip = new equip[2];
                    for (int i = 0; i < namaEquip.Length; i++)
                    {
                        if (equip1 == namaEquip[i].nama)
                        {
                            arrEquip[0] = namaEquip[i];
                        }

                        if (equip2 == namaEquip[i].nama)
                        {
                            arrEquip[1] = namaEquip[i];
                        }
                    }
                    if (hero == "ninja")
                    {
                        karakter hero = new ninja(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "archer")
                    {
                        karakter hero = new archer(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "aladin")
                    {
                        karakter hero = new aladin(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "tonyStark")
                    {
                        karakter hero = new Tony(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "druid")
                    {
                        karakter hero = new druid(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "iceWoman")
                    {
                        karakter hero = new IceWoman(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "hercules")
                    {
                        karakter hero = new Hercules(nama);
                        overRideHero(hero);
                    }
                    else if (hero == "giantLady")
                    {
                        karakter hero = new giantLady(nama);
                        overRideHero(hero);
                    }

                    reader.ReadEndElement();
                }
                manager.player.gold = gold;
                reader.ReadEndElement();
                reader.Close();

                XmlTextReader buffReader = new XmlTextReader("buff.xml");
                buffReader.ReadStartElement("root");
                while (buffReader.IsStartElement("buff"))
                {
                    buffReader.ReadStartElement("buff");
                    buff_temp = buffReader.ReadElementString("hero_buff");
                    for (int i = 0; i < arrTemp.Length; i++)
                    {
                        if (arrTemp[i].ToString() == buff_temp)
                        {
                            manager.player.myCharacter[manager.player.myCharacter.Count - 1].hero_buff = arrTemp[i];
                        }
                    }
                    string turn_temp = buffReader.ReadElementString("hero_buff_turn");
                    manager.player.myCharacter[manager.player.myCharacter.Count - 1].hero_buff_turn = Convert.ToInt32(turn_temp);

                    buffReader.ReadEndElement();
                }
                buffReader.ReadEndElement();
                buffReader.Close();
            }
            catch (Exception)
            {
                //MessageBox.Show("load error");
                manager.player.myCharacter.Add(new ninja("Hatory"));
                manager.player.myCharacter.Add(new aladin("aladin"));
                manager.player.currentCharacters.Add(manager.player.myCharacter[0]);
                manager.player.currentCharacters.Add(manager.player.myCharacter[1]);
            }
        }
Exemplo n.º 2
0
        public BattleState(GameStateManager gsm, dungeon dgn)
        {
            locSkill = new List <int>();
            locSkill.Add(310);
            locSkill.Add(365);
            locSkill.Add(420);
            locSkill.Add(476);

            player      = gsm.player.currentCharacters;
            thisDungeon = dgn;
            battleInv   = dgn.battleInv;
            player      = gsm.player.currentCharacters;
            Random r = new Random();

            this.gsm = gsm;
            gambar   = new List <int>();
            for (int i = 0; i < 5; i++)
            {
                gambar.Add(r.Next(5) + 1);
            }
            imgLast    = (Image)last;
            imgDoor    = (Image)door;
            x          = 0;
            imgpPlayer = (Image)Properties.Resources.ResourceManager.GetObject("panel_player2");
            imgpInv    = (Image)Properties.Resources.ResourceManager.GetObject("panel_inventory");
            //drawInventory();

            //random barang jatuh
            for (int i = 0; i < 3; i++)
            {
                int typeInv = rand.Next(10);
                if (typeInv == 0)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new LargeFood(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 1)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new LargeFood(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 2)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new SmallFood(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 3)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Torch(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 4)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Bandage(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 5)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Gold(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 6)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Jewel(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 7)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Key(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 8)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new Shovel(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
                else if (typeInv == 9)
                {
                    int jumlah = rand.Next(1, 8); inv_found[i] = new TheCure(walk_and_found[i], 334, jumlah); inv_found_rect[i] = new Rectangle(walk_and_found[i], 334, 50, 50);
                }
            }

            inv = gsm.player.inventoryAktif;

            dmg_min = player[pilihHero].skills[pilih_attack].status_skill.dmg_min + "";
            dmg_max = player[pilihHero].skills[pilih_attack].status_skill.dmg_max + "";
            acc     = player[pilihHero].skills[pilih_attack].status_skill.acc + "";
            crit    = player[pilihHero].skills[pilih_attack].status_skill.crit + "%";
            prot    = player[pilihHero].skills[pilih_attack].status_skill.def + "";
        }
Exemplo n.º 3
0
        public battle(GameStateManager gsm, Image back, dungeon dgn)
        {
            thisDungeon = dgn;



            this.gsm  = gsm;
            battleInv = thisDungeon.battleInv;
            player    = new List <karakter>();;
            for (int i = 0; i < 4; i++)
            {
                try
                {
                    player.Add(gsm.player.currentCharacters[i]);
                }
                catch (Exception)
                {
                }
            }
            Random rand = new Random();

            musuh = new List <musuh>();
            int a = rand.Next(1, 3);

            for (int i = 0; i < a; i++)
            {
                int b = rand.Next(1, 8);
                if (b == 1)
                {
                    musuh.Add(new yeti(700 + i * 100));
                }
                else if (b == 2)
                {
                    musuh.Add(new Gargoyle(700 + i * 100));
                }
                else if (b == 3)
                {
                    musuh.Add(new Gargoyle(700 + i * 100));
                }
                else if (b == 4)
                {
                    musuh.Add(new Boarman(700 + i * 100));
                }
                else if (b == 5)
                {
                    musuh.Add(new Larry(700 + i * 100));
                }
                else if (b == 6)
                {
                    musuh.Add(new FlameEater(700 + i * 100));
                }
                else
                {
                    musuh.Add(new GiantGoblin(700 + i * 100));
                }
                turnAttack.Add(new turn(0, i, musuh[i].speed));
            }


            locSkill = new List <int>();
            locSkill.Add(310);
            locSkill.Add(365);
            locSkill.Add(420);
            locSkill.Add(476);

            for (int i = 0; i < player.Count; i++)
            {
                player[i].x = 350 - 100 * i;
                turnAttack.Add(new turn(1, i, player[i].speed));
            }

            for (int i = 0; i < turnAttack.Count - 1; i++)
            {
                for (int j = i; j < turnAttack.Count - i - 1; j++)
                {
                    if (turnAttack[i].speed < turnAttack[j].speed)
                    {
                        turn temp = turnAttack[i];
                        turnAttack[i] = turnAttack[j];
                        turnAttack[j] = temp;
                    }
                }
            }
            background = back;
            imgpPlayer = (Image)Properties.Resources.ResourceManager.GetObject("panel_player2");
            imgpInv    = (Image)Properties.Resources.ResourceManager.GetObject("panel_inventory");

            if (turnAttack[0].jenis == 1)
            {
                pilihHero = turnAttack[0].ke;
            }
            else
            {
                pilihMusuh  = turnAttack[0].ke;
                delay_aktif = true;
            }


            dmg_min = player[pilihHero].skills[pilih_attack].status_skill.dmg_min + "";
            dmg_max = player[pilihHero].skills[pilih_attack].status_skill.dmg_max + "";
            acc     = player[pilihHero].skills[pilih_attack].status_skill.acc + "";
            crit    = player[pilihHero].skills[pilih_attack].status_skill.crit + "%";
            prot    = player[pilihHero].skills[pilih_attack].status_skill.def + "";
        }