public FormMain() { InitializeComponent(); for (int i = 1; i <= 3; i++) { OrcishWarrior orcishWarrior = new OrcishWarrior(); } for (int i = 1; i <= 3; i++) { OrcishCrossbowman newCrossbowman = new OrcishCrossbowman(); } // wlaczenie muzyki w tle soundPlayer.PlayLooping(); }
/// <summary> /// Funkcja wczytująca wcześniej zapisany stan /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonLoad_Click(object sender, EventArgs e) { // próba otworzenia pliku try { xDoc.Load(path); } catch { MessageBox.Show("Otworzenie pliku z zapisami nie powiodło sie", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Error); } // szukanie zapisu o podanej nazwie foreach (XmlNode node in xDoc.SelectNodes("saves/save")) { // jezeli znalazlo podaną nazwę zapisu w bazie xml to wczytuje z niej zawarte dane if (node.SelectSingleNode("saveName").InnerText == textBoxSaveName.Text) { // wczytanie zasobów Resources.ResourcesFood = Int32.Parse(node.SelectSingleNode("resources/food").InnerXml); Resources.ResourcesWood = Int32.Parse(node.SelectSingleNode("resources/wood").InnerXml); Resources.ResoucresStone = Int32.Parse(node.SelectSingleNode("resources/stone").InnerXml); Resources.ResoucresIron = Int32.Parse(node.SelectSingleNode("resources/iron").InnerXml); Resources.ResoucresCrystals = Int32.Parse(node.SelectSingleNode("resources/crystals").InnerXml); Resources.Population = Int32.Parse(node.SelectSingleNode("resources/population").InnerXml); // wczytanie poziomow budynkow ElvishBuildings.LevelOfHuntingBuilding = Int32.Parse(node.SelectSingleNode("elvishBuildings/huntingBuild").InnerXml); ElvishBuildings.LevelOfWoodshet = Int32.Parse(node.SelectSingleNode("elvishBuildings/woodshet").InnerXml); ElvishBuildings.LevelOfQuarry = Int32.Parse(node.SelectSingleNode("elvishBuildings/quarry").InnerXml); ElvishBuildings.LevelOfIronWorks = Int32.Parse(node.SelectSingleNode("elvishBuildings/ironWorks").InnerXml); ElvishBuildings.LevelOfCrystalMine = Int32.Parse(node.SelectSingleNode("elvishBuildings/crystalMine").InnerXml); ElvishBuildings.LevelOfHouses = Int32.Parse(node.SelectSingleNode("elvishBuildings/houses").InnerXml); ElvishBuildings.LevelOfTemple = Int32.Parse(node.SelectSingleNode("elvishBuildings/temple").InnerXml); ElvishBuildings.LevelOfElvishBuilding = Int32.Parse(node.SelectSingleNode("elvishBuildings/elvishBuilding").InnerXml); ElvishBuildings.LevelOfMartialArtsSchool = Int32.Parse(node.SelectSingleNode("elvishBuildings/martialArtsSchool").InnerXml); ElvishBuildings.LevelOfInfrastructure = Int32.Parse(node.SelectSingleNode("elvishBuildings/infrastructure").InnerXml); // stworzenie takiej samej liczby jednostek elfow for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("elvishUnits/elvishArcher").InnerXml); i++) { ElvishArcher loadArcher = new ElvishArcher(); } for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("elvishUnits/elvishWarrior").InnerXml); i++) { ElvishWarrior loadWarrior = new ElvishWarrior(); } for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("elvishUnits/elvishMaster").InnerXml); i++) { ElvishMaster loadMaster = new ElvishMaster(); } // stworzenie takiej samej liczby jednostek orków for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("orcishUnits/orcishCrossbowman").InnerXml); i++) { OrcishCrossbowman loadOrcishCrossbowman = new OrcishCrossbowman(); } for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("orcishUnits/orcishWarrior").InnerXml); i++) { OrcishWarrior loadWarrior = new OrcishWarrior(); } for (int i = 1; i <= Int32.Parse(node.SelectSingleNode("orcishUnits/orcishCommander").InnerXml); i++) { OrcishCommander loadCommander = new OrcishCommander(); } // wczytanie licznika potyczek OrcsAttack.battleCounter = Int32.Parse(node.SelectSingleNode("battleCounter").InnerXml); // zamkniecie okienka this.Close(); // wyswietlenie wiadomosci MessageBox.Show("Wczytano!", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Funkcja zwieksza ilosc orkow bioracych udzial w nastepnym ataku /// </summary> public static void NextWave() { // obiekt ranomNumber klasy Random bedzie losowal liczby w celu prowadzenia roznych losow potyczek Random randomNumber = new Random(); // inkrementacja licznika potyczek battleCounter++; if (battleCounter == 1) { // zwiekszenie liczby przeciwnikow OrcishWarrior newWarrior = new OrcishWarrior(); OrcishCrossbowman newCrossbowman = new OrcishCrossbowman(); } // jezeli licznik bitew wskazuje 3 if (battleCounter == 2) { // dodanie do grupy orkow silnego dowodcy OrcishCommander newCommander = new OrcishCommander(); } // jezeli licznik bitew jest rowny lub wiekszy od 4 to orkowie beda atakowac coraz to wieksza grupa if (battleCounter >= 3 && battleCounter < 10) { for (int i = 1; i <= randomNumber.Next(3, 7); i++) { OrcishWarrior orcishWarrior = new OrcishWarrior(); } for (int i = 1; i <= randomNumber.Next(3, 7); i++) { OrcishCrossbowman newCrossbowman = new OrcishCrossbowman(); } for (int i = 1; i <= randomNumber.Next(1, 3); i++) { OrcishCommander newCommander = new OrcishCommander(); } } if (battleCounter >= 10) { for (int i = 1; i <= randomNumber.Next(7, 14); i++) { OrcishWarrior orcishWarrior = new OrcishWarrior(); } for (int i = 1; i <= randomNumber.Next(7, 14); i++) { OrcishCrossbowman newCrossbowman = new OrcishCrossbowman(); } for (int i = 1; i <= randomNumber.Next(3, 6); i++) { OrcishCommander newCommander = new OrcishCommander(); } } if (battleCounter >= 16) { for (int i = 1; i <= randomNumber.Next(12, 20); i++) { OrcishWarrior orcishWarrior = new OrcishWarrior(); } for (int i = 1; i <= randomNumber.Next(12, 20); i++) { OrcishCrossbowman newCrossbowman = new OrcishCrossbowman(); } for (int i = 1; i <= randomNumber.Next(4, 7); i++) { OrcishCommander newCommander = new OrcishCommander(); } } }