Example #1
0
        public void randCharacter()
        {
            newHeroes = new List <newHero>();

            int xRoster = 700;
            int yRoster = 28;

            frame = Properties.Resources.rosterelement_res1;
            int temp = rand.Next(2, 3);

            for (int i = 0; i < temp; i++)
            {
                int priceRand = rand.Next(1000, 3000);
                newHeroes.Add(new newHero(xRoster, yRoster, priceRand));
                yRoster += 75;

                karakter karakter;
                int      type = rand.Next(8);
                switch (type)
                {
                case 0:
                    karakter = new ninja("Hatory");
                    break;

                case 1:
                    karakter = new aladin("Aladeen");
                    break;

                case 2:
                    karakter = new druid("Druid");
                    break;

                case 3:
                    karakter = new archer("Archer");
                    break;

                case 4:
                    karakter = new giantLady("Rukka");
                    break;

                case 5:
                    karakter = new Tony("Stark");
                    break;

                case 6:
                    karakter = new IceWoman("Frozen");
                    break;

                default:
                    karakter = new Hercules("Herher");
                    break;
                }
                newHeroes[i].karakter = karakter;
            }
        }
Example #2
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]);
            }
        }