// This is the function for Human's turn static void HumanTurn() { // Check if health is <= 0? if (IsGameOver()) { Console.WriteLine($"{human.Name} Win!"); return; } Console.WriteLine($"{human.Name}'s Turn"); // Initialize the random number from 0 to 100 int rand = rng.Next(0, 101); // The casting chance of super skill is 20% and 80 % for basic skill. if (rand > 80) { human.CastSuperSkill(); Thread.Sleep(1500); orc.Hit(human.Damage * 2); Thread.Sleep(1500); } else { human.CastBasicSkill(); Thread.Sleep(1500); orc.Hit(human.Damage); Thread.Sleep(1500); } // Call OrcTurn() funtion OrcTurn(); }
static void Task02() { var observer = new Observer(); var Aragorn = new Human(observer); var Ugluk = new Orc(observer); var Galadriel = new Elf(observer); var allHeroes = new BaseCharacter[] { Aragorn, Ugluk, Galadriel }; Ugluk.TakeWeapon(new Scimitar()); while (Aragorn.IsAlive && Ugluk.IsAlive) { Aragorn.Hit(Ugluk); Ugluk.Hit(Aragorn); Galadriel.Heal(Aragorn); Galadriel.Hit(Ugluk); } Console.WriteLine(); foreach (BaseCharacter hero in allHeroes) { Console.WriteLine($"Is {hero.GetType().Name} alive?: {hero.IsAlive}"); } }
private void FixedUpdate() { animator.SetBool("isAttack", isAttack); animator.SetBool("isDead", isDeath); animator.SetBool("isDamage", isHit); if (Physics.Raycast(transform.position, transform.forward, out hit, 50)) { if (hit.collider.tag == "OrcDagger" || hit.collider.tag == "OrcSpear" || hit.collider.tag == "OrcKing" || hit.collider.tag == "WereWolf" || hit.collider.tag == "BlackWolf" || hit.collider.tag == "WhiteWolf" || hit.collider.tag == "MiniBot" || hit.collider.tag == "MegaBot") { Orc orc = hit.collider.GetComponent <Orc>(); if (orc.isAttack == true) // player action { if (isDeath == false) { isHit = true; animator.SetBool("isDamage", isHit); character.characterDefinition.TakeDamage(orc.CDamage); orc.isAttack = false; } if (isDeath) { cm.PanelToDisable[3].SetActive(false); } } if (isAttack == true) { // enemy action orc.TakeDamage(character.characterDefinition.currentDamage); orc.Hit(true); isAttack = false; } isHit = false; isAttack = false; } } }