private void Activation() { SpiderAnimationEntry entry = this.states[this.currentState]; if ((this.targetBody != null) && ((entry.Animation.normalizedTime % 1f) >= 0.99f)) { this.StartRuning(); } }
private void ConfigureState(SpiderAnimationState animationState, string clipName, Action action = null) { SpiderAnimationEntry entry = new SpiderAnimationEntry { ClipName = clipName, Animation = this.animation[clipName], Action = action }; this.states.Add(animationState, entry); }
private void Runing() { SpiderAnimationEntry entry = this.states[this.currentState]; Vector3 directionToTarget = this.GetDirectionToTarget(); if (directionToTarget.Equals(Vector3.zero)) { entry.Animation.speed = 0f; } else { RaycastHit hit; float num = Vector3.Dot(directionToTarget, this.rigidbody.transform.right); float num2 = 0f; if (num > 0f) { num2 = 1f; } if (num < 0f) { num2 = -1f; } this.onGround = Physics.Raycast(base.transform.position + (base.transform.up * 0.2f), -base.transform.up, out hit, 1f, LayerMasks.STATIC); if (!this.onGround) { entry.Animation.speed = (Vector3.Dot(this.rigidbody.transform.up, Vector3.up) >= 0.1f) ? 0.2f : 4f; this.rigidbody.drag = 0f; } else { float magnitude = this.rigidbody.velocity.magnitude; if (magnitude > this.maximalRuningSpeed) { this.rigidbody.SetVelocitySafe((this.rigidbody.velocity * this.maximalRuningSpeed) / magnitude); } float num4 = Vector3.ProjectOnPlane(this.rigidbody.velocity, hit.normal).magnitude; entry.Animation.speed = num4 * this.runAnimationSpeed; Vector3 normalized = directionToTarget; if (Vector3.Dot(hit.normal, Vector3.up) > 0.5f) { normalized = Vector3.ProjectOnPlane(directionToTarget, hit.normal).normalized; } normalized = (normalized + (Vector3.up * 0.2f)).normalized; this.rigidbody.AddTorqueSafe(0f, num2 * this.rotationSpeed, 0f); this.rigidbody.AddForceAtPositionSafe(normalized * this.runForce, base.transform.position); this.rigidbody.drag = this.runingDrag; } } }
private void Jumping() { SpiderAnimationEntry entry = this.states[this.currentState]; entry.Animation.speed = 1.3f; if (!this.jumpForceApplied && ((entry.Animation.normalizedTime % 1f) > 0.3f)) { Vector3 normalized = ((this.GetDirectionToTarget() * 0.2f) + (Vector3.up * 0.8f)).normalized; this.rigidbody.AddForceSafe(normalized * this.jumpForce); this.jumpForceApplied = true; } if ((entry.Animation.normalizedTime % 1f) > 0.99f) { this.StartRuning(); } }