void FixedUpdate() { RaycastHit raycastHit; Physics.Raycast(transform.position, -Vector3.forward, out raycastHit, 500.0f); Debug.DrawRay(transform.position, -Vector3.forward, Color.red); if (raycastHit.collider) { // Debug.Log("FlashlightHits Collider"); Zombie zombie = raycastHit.collider.gameObject.GetComponent <Zombie>(); Debug.Log("Zombie; " + zombie); if (zombie) { Debug.Log("FlashlightHits Zombie"); zombie.playerPosition = playersHead; zombie.playerHealth = playerHealth; zombie.Attack(); } if (raycastHit.collider.gameObject.name == "FreeZombie") { Debug.Log("FlashlightHits Object with name zombie"); } } }
public override ZombieStateEnum Update(Zombie zombie) { //目标死亡进入Idle状态 if (zombie.target.GetComponent <Hero>().IsDead) { return(ZombieStateEnum.Patrol); } //如果目标超出攻击范围则切换成追逐状态 float x = zombie.target.position.x - zombie.transform.position.x; float y = zombie.target.position.y - zombie.transform.position.y; if (Mathf.Abs(x) > zombie.attackRange.x || Mathf.Abs(y) > zombie.attackRange.y) { return(ZombieStateEnum.Seek); } if (_time <= 0.0f) { zombie.Attack(); _time = zombie.attackCD; } else { _time -= Time.deltaTime; } return(ZombieStateEnum.None); }
void Update() { if (freeZombie != null && (handWithInventory.Inputs[NVRButtons.ApplicationMenu].PressDown || Vector3.Distance(freeZombie.transform.position, handWithInventory.transform.position) < attackDistance)) { freeZombie.Attack(); } if (freeZombie != null && Vector3.Distance(freeZombie.transform.position, handWithInventory.transform.position) < attackDistance) { freeZombie.Attack(); } if (freeZombie != null && freeZombie.transform.position == zombieWalkTo1.position) { //Debug.Log("Zombie reached position 1"); walkingToPosition2 = true; walkingToPosition1 = false; } else if (freeZombie != null && freeZombie.transform.position == zombieWalkTo2.position) { //Debug.Log("Zombie reached position 2"); walkingToPosition1 = true; walkingToPosition2 = false; } if (freeZombie != null && !walkingToPosition1Called && walkingToPosition1) { freeZombie.WalkTo(zombieWalkTo1); walkingToPosition1 = true; //Debug.Log("Zombie walking to pos 1"); walkingToPosition1Called = true; walkingToPosition2Called = false; } if (freeZombie != null && !walkingToPosition2Called && walkingToPosition2) { freeZombie.WalkTo(zombieWalkTo2); walkingToPosition2 = true; //Debug.Log("Zombie walking to pos 2"); walkingToPosition1Called = false; walkingToPosition2Called = true; } if (freeZombie == null) { Destroy(gameObject); } }
private void ReleaseZombie() { Debug.Log("Zombie Released"); releaseSound.Play(); isReleased = true; Destroy(CapsuleGlas); GameObject releasedZombie = Instantiate(attackingZombiePrefab, releasedZombiePosition.position, releasedZombiePosition.rotation); Zombie zombie = releasedZombie.GetComponent <Zombie>(); Debug.Log(" releasedZombie.GetComponent<Zombie>() " + zombie); zombie.playerPosition = player.transform; zombie.playerHealth = playerHealth; zombie.Attack(); Destroy(floatingZombie); }
// Use this for initialization void Start() { Zombie zombie = new Zombie(); Player player = new Player(); player.TakeDamage(zombie.Attack()); player.TakeDamage(zombie.AcidPuke()); player.Die(); Zombie[] zombies = new Zombie[100]; for (int x = 0; x < zombies.Length; x++) { zombies[x] = new Zombie(); Debug.Log("Creating Zombie#" + x); } }
// Start is called before the first frame update void Start() { Zombie zombie = new Zombie(); Player player = new Player(); player.TakeDamage(zombie.Attack()); player.TakeDamage(zombie.AcidPukeAttack()); player.Die(); Zombie[] zombies = new Zombie[100]; for (int i = 0; i < zombies.Length; i++) { zombies[i] = new Zombie(); Debug.Log("Creating Zombie #:" + i); } }
private void SpawnZombies() { Debug.Log("Instantiating zombies"); zombie1 = Instantiate(Zombiepefab, zombie1Pos.position, zombie1Pos.rotation).GetComponent <Zombie>(); zombie2 = Instantiate(Zombiepefab, zombie2Pos.position, zombie2Pos.rotation).GetComponent <Zombie>(); zombie3 = Instantiate(Zombiepefab, zombie3Pos.position, zombie3Pos.rotation).GetComponent <Zombie>(); zombie4 = Instantiate(Zombiepefab, zombie4Pos.position, zombie4Pos.rotation).GetComponent <Zombie>(); zombie1.playerHealth = playerhealth; zombie1.playerPosition = playerPosition.gameObject.transform; zombie1.Attack(); zombie2.playerHealth = playerhealth; zombie2.playerPosition = playerPosition.gameObject.transform; zombie2.Attack(); zombie3.playerHealth = playerhealth; zombie3.playerPosition = playerPosition.gameObject.transform; zombie3.Attack(); zombie4.playerHealth = playerhealth; zombie4.playerPosition = playerPosition.gameObject.transform; zombie4.Attack(); }
static void Main(string[] args) { RayGun green = new RayGun("green ray gun", 2); RayGun red = new RayGun("red ray gun", 4); SpaceArmor titanium = new SpaceArmor("titanium space armor", 50); SpaceArmor alien = new SpaceArmor("alien tech space armor", 100); GravBoots nike = new GravBoots("Nike grav boots", 2); GravBoots adidas = new GravBoots("Adidas grav boots", 4); AlienText romulan = new AlienText("book of Romulan wisdom", 2); AlienText vulcan = new AlienText("book of Vulcan wisdom", 4); IEquipable[] treasure = new IEquipable[8] { green, red, titanium, alien, nike, adidas, romulan, vulcan }; ConsoleYellow("********NINJAS IN SPACE********"); Hero player = PlayerSetup(); ConsoleYellow($"You, {player.Name}, have been chosen(randomly selected) to join a team of developer ninjas on a space quest! To seek out new algorithms, new data structures, and go where no else wants to go! DEEP SPACE!!!\n\nHere you will encounter aliens, space monsters, and the unknown to bring back algorithms to benefit all humans. You now must choose your team.\n\nPress Enter to Start"); ConsoleKey key = Console.ReadKey(true).Key; while (key != ConsoleKey.Enter) { key = Console.ReadKey(true).Key; } Console.WriteLine("Please select two crew members"); Hero teammate1 = TeamSetup(); Hero teammate2 = TeamSetup(); List <Hero> party = new List <Hero>() { player, teammate1, teammate2 }; int planet = 0; while (planet < 5) { Console.WriteLine(""); ConsoleYellow($"Welcome to Planet {planet+1}!"); ConsoleYellow("====================="); List <Enemy> enemies = new List <Enemy>(); Spider enemy1 = new Spider("Space Spider 1"); Zombie enemy2 = new Zombie("Space Zombie 1"); Xenomorph enemy3 = new Xenomorph("Xenomorph 1"); enemies.Add(enemy1); enemies.Add(enemy2); enemies.Add(enemy3); Random die = new Random(); int round = 0; while (SumHealthParty(party) > 0 && SumHealthEnemies(enemies) > 0) { int turn = round % 6; if (turn >= 0 && turn < 3) { if (party[turn].Health > 0) { Console.WriteLine(""); EncounterStatus(party, enemies); if (party[turn] is Ninja) { Ninja ninjaClone = (Ninja)party[turn]; Console.WriteLine($"{ninjaClone.Name}'s turn. (A)ttack or (B)ackstab?"); string Action = Console.ReadLine(); Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}"); string Target = Console.ReadLine(); if (Action == "A") { ninjaClone.Attack(enemies[int.Parse(Target) - 1]); } else if (Action == "B") { ninjaClone.Backstab(enemies[int.Parse(Target) - 1]); } else if (Action == "Z") { enemies[int.Parse(Target) - 1].Health = 0; Console.WriteLine("Let's get this over with"); Console.WriteLine(""); } } else if (party[turn] is Samurai) { Samurai samuraiClone = (Samurai)party[turn]; Console.WriteLine($"{samuraiClone.Name}'s turn. (A)ttack or (M)editate?"); string Action = Console.ReadLine(); if (Action == "A") { Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}"); string Target = Console.ReadLine(); samuraiClone.Attack(enemies[int.Parse(Target) - 1]); } else if (Action == "M") { samuraiClone.Meditate(); } else if (Action == "Z") { Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}"); string Target = Console.ReadLine(); enemies[int.Parse(Target) - 1].Health = 0; Console.WriteLine("Let's get this over with"); Console.WriteLine(""); } } else if (party[turn] is Wizard) { Wizard wizardClone = (Wizard)party[turn]; Console.WriteLine($"{wizardClone.Name}'s turn. (A)ttack or (S)hield?"); string Action = Console.ReadLine(); if (Action == "A") { Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}"); string Target = Console.ReadLine(); wizardClone.Attack(enemies[int.Parse(Target) - 1]); } else if (Action == "S") { Console.WriteLine($"Target? (1){party[0].Name} (2){party[1].Name} (3){party[2].Name}"); string Target = Console.ReadLine(); wizardClone.Shield(party[int.Parse(Target) - 1]); } else if (Action == "Z") { Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}"); string Target = Console.ReadLine(); enemies[int.Parse(Target) - 1].Health = 0; Console.WriteLine("Let's get this over with"); Console.WriteLine(""); } } } } else { if (enemies[turn - 3].Health > 0) { Console.WriteLine(""); EncounterStatus(party, enemies); if (enemies[turn - 3] is Zombie) { Zombie zombieClone = (Zombie)enemies[turn - 3]; Console.WriteLine($"{zombieClone.Name}'s turn."); Random rand = new Random(); bool attacked = false; while (!attacked) { int target = rand.Next(3); if (party[target].Health > 0) { zombieClone.Attack(party[target]); attacked = true; } } Console.WriteLine("Please press \"Enter\" to continue"); string Action = Console.ReadLine(); } else if (enemies[turn - 3] is Spider) { Spider spiderClone = (Spider)enemies[turn - 3]; Console.WriteLine($"{spiderClone.Name}'s turn."); Random rand = new Random(); bool attacked = false; while (!attacked) { int target = rand.Next(3); if (party[target].Health > 0) { spiderClone.Attack(party[target]); attacked = true; } } Console.WriteLine("Please press \"Enter\" to continue"); string Action = Console.ReadLine(); } else if (enemies[turn - 3] is Xenomorph) { Xenomorph xenoClone = (Xenomorph)enemies[turn - 3]; Console.WriteLine($"{xenoClone.Name}'s turn."); Random rand = new Random(); bool attacked = false; while (!attacked) { int target = rand.Next(3); if (party[target].Health > 0) { xenoClone.Attack(party[target]); attacked = true; } } Console.WriteLine("Please press \"Enter\" to continue"); string Action = Console.ReadLine(); } } } if (SumHealthEnemies(enemies) <= 0) { Console.WriteLine("All enemies vanquished! Congratulations!"); int d8 = die.Next(8); IEquipable foundTreasure = treasure[d8]; Equipment equipClone = (Equipment)foundTreasure; Console.WriteLine($"You found {equipClone.Name}! {equipClone.Desc} Who should equip it?"); string choice = "0"; while (choice != "1" && choice != "2" && choice != "3") { Console.WriteLine($"Please type the number of the hero you would like to equip:\n1. {party[0].Name}\n2. {party[1].Name}\n3. {party[2].Name}"); choice = Console.ReadLine(); } switch (choice) { case ("1"): foundTreasure.Equip(party[0]); Console.WriteLine($"{party[0].Name} has equipped the {equipClone.Name}"); party[0].ShowStats(); Console.WriteLine(""); break; case ("2"): foundTreasure.Equip(party[1]); Console.WriteLine($"{party[1].Name} has equipped the {equipClone.Name}"); party[1].ShowStats(); Console.WriteLine(""); break; case ("3"): foundTreasure.Equip(party[2]); Console.WriteLine($"{party[2].Name} has equipped the {equipClone.Name}"); party[2].ShowStats(); Console.WriteLine(""); break; } Console.WriteLine("Onward to the next planet! Good thing you brought clones of everyone!"); player.Health = player.MaxHealth; teammate1.Health = teammate1.MaxHealth; teammate2.Health = teammate2.MaxHealth; Console.WriteLine(""); planet++; if (planet == 5) { ConsoleYellow("You've certainly accomplished something! Saved the universe? Sure! Congratulations!"); } } if (SumHealthParty(party) <= 0) { ConsoleYellow("Your party was killed in self-defense! Game over!"); planet = 5; } round++; } } }
public void CheckZombieAttackBitten() { var monster = new Zombie(); Assert.AreEqual("You have been bitten!", monster.Attack()); }