static void Main() { Warrior firstWarrior = new Warrior(150, 50, "Name", Faction.BadGuy); //firstWarrior.Addition(4, 6); //firstWarrior.Move(100); Mage firstMega = new Mage(); Character secondWarrior = new Warrior(); Warrior tempWarrior = (Warrior)secondWarrior; secondWarrior.Move(5); List <Character> theCharacters = new List <Character>(); theCharacters.Add(firstWarrior); theCharacters.Add(firstMega); Console.WriteLine(firstWarrior.HealthPoints); Console.WriteLine(firstMega.Mana); firstMega.CastSpell(firstWarrior); Console.WriteLine(firstWarrior.HealthPoints); Console.WriteLine(firstMega.Mana); //firstMega.Move(10000); //public type can be accessed in same assembly firstMega.Addition(1, 2); Console.WriteLine(firstWarrior.Age); try { //firstWarrior.Age = 15; firstMega.Age = 25; } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } //Warrior secondWarrior = new Warrior(150, 50); //Warrior thirdWarrior = new Warrior(140, 78, "I am the third warrior!"); //Warrior thirdWarrior = new Warrior(140, 78); //Warrior fouthWarrior = new Warrior(150, 40, "Name", Faction.GoodGuy); //Mage firstMage = new Mage(); //Console.WriteLine(fouthWarrior.Name); //Console.WriteLine(fouthWarrior.HealthPoints); //Tools.ColorfulWriteLine(firstWarrior.ID.ToString(), ConsoleColor.DarkBlue); //Tools.ColorfulWriteLine(secondWarrior.ID.ToString(), ConsoleColor.Red); //Tools.ColorfulWriteLine(thirdWarrior.ID.ToString(), ConsoleColor.Green); Console.Read(); //Console.WriteLine(firstWarrior.Name); //Console.WriteLine(thirdWarrior.Name); }
private IEnumerator CastFireBallAfter(float time) { mage.elementalHandler.ClearSlots(); yield return(new WaitForSeconds(time)); Spell spell = SpellBook.Instance.GetRandomSpell(); foreach (var item in spell.GetCombo()) { mage.elementalHandler.AddElement(item); yield return(new WaitForSeconds(.2f)); } yield return(new WaitForSeconds(.2f)); mage.CastSpell(); StartCoroutine(CastFireBallAfter(.5f)); }
static void Main() { Warrior firstWarrior = new Warrior(78, 180, "Amy", Faction.GoodGuy); Mage firstMage = new Mage(); Console.WriteLine(firstWarrior.AddNumber(7, 5)); Console.WriteLine(firstWarrior.HealthPoints); Console.WriteLine(firstMage.Mana); firstMage.CastSpell(firstWarrior); Character secondWarrior = new Warrior(); List <Character> theCharacters = new List <Character>(); List <ICalculator> calculators = new List <ICalculator>(); calculators.Add(firstWarrior); calculators.Add(firstMage); theCharacters.Add(firstWarrior); theCharacters.Add(firstMage); foreach (var character in theCharacters) { if (character is Warrior) { Warrior tempWarrior = character as Warrior; Console.WriteLine(tempWarrior.SwordWeapon.Damage); } } Console.WriteLine("After spell cast:" + firstWarrior.HealthPoints); Console.WriteLine("After spell cast:" + firstMage.Mana); PerformGreeting(theCharacters); Character[] theCharactersAgain = new Character[2]; theCharactersAgain[0] = firstMage; theCharactersAgain[1] = firstWarrior; PerformGreeting(theCharactersAgain); }
static void Main() { Warrior theGoodGuy = new Warrior(190, 80, "Good Guy Name", Faction.GoodGuy); //theGoodGuy.Age = 25; //theGoodGuy.Height = 190; //theGoodGuy.Weight = 80; //theGoodGuy.Name = "Good Guy"; Warrior theBadGuy = new Warrior(170, 70, "Bad Guy Name", Faction.BadGuy); //theBadGuy.Age = 15; //theBadGuy.Height = 170; //theBadGuy.Weight = 70; //theBadGuy.Name = "Bad Guy"; Warrior youngWarrior = new Warrior(100, 50); youngWarrior.Age = 18; Console.WriteLine($@"blOOp {youngWarrior.Age}"); try { theGoodGuy.Age = 25; theBadGuy.Age = 15; } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } theGoodGuy.Greetings(theBadGuy); theBadGuy.Greetings(theGoodGuy); Console.WriteLine($@"The warrior {theGoodGuy.Name} is {theGoodGuy.Age}"); Console.WriteLine($@"The warrior {theBadGuy.Name} is {theBadGuy.Age}"); Console.WriteLine(theBadGuy.Height); Console.WriteLine($@"The damage from the sword of the warrior {theGoodGuy.Name} is {theGoodGuy.SwordWeapon.Damage}!"); Console.WriteLine(theGoodGuy.SwordWeapon.Damage); Warrior firstWarrior = new Warrior(); Console.WriteLine(Warrior.idCounter); Warrior secondWarrior = new Warrior(150, 50); Console.WriteLine(Warrior.idCounter); Warrior thirdWarrior = new Warrior(140, 78, "I am the third warrior", Faction.GoodGuy); Warrior fourthWarrior = new Warrior(100, 100, "fourth warrior", Faction.BadGuy); Console.WriteLine(Warrior.idCounter); Console.WriteLine($"FourthWarrior health points: {fourthWarrior.HealthPoints}"); Console.WriteLine(secondWarrior.ID); Warrior.GetDefaultValues(firstWarrior); Tools.ColorfulWriteLine(firstWarrior.ID.ToString(), ConsoleColor.Cyan); Tools.ColorfulWriteLine(secondWarrior.ID.ToString(), ConsoleColor.Red); Tools.ColorfulWriteLine(thirdWarrior.ID.ToString(), ConsoleColor.DarkYellow); firstWarrior.Move(500); Mage firstMage = new Mage(); firstMage.Move(200); try { firstMage.Age = 25; } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } firstWarrior.Addition(12, 12); firstMage.Addition(200, 200); Console.WriteLine($"first warrior health points before attack{firstWarrior.HealthPoints}"); Console.WriteLine($"first mage Mana points before attack{firstMage.Mana}"); firstMage.CastSpell(firstWarrior); Console.WriteLine($"first warrior health points after attack{firstWarrior.HealthPoints}"); Console.WriteLine($"first mage Mana points after attack{firstMage.Mana}"); //Polymorphism //Character seventhWarrior = new Warrior(); //Warrior tempWarrior = (Warrior)seventhWarrior; List <Character> theCharacters = new List <Character>(); //Warrior tempWarrior = (Warrior)theCharacters[0]; // way #1... Foreach loop to get specific details of a type of character from a list //foreach (var character in theCharacters) //{ // if (character.GetType().Name == "Warrior") // { // Warrior tempWarrior = (Warrior)character; // Console.WriteLine(tempWarrior.SwordWeapon.Damage); // } //} // way #2...ForEach loop to get specific details of a type of character from a list foreach (var character in theCharacters) { if (character is Warrior) { Warrior tempWarrior = character as Warrior; Console.WriteLine(tempWarrior.SwordWeapon.Damage); } } List <ICalculator> calculators = new List <ICalculator>(); theCharacters.Add(firstWarrior); theCharacters.Add(firstMage); PerformGreeting(theCharacters); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private IEnumerator CastSpellAfterIdleFor(float time) { yield return(new WaitForSeconds(time)); mage.CastSpell(); }
// вначале хотел сделать юзер-френдли интерфейс.... /* private static void SetHero(Character hero) { string heroName; string heroRace; string heroGender; Console.Write("Введите имя вашего персонажа >>"); heroName = Console.ReadLine(); while (hero == null) { Console.WriteLine("Введите расу вашего персонажа >>"); heroRace = Console.ReadLine(); Console.WriteLine("Введите пол вашего персонажа >>"); heroGender = Console.ReadLine(); Console.WriteLine("Является ли ваш персонаж магом (y/n)"); char mage = Console.ReadKey().KeyChar; try { if (mage == 'n') { hero = new Character(heroName, heroRace, heroGender); } if (mage == 'y') { hero = new Mage(heroName, heroRace, heroGender); } } catch (ArgumentException aExeption) { Console.WriteLine("Уууупс!"); Console.WriteLine(aExeption.Message); } } } private static void ShowOptionsList() { Console.WriteLine("1 - изменить возраст персонажа"); Console.WriteLine("2 - идти сражатся!"); Console.WriteLine("3 - отправится за артефактами"); Console.WriteLine("4 - работать с ") }*/ static void Main(string[] args) { Character hero = null; Character badGuy = null; Mage mage = null; //создание персонажей // // //Нормально ли, что при выборе несуществующей расы создаётся персонаж с расой Human hero = new Character("Player", "numan", "Female"); mage = new Mage("Gendalf", Race.Human, Gender.Male); badGuy = new Character("Ыыынгыз", Race.Goblin, Gender.Male); badGuy.Age = 50; mage.Age = 100; badGuy.Age = 50; mage.Age = 100; Console.WriteLine("Текущее значение маны мага = " + mage.CurrentMana); //Заклинания mage.LearnSpell(new UnRoot()); mage.ForgotSpell(new UnRoot()); mage.CastSpell(new UnRoot()); mage.CurrentHP = 30; mage.LearnSpell(new IncreaseHP()); mage.CastSpell(new IncreaseHP(),30); Console.WriteLine("Текущее значение маны мага = " + mage.CurrentMana); Console.WriteLine("Текущее значение хп мага = " + mage.CurrentHP); Console.WriteLine(); Character experimentalMen = new Character("Его надо возродить", Race.Elf, Gender.Male); experimentalMen.CurrentHP = 0; Console.WriteLine("Текущее значение хп эльфа = " + experimentalMen.CurrentHP); Console.WriteLine("Текущее состояние эльфа = " + experimentalMen.Condition.ToString()); mage.LearnSpell(new Revive()); mage.CastSpell(new Revive(),1, experimentalMen); //эх не получилось Console.WriteLine("Текущее значение хп эльфа = " + experimentalMen.CurrentHP); Console.WriteLine("Текущее состояние эльфа = " + experimentalMen.Condition.ToString()); //aртефакты Console.WriteLine(); hero.UseArtefact(new EyeOfVasilisk(10), badGuy); DeadWater findArtefactDW = new DeadWater(BottleType.Малая); hero.Inventory.AddItem(findArtefactDW); hero.UseArtefact(findArtefactDW,mage); LightningStaff findArtefactLS = new LightningStaff(125); //попытка самоустранится hero.Inventory.AddItem(findArtefactLS); hero.UseArtefact(findArtefactLS,hero,40); // почти удалось! Console.WriteLine("Текущее значение хп игрока = " + hero.CurrentHP); Console.WriteLine("Текущее состояние игрока = " + hero.Condition.ToString()+"\n"); hero.UseArtefact(findArtefactLS,badGuy,45); Console.WriteLine("Текущее значение хп гоблина-вражины = " + badGuy.CurrentHP); Console.WriteLine("Текущее состояние гоблина-вражины = " + badGuy.Condition.ToString() + "\n"); PoisonousSaliva saliva = new PoisonousSaliva(52); badGuy.Inventory.AddItem(saliva); badGuy.UseArtefact(saliva, hero, 26); Console.WriteLine("Текущее значение хп игрока = " + hero.CurrentHP); Console.WriteLine("Текущее состояние игрока = " + hero.Condition.ToString() + "\n"); FrogDecoction healPoison = new FrogDecoction(); mage.Inventory.AddItem(healPoison); mage.UseArtefact(healPoison, hero, 25); Console.WriteLine("Текущее значение хп игрока = " + hero.CurrentHP); Console.WriteLine("Текущее состояние игрока = " + hero.Condition.ToString() + "\n"); //попытка использовать не реюзабельный артефакт mage.UseArtefact(healPoison, hero, 25); HolyWater holyWater = new HolyWater(BottleType.Большая); hero.Inventory.AddItem(holyWater); hero.UseArtefact(holyWater); Console.WriteLine("Текущее значение хп игрока = " + hero.CurrentHP); Console.WriteLine("Текущее состояние игрока = " + hero.Condition.ToString() + "\n"); //передаём посох магу hero.Inventory.GiveItem(mage, "Посох молнии"); // и сразу в бой mage.UseArtefact(findArtefactLS,badGuy,20); Console.WriteLine("Текущее значение хп гоблина-вражины = " + badGuy.CurrentHP); Console.WriteLine("Текущее состояние гоблина-вражины = " + badGuy.Condition.ToString() + "\n"); //сравнение игроков Console.WriteLine(mage.CompareTo(hero)); Console.WriteLine(hero.CompareTo(badGuy)); //если добавить опыта, то всё изменится mage.Exp = 100; Console.WriteLine(mage.CompareTo(hero)+ "\n"); //Работа брони mage.LearnSpell(new Armor()); //cначала подбавим маны mage.CurrentMana = 100; Console.WriteLine("Текущее значение хп мага = " + mage.CurrentHP); mage.CastSpell(new Armor()); //попробуем задомажить теперь мага mage.CurrentHP = 15; Console.WriteLine("Текущее состояние мага = " + mage.Condition.ToString()); Console.WriteLine("Текущее значение хп мага = " + mage.CurrentHP); }