void Start() { controller = GetComponent <Controller2D>(); thisCollider = GetComponent <Collider2D>(); pather = GetComponent <PathManager>(); animator = GetComponent <Animator>(); thisNode = GetComponentInChildren <Node>(); cam = Camera.main; bow = gameObject.transform.Find("Bow"); bow.localScale = new Vector3(1 / gameObject.transform.lossyScale.x, 1 / gameObject.transform.lossyScale.y, 1 / gameObject.transform.lossyScale.z); gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity); maxVelocityX = investigateSpeed * maxVelocityMultiple; maxVelocityY = jumpVelocity * maxVelocityMultiple; globalMaxInvestigateRange = localMaxInvestigateRange + transform.position; globalMinInvestigateRange = localMinInvestigateRange + transform.position; rangedEnemyState = RangedEnemyState.patrolling; faceDirX = 1; }
public void StartChasing() { this.state = RangedEnemyState.CHASING; // Start a new path to the targetPosition, call the the OnPathComplete function // when the path has been calculated (which may take a few frames depending on the complexity) path = null; seeker.StartPath(transform.position, player.transform.position, OnPathComplete); }
IEnumerator SwitchToAlert() { if (!switchingState) { switchingState = true; foreach (Transform child in bow) { GameObject.Destroy(child.gameObject); } yield return(new WaitForSeconds(alertSwitchTime)); rangedEnemyState = RangedEnemyState.alert; //lastStateTime = Time.time; switchingState = false; } }
IEnumerator SwitchToInvestigating() { if (!switchingState) { switchingState = true; foreach (Transform child in bow) { GameObject.Destroy(child.gameObject); } yield return(new WaitForSeconds(investigateSwitchTime)); rangedEnemyState = RangedEnemyState.investigating; endInvestigationTime = Time.time + investigateAttentionSpan; //lastStateTime = Time.time; switchingState = false; } }
IEnumerator SwitchToAttacking() { if (!switchingState) { switchingState = true; foreach (Transform child in bow) { GameObject.Destroy(child.gameObject); } arrowClone = LoadArrow(); yield return(new WaitForSeconds(attackSwitchTime)); rangedEnemyState = RangedEnemyState.attacking; //lastStateTime = Time.time; switchingState = false; } }
public void StartAttacking() { this.state = RangedEnemyState.ATTACKING; }
public void StartIdle() { this.state = RangedEnemyState.IDLE; }