public ActionHandler(Entity owner) { Entity = owner; zom = Entity.gameObject.GetComponent<ZombieAI>(); addAction(new Walk(this)); }
void Awake() { anim = GetComponent <Animator> (); zombieai = GetComponent<ZombieAI> (); rigid = GetComponent<Rigidbody> (); cap = GetComponent<CapsuleCollider> (); }
public SenseHandler(Entity entity, bool deaf = false, bool blind = false) { Entity = entity; isDeaf = deaf; isBlind = blind; zom = Entity.GetComponent<ZombieAI>(); initialise(); }
ZombieAI EnemyScript; // stores enemy ai script void Awake() { scoretext = GetComponent <Text>(); // gets text component of score bar and stores it xBarText = xBar.GetComponent <Text>(); // gets text component of multiplier bar and stores it EnemyScript = enemy.GetComponent <ZombieAI>(); // used to access variables in ZombieAI script HealthScript = player.GetComponent <PlayerHealth>(); // used to access variables in PlayerHealth script kills = 0; // kils is set to 0 scoreToAdd = 0; // score to add is set to 0 current_score = 0; // score is to 0 }
public void gotShot() { fwd = transform.TransformDirection(Vector3.forward * 10); Ray DetectionRay = new Ray(transform.position, fwd); //Physics capsule cast //Gotta figure this out later if (Physics.CapsuleCast(transform.position, fwd, 1.5f, Vector3.forward, out hit, distance)) { if (hit.collider.tag == "Zombie") { Debug.Log("Capsule hit!"); } } if (Physics.Raycast(DetectionRay, out hit, distance)) { //Ray Debugger Debug.DrawRay(transform.position, fwd, Color.green); if (hit.collider.tag == "Zombie") { //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); //Checks the zombie health script. ZombieAI health = hit.collider.GetComponent <ZombieAI>(); //this sets how much damage a zombie will take. See why this may not work if its attached to every gun? 1 damage isnt going to cut it if we're using miniguns or shotguns, etc. health.TakeDamage(1, hit.point); if (health != null) { health.TakeDamage(0, hit.point); Debug.Log("Zombie Health: " + health.currentHealth); } //Need health.takedamage(1,hit.point) Debug.Log(Zoomzoom.numEnemy); } //A repeat of above, except with EL DIABLO!! if (hit.collider.tag == "Devil") { DevilScript health = hit.collider.GetComponent <DevilScript>(); //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); if (health != null) { health.TakeDamage(1, hit.point); Debug.Log("Devil health = " + health.currentHealth); } } } }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); zombieAI = GetComponent <ZombieAI>(); zombieAudio = GetComponent <ZombieAudio>(); bodyParts = GetComponentsInChildren <Rigidbody>(); zombieMovement = GetComponent <ZombieMovement>(); characterController = GetComponent <CharacterController>(); isAlive = true; EnableRagdoll(false); }
private void Awake() { if (!gameObject.tag.Equals("Zevolution")) { component = GetComponent <ZombieAI>(); } if (!defaultsRegistered) { DefaultDR(); defaultsRegistered = true; } }
private void CmdSpawnZombiePlayer() { // Create the Zombie Player on the Server. GameObject zombiePlayer = Instantiate(playerZombie, transform.position, transform.rotation) as GameObject; ZombieAI cloneZombie = zombiePlayer.GetComponent <ZombieAI>(); cloneZombie.isInside = true; cloneZombie.name = name + " (Zombie)"; // Casdasdsdreate the Zombie Player on the Clients. NetworkServer.ReplacePlayerForConnection(connectionToClient, zombiePlayer, 0); NetworkServer.Destroy(gameObject); }
void Shoot() { myCurrentAmmo--; currentGun.currentAmmo = myCurrentAmmo; RaycastHit thisHit; if (Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out thisHit, myWepRange)) { //Debug.Log(thisHit.transform.name); ZombieAI myTarget = thisHit.transform.GetComponent <ZombieAI>(); //ZombieAI myTargetHead = thisHit.transform.GetComponentInParent<ZombieAI>(); if (myTarget != null) { // This is for headshots. If we choose, we can implement this later //if (thisHit.transform.tag == "Head Collider") //{ // myTargetHead.HeadshotDie(); // myTargetHead.headshot = true; // Debug.Log("Headshot!"); // if (myTargetHead.impactEffect != null) // { // GameObject zombieHitEffect = Instantiate(myTargetHead.impactEffect, thisHit.point, Quaternion.LookRotation(thisHit.normal)); // Destroy(zombieHitEffect, 0.75f); // } //} //else if (thisHit.transform.tag != "Head Collider") { myTarget.TakeDamage(myWepDamage); myTarget.wasShot = true; myTarget.canMove = false; Debug.Log("Hit!"); // This is incase we want to do a blood effect or something. if (myTarget.impactEffect != null) { GameObject zombieHitEffect = Instantiate(myTarget.impactEffect, thisHit.point, Quaternion.LookRotation(thisHit.normal)); Destroy(zombieHitEffect, 0.75f); } } // end of if else if statement. } // end of the check for a valid target } // end of raycast } // End of shooting animation
void Shoot() { RaycastHit _hit; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, weapon.range, mask)) { //debugger, we hit something Debug.Log("hit " + _hit.collider.name); ZombieAI target = _hit.transform.GetComponent <ZombieAI>(); if (target != null) { target.TakeDamage(PlayerWeapon.damage); } } }
void Awake() { _healthBar = GetComponentInChildren <ZombieHealthBar>(); _zombieAI = GetComponent <ZombieAI>(); _zombieMover = GetComponent <ZombieMover>(); _squad = transform.parent.GetComponent <ZombieSquad>(); if (_squad == null) { _squad = FindObjectOfType <ZombieSquad>(); } AudioManager = GetComponent <ZombieAudioManager>(); Invoke("UpdateParametersByMode", 0.1f); }
// Update is called once per frame void Update() { //Checks the forward Facing Direction & raycasts fwd = transform.TransformDirection(Vector3.forward * 10); Ray DetectionRay = new Ray(transform.position, fwd); //Fire by MB1 or Spacebar if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space")) { //Ray Debugger Debug.DrawRay(transform.position, fwd, Color.cyan); if (Physics.Raycast(DetectionRay, out hit, distance)) { if (hit.collider.tag == "Zombie") { //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); //Checks the zombie health script. ZombieAI health = hit.collider.GetComponent <ZombieAI>(); //this sets how much damage a zombie will take. See why this may not work if its attached to every gun? 1 damage isnt going to cut it if we're using miniguns or shotguns, etc. health.TakeDamage(damage, hit.point); if (health != null) { health.TakeDamage(0, hit.point); Debug.Log("Zombie Health: " + health.currentHealth); } //Need health.takedamage(1,hit.point) } //A repeat of above, except with EL DIABLO!! if (hit.collider.tag == "Devil") { DevilScript health = hit.collider.GetComponent <DevilScript>(); //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); if (health != null) { health.TakeDamage(damage, hit.point); Debug.Log("Devil health = " + health.currentHealth); } } } } }
void AreaDamageEnemies(Vector3 location, float radius, float damage) { Collider[] objectsInRange = Physics.OverlapSphere(location, radius); foreach (Collider col in objectsInRange) { ZombieAI enemy = col.GetComponent <ZombieAI>(); if (enemy != null) { // linear falloff of effect //float proximity = (location - enemy.transform.position).magnitude; // float effect = 1 - (proximity / radius); enemy.currentHealth -= 1; } } }
// This may need to be moved onto something else later. Perhaps a damager script? private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Fireball") { devilGO = GameObject.FindGameObjectWithTag("Devil"); devil = devilGO.GetComponent <DevilScript>(); Debug.Log("FUEGO!!!"); Destroy(collision.gameObject); TakeDamage(devil.fireballDamage); } else if (collision.gameObject.tag == "Zombie") { zombieGO = GameObject.FindGameObjectWithTag("Zombie"); zombie = zombieGO.GetComponent <ZombieAI>(); TakeDamage(zombie.zombieDamage); } }
public void AlertNearbyZombies(GameObject target) { Vector3 pos = transform.position; foreach (GameObject zombie in GameObject.FindGameObjectsWithTag("Zombie")) { Vector2 offset = pos - zombie.transform.position; if (zombie != gameObject && offset.sqrMagnitude <= alertRadius * alertRadius) { ZombieAI otherAI = zombie.GetComponent <ZombieAI>(); if (otherAI != null) { otherAI.externalTarget = target; } } } }
public void TryShoot(ZombieAI ai) { float currentTime = Time.time; MoveForward(0); state = zmmBodyState.Firing; facingLeft = ai.transition > 0 ? true : false; if (currentTime - lastShootTime > shootInterval) { lastShootTime = currentTime; if (ShootEvent != null) { ShootEvent(); // Fire the "ShootEvent" event. ai.OnDamage(1); } } }
//while colliding with the gas, Dinos and the Player will be affected by it void OnTriggerStay(Collider other) { if (mGasActive) { //if a Dino is colliding with the gas, it is stunned and will stay stunned as long as it touches the gas if (other.GetComponent <ZombieAI>()) { other.GetComponent <ZombieAI>().GetComponent <Stunable>().bStayStunned = true; other.GetComponent <ZombieAI>().GetComponent <Stunable>().IsStunned = true; } } else { if (other.GetComponent <ZombieAI>()) { ZombieAI zombie = other.GetComponent <ZombieAI>(); zombie.GetComponent <Stunable>().bStayStunned = false; zombie.GetComponent <Stunable>().IsStunned = false; } } }
void OnTriggerStay2D(Collider2D other) { if (auto) { if (other.gameObject.tag == "Enemy") { ZombieAI ai = other.gameObject.GetComponent <ZombieAI>(); if (ai != null) { TryShoot(ai); } } else if (other.gameObject.tag == "Supply") { supply sup = other.gameObject.GetComponent <supply>(); if (sup != null) { sup.Gather(); } } } }
void SetNewZombie(int viewID) { // //Debug.Log("RPC SetNewZombie() called"); PhotonView zombiephotonView = PhotonView.Find(viewID); if (zombiephotonView == null) { Debug.Log("Can not find PhotonView with ID viewID , in SetNewZombie()"); return; } ZombieAI zAI = zombiephotonView.gameObject.GetComponent <ZombieAI>(); ZombieStats zState = zombiephotonView.gameObject.GetComponent <ZombieStats>(); for (int i = 0; i < zAI.patrolSettings.waypoints.Length; i++) { zAI.patrolSettings.waypoints[i] = respawnerSetting.waypoints[(i + Zoffest) % respawnerSetting.waypoints.Length]; } zState.thisRespwaner = this; }
/// <summary> /// Generate a zombie and add him to the list /// </summary> void addZombie() { int newDifficulty = Difficulty_difficulty.onSpawn(); //what the difficulty currently is if (int_difficulty != newDifficulty) //if the difficulty has changed { int_difficulty = newDifficulty; numWords = 1; } GameObject goZ = (GameObject)Instantiate(Resources.Load("CommonZombie")); //Instantiate the zombie prefab from resources //Assign to an enemyManager //1:Randomly choose an enemyManager es = GameObject.FindGameObjectsWithTag("Spawner"); //Es now contains all of the enemy spawners int emi = (int)Random.Range(0, es.Length); //stands for enemy manager index //2:Set parent child relationship Transform pT = es[emi].transform; //pt stands for parent transform goZ.transform.parent = pT; Vector3 spawnPos = pT.position; spawnPos.x += Random.Range(-pT.lossyScale.x / 2, pT.lossyScale.x / 2); spawnPos.y += Random.Range(-pT.lossyScale.y / 2, pT.lossyScale.y / 2); ///goZ.transform.position.x += es[emi].transform.localScale.x; ///goZ.transform.position.y += es[emi].transform.localScale.y; goZ.transform.position = spawnPos; ZombieAI ZAI = goZ.GetComponent <ZombieAI>(); //get words for this zombie. Upgrades knows the difficulty settting so it can effectively determine //how many words to give ///numWords = Difficulty_difficulty.getNumWords(); ZAI.setWords(dictionary.pickWords(Difficulty_difficulty.WordLength, Difficulty_difficulty.NumWords * 10)); ZAI.setStats(int_difficulty, numWords); }
void Awake() { skeletonWand = GameObject.FindGameObjectWithTag(Tags.arm); shoot1 = skeletonWand.GetComponent <RUISFistGestureRecognizer>(); enemy = GameObject.FindGameObjectWithTag(Tags.enemy); AI = enemy.GetComponent <ZombieAI>(); mousewWand = GameObject.FindGameObjectWithTag(Tags.mouse); shoot2 = mousewWand.GetComponent <Shooting>(); skeletonWandLeft = GameObject.FindGameObjectWithTag("Armleft"); spray = skeletonWandLeft.GetComponent <RUISFistGestureRecognizer>(); mousewWandLeft = GameObject.FindGameObjectWithTag("Mouseleft"); spray2 = mousewWandLeft.GetComponent <Shooting>(); Uaa = GetComponent <AudioSource> (); Pang = GetComponent <ParticleSystem> (); effect = GetComponent <Light> (); displacement = FlyBehavior.displacement; }
void Awake() { RigidbodyCache = Hips.GetComponentsInChildren <Rigidbody>(); ColliderCache = Hips.GetComponentsInChildren <Collider>(); ai = GetComponent <ZombieAI>(); }
void Start () { zom = GetComponent<ZombieAI>(); anim = GetComponentInChildren<Animator>(); entity = GetComponent<Entity>(); }
void Start() { zombie = GetComponent <ZombieAI>(); }
// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); zombieAI = GetComponent <ZombieAI>(); }
TestWaveSpawner spawner; // wave spawner script void Start() { AIscript = enemy.GetComponent <ZombieAI>(); // used to access ai script spawner = GetComponent <TestWaveSpawner>(); // used to access spawner script }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ZombieAI zombieAI = animator.gameObject.GetComponent <ZombieAI>(); zombieAI.SetNextPoint(); }
public void Shoot() { RaycastHit hit; List <Ray> rays = new List <Ray>(); float distance = 4f; int numberOfRaysToShoot = 4; Vector3 fwd = transform.TransformDirection(Vector3.forward * 10); Ray DetectionRay = new Ray(transform.position, fwd); Ray NewDetectRay; Vector3 direction = transform.forward; Vector3 spread = new Vector3(); for (int i = 0; i < numberOfRaysToShoot; i++) { spread = spread + (transform.right * Random.Range(-1f, 1f)); direction += spread.normalized * Random.Range(0f, 0.2f); //rays.Add(Camera.main.ViewportPointToRay(new Vector3(Random.value, 0f, Random.value))); //fwd = transform.TransformDirection(new Vector3(0,0,0)); rays.Add(NewDetectRay = new Ray(direction, fwd)); } foreach (Ray ray in rays) { if (Physics.Raycast(ray, out hit, distance)) { Debug.DrawLine(transform.position, hit.point, Color.green, 1f); if (hit.collider.tag == "Zombie") { //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); //Checks the zombie health script. ZombieAI health = hit.collider.GetComponent <ZombieAI>(); //this sets how much damage a zombie will take. See why this may not work if its attached to every gun? 1 damage isnt going to cut it if we're using miniguns or shotguns, etc. health.TakeDamage(1, hit.point); if (health != null) { health.TakeDamage(0, hit.point); Debug.Log("Zombie Health: " + health.currentHealth); } //Need health.takedamage(1,hit.point) } //A repeat of above, except with EL DIABLO!! if (hit.collider.tag == "Devil") { DevilScript health = hit.collider.GetComponent <DevilScript>(); //If Zombie is hit, destroy that specific GameObject, and decrease # of zombies Debug.Log("Hit!"); if (health != null) { health.TakeDamage(1, hit.point); Debug.Log("Devil health = " + health.currentHealth); } } } else { Debug.DrawRay(this.transform.position, direction, Color.red, 0.2f); } } }
void OnEnable() { Reset(); zombie = GetComponent <ZombieAI> (); }
public WasHittedNode(ZombieAI zombieAI) { this.zombieAI = zombieAI; }
void Start() { zombieAI = gameObject.GetComponentInParent<ZombieAI>(); rb = gameObject.GetComponentInParent<Rigidbody2D> (); }
void Start() { ZombieController = GetComponent <ZombieAI>(); }
public EnemyState CreateEnemyState(Enemy enemy) { var AI = new ZombieAI(enemy, wizardNode); return(new EnemyState(AI, enemy)); }
// Use this for initialization void Start() { zombieAI = gameObject.GetComponentInParent<ZombieAI>(); }
private ZombieAI zombieAI; // #region public methods public IdelState(ZombieAI zAI) { zombieAI = zAI; }
// Will apply damage to any zombies within the Overlap Sphere. private void OverlapSphereDamage() { Collider[] hitColliders = Physics.OverlapSphere(transform.position, blastRadius); foreach (Collider collider in hitColliders) { Transform hitTransform = collider.transform; if (hitTransform.root.tag == "Zombie") { // If we have already iterated through a Zombie containing this collider, then skip to next. if (hitZombies.Contains(hitTransform.root)) { continue; } // Add the new zombie to the <hitZombies> so that he don't get iterated more than once. hitZombies.Add(collider.transform.root); ZombieAI targetZombie = collider.transform.root.GetComponent <ZombieAI>(); if (throwableType == ThrowableType.Molotov) { foreach (Transform child in targetZombie.transform) { // If the zombie is already on fire, there is not need to set him on fire. if (child.GetComponent <FireDamage>() != null) { continue; } } // Create a fire particle (does apply damage by itself). GameObject fireClone = Instantiate(fireParticle, collider.transform.position, Quaternion.identity) as GameObject; fireClone.name = "Flame"; fireClone.transform.SetParent(targetZombie.transform, true); fireClone.transform.localPosition = Vector3.zero; // Setup the fire particle FireDamage component. FireDamage fireDamage = fireClone.GetComponent <FireDamage>(); fireDamage.shooterID = shooterID; fireDamage.targetZombie = targetZombie; } else { // Set the grenade explosion to this one (for ExplosionForce physics) and apply damage to the zombie. targetZombie.grenadeExplosion = this; targetZombie.TakeDamage(damage, shooterID); } } else if (throwableType == ThrowableType.Grenade) { Rigidbody targetRigidbody = hitTransform.GetComponent <Rigidbody>(); if (targetRigidbody != null) { targetRigidbody.AddExplosionForce(damage * 10f, transform.position, blastRadius, 2f); } } } if (throwableType == ThrowableType.Grenade) { Destroy(gameObject); } }