public void Enter(NPC npc) { if (npc is ShooterScript) { shooter = npc as ShooterScript; } }
// Use this for initialization void Start() { winnerObject = GameObject.FindGameObjectWithTag("GameController").GetComponent <hasWon>(); playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>(); //playerHealth2 = GameObject.FindGameObjectWithTag("PlayerWScript").GetComponent<PlayerMovement>(); shooterHealth = GameObject.FindGameObjectWithTag("Enemy").GetComponent <ShooterScript>(); }
// Use this for initialization void Start() { // Get the weapons weaponOne = GameObject.FindGameObjectWithTag("FrontalCannon").GetComponent <ShooterScript>(); cuerpoBoss = GameObject.FindGameObjectWithTag("FrontalCannon") as GameObject; anim = gameObject.GetComponent <Animator>(); canShoot = true; arm = this.transform.GetChild(1).GetComponent <ArmScript>(); armTwo = this.transform.GetChild(2).GetComponent <ArmScript>(); //misileLauncher = this.transform.GetChild(4).GetComponent<MisileScript>(); instance.isMoving = true; _startPosition = transform.position; health = this.gameObject.GetComponent <EnemyHealth>(); pickUp = true; weaponTimeToShoot = Time.time + weaponShootingRate; clawTimeToShoot = Time.time + clawShootingRate; misileTimeToShoot = Time.time + misileShootingRate; }
private void OnTriggerEnter(Collider other) { if (isActive) { if (other.tag == "player") { isActive = false; fow.ShowInHidden = true; fow.ShowInExplored = true; ss = other.GetComponentInChildren<ShooterScript>(); ammoDepot = ss.ammoDepot.position; StartCoroutine(Move (ammoDepot)); audio.Stop (); audio.Play(); } else if (other.tag == "enemy") { Destroy(gameObject); } } }
public void Exit(NPC npc) { shooter = null; }
// Update is called once per frame void Update() { ShooterScript movementScript = shooterObj.GetComponent <ShooterScript>(); isPatrolling = true; RaycastHit hitInfo; Vector3 startPoint = shooterObject.transform.position + new Vector3(0, 1, 0); if ((!isAtWaypoint1 && !isAtWaypoint2) || (isAtWaypoint2 && !isAtWaypoint1) && isPatrolling == true && isPursuing == false) { shooterObject.transform.LookAt(waypoint1.transform); if (Vector3.Distance(shooterObject.position, waypoint1.transform.position) > radiusOfSatisfaction) { float shooterYPos = transform.position.y; Vector3 customPos = waypoint1.transform.position; customPos.y = shooterYPos; shooterObject.transform.LookAt(customPos); shooterObject.transform.position += shooterObject.transform.forward * moveSpeed * Time.deltaTime; } else { isAtWaypoint1 = true; isAtWaypoint2 = false; } } if ((isAtWaypoint1 && !isAtWaypoint2) && isPatrolling == true && isPursuing == false) { shooterObject.transform.LookAt(waypoint2.transform); if (Vector3.Distance(shooterObject.position, waypoint2.transform.position) > radiusOfSatisfaction) { float shooterYPos = transform.position.y; Vector3 customPos = waypoint2.transform.position; customPos.y = shooterYPos; shooterObject.transform.LookAt(customPos); shooterObject.transform.position += shooterObject.transform.forward * moveSpeed * Time.deltaTime; } else { isAtWaypoint2 = true; isAtWaypoint1 = false; } } if (Physics.Raycast(startPoint, transform.forward, out hitInfo, rayDistance, raycastLayers.value)) { //shooterObject.transform.LookAt(playerObject); if (Vector3.Distance(shooterObject.position, playerObject.position) <= detectionDistance) { isPatrolling = false; isPursuing = true; float shooterYPos = transform.position.y; Vector3 customPos = playerObject.transform.position; customPos.y = shooterYPos; shooterObject.transform.LookAt(customPos); shooterObject.transform.position += shooterObject.transform.forward * moveSpeed * Time.deltaTime; if (Time.time > nextRound) { nextRound = Time.time + fireRate; myAnimator.SetBool("isFiring", true); var projectileBullet = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); projectileBullet.GetComponent <Rigidbody>().velocity = projectileBullet.transform.forward * 10; Destroy(projectileBullet, 4f); } } else if (Vector3.Distance(shooterObject.position, playerObject.position) > detectionDistance) { isPatrolling = true; isPursuing = false; } myAnimator.SetBool("isFiring", false); } //health system if (shooterHealth <= 0 && !isDead) { isDead = true; isPatrolling = false; myAnimator.SetTrigger("isDeadTrigger"); Destroy(shooterObj, 7f); movementScript.enabled = !movementScript.enabled; } }