void FixedUpdate() { if (Alive && !isStunned()) { if (MyVine != null) { Collider2D col = MyVine.GetComponent <Collider2D>(); if (col != null) { LimitMin = col.bounds.min.y; LimitMax = col.bounds.max.y; } } if (ThrowingProjectile) { if ((Time.time - ThrowTime) >= .25f) { ThrowingProjectile = false; ThrowTime = Time.time; //Fire the Projectile JungleMonkeyProjectile p = GameObject.Instantiate(ProjectilePrefab, this.transform.position, new Quaternion()); float sp = 5f * (1f + (2f * Astronaut.AggressionLevelF)); p.MyRigidbody.velocity = AimDirection * sp; Am.am.oneshot(Am.am.M.MonkeyThrow); if (Astronaut.AggressionLevel > 0) { for (int i = 0; i < Astronaut.AggressionLevel; i++) { JungleMonkeyProjectile c = GameObject.Instantiate(p, p.transform.position, p.transform.rotation); c.MyRigidbody.velocity = (p.MyRigidbody.velocity + (Random.insideUnitCircle * p.MyRigidbody.velocity.magnitude * .5f)); } } } } else { Astronaut plr = Astronaut.TheAstronaut; if ((Time.time - ThrowTime) >= .75f) { if ((plr != null) && (plr.Alive) && ((Time.time - plr.ReviveTime) >= 2f)) { Vector3 dif = (plr.transform.position - this.transform.position); if (dif.magnitude < 8f) { //if (Mathf.Abs(dif.x) < 2f) //{ if ((Time.time - climbtime) >= .5f) { climbtime = Time.time; ClimbDirection = 1 * ((int)Mathf.Sign(dif.y)); } //} //else //{ //climbdirection = -1*((int)Mathf.Sign(dif.y)); //} if ((Time.time - ThrowTime) >= Mathf.Lerp(2.5f, 1.75f, Astronaut.AggressionLevelF)) { ThrowingProjectile = true; ThrowTime = Time.time; MyAnimator.SetTrigger("Throw"); } AimDirection = dif.normalized; } } } } if (!ThrowingProjectile) { if (ClimbDirection != 0) { float cl = CLIMBINGSPEED * (Mathf.Lerp(1f, 2f, Astronaut.AggressionLevelF)) * (1f - FreezeFactor); if (ClimbDirection > 0) { if (this.transform.position.y < LimitMax) { this.transform.position = (this.transform.position + (Vector3.up * (Mathf.Min(Time.fixedDeltaTime * cl, LimitMax - this.transform.position.y)))); MyAnimator.SetInteger("Climbing", 1); } else { MyAnimator.SetInteger("Climbing", 0); } } else if (ClimbDirection < 0) { if (this.transform.position.y > LimitMin) { this.transform.position = (this.transform.position + (Vector3.down * (Mathf.Min(Time.fixedDeltaTime * cl, this.transform.position.y - LimitMin)))); MyAnimator.SetInteger("Climbing", -1); } else { MyAnimator.SetInteger("Climbing", 0); } } } else { ClimbDirection = 0; MyAnimator.SetInteger("Climbing", 0); } } else { ClimbDirection = 0; MyAnimator.SetInteger("Climbing", 0); } } else { ClimbDirection = 0; MyAnimator.SetInteger("Climbing", 0); } }
void Update() { CurrentAnimState.Update(); _footStepTimer += Time.deltaTime; _footStepTimeout = 0.1f; if (MyStatus.Health > 0) { UpdateLookDirection(); UpdateDestBodyAngle(); MyStatus.UpdateBodyStatusEveryone(); if (MyStatus.Health <= 0) { MyStatus.Health = 0; OnDeath(Vector3.zero); } MyAI.AlwaysPerFrameUpdate(); } bool isAlert = IsAlert(); if (isAlert) { if (MyAnimator.GetInteger("AlertLevel") <= 1) { MyAnimator.SetInteger("AlertLevel", 2); //Debug.LogError("setting alert level to TWO"); } } else { if (MyAnimator.GetInteger("AlertLevel") > 1) { MyAnimator.SetInteger("AlertLevel", 1); //Debug.LogError("setting alert level to ONE"); } } if (ActionState == HumanActionStates.Twitch) { if (_twitchTimer > 0) { _twitchTimer -= Time.deltaTime; } else { _twitchTimer = 0; OnInjuryRecover(); } } GoapAction action = MyAI.GetCurrentAction(); if (action != null) { CurrentAction = action.Name; } else { CurrentAction = "NONE"; } UpdateFading(); }