示例#1
0
 public override TaskStatus OnUpdate()
 {
     if (this._timer >= 0f)
     {
         this._timer -= Time.deltaTime * this._aiEntity.TimeScale;
         if ((this._aiEntity.AttackTarget == null) || !this._aiEntity.AttackTarget.IsActive())
         {
             return(TaskStatus.Success);
         }
         Vector3 targetFaceDir = this.GetTargetFaceDir();
         if (this.forceAndInstant)
         {
             base.GetComponent <BaseMonoAnimatorEntity>().SteerFaceDirectionTo(targetFaceDir);
             return(TaskStatus.Success);
         }
         if (Mathf.Abs(Miscs.AngleFromToIgnoreY(this._aiEntity.FaceDirection, targetFaceDir)) >= this.angelThreshold)
         {
             this._aiController.TrySteer(targetFaceDir, (this.steerSpeedRatio * (this._aiEntity.GetProperty("Animator_MoveSpeedRatio") + 1f)) * 1.5f);
             return(TaskStatus.Running);
         }
         if (this.keepFacing)
         {
             return(TaskStatus.Running);
         }
     }
     return(TaskStatus.Success);
 }
示例#2
0
        protected override void SteerStep()
        {
            Vector3 faceDirection = base._monster.FaceDirection;

            if (base._monster.AttackTarget != null)
            {
                faceDirection   = base._monster.AttackTarget.XZPosition - base._monster.XZPosition;
                faceDirection.y = 0f;
                faceDirection.Normalize();
                Debug.DrawLine(base._monster.transform.position, base._monster.transform.position + ((Vector3)(faceDirection * 10f)), Color.blue);
                Debug.DrawLine(base._monster.transform.position, base._monster.transform.position + ((Vector3)(base._monster.FaceDirection * 10f)), Color.red);
                faceDirection = base._monster.FaceDirection + faceDirection;
                float num = Miscs.AngleFromToIgnoreY(base._monster.FaceDirection, faceDirection);
                if (this.steerType == SteerLimitState.OnlySteerLeft)
                {
                    if (num > 0f)
                    {
                        faceDirection = -faceDirection;
                    }
                }
                else if ((this.steerType == SteerLimitState.OnlySteerRight) && (num < 0f))
                {
                    faceDirection = -faceDirection;
                }
                Debug.DrawLine(base._monster.transform.position, base._monster.transform.position + ((Vector3)(faceDirection * 10f)), Color.yellow);
                base._monster.SteerFaceDirectionTo(Vector3.Slerp(base._monster.FaceDirection, faceDirection, (base.steerRatio * base._monster.TimeScale) * Time.deltaTime));
            }
        }
示例#3
0
 protected override TaskStatus OnMoveUpdate()
 {
     this.UpdateTargetDistance();
     if (this._timer >= 0f)
     {
         this._timer -= Time.deltaTime * base._aiEntity.TimeScale;
         if (base.CheckCollided())
         {
             return(TaskStatus.Success);
         }
         if ((base._aiEntity.AttackTarget == null) || !base._aiEntity.AttackTarget.IsActive())
         {
             return(TaskStatus.Success);
         }
         if (!this._isAutoDirectionSet && (this.speedDirection == SpeedDirection.Auto))
         {
             BaseMonoEntity attackTarget = base._aiEntity.AttackTarget;
             Vector3        xZPosition   = base._aiEntity.XZPosition;
             Vector3        b            = attackTarget.XZPosition;
             if (Vector3.Distance(xZPosition, b) <= this.autoDistanceThreshold)
             {
                 this.speedDirection = SpeedDirection.Back;
             }
             else
             {
                 this.speedDirection = SpeedDirection.Forward;
             }
             this._isAutoDirectionSet = true;
         }
         Vector3 targetDirection = this.GetTargetDirection();
         base._aiController.TrySteer(targetDirection, this.GetSteerRatio());
         if (this.speedDirection == SpeedDirection.Back)
         {
             if (!string.IsNullOrEmpty(this.backSpeedKey.Value))
             {
                 base._aiController.TryMove(-this._backSpeed);
             }
             else
             {
                 base.DoMoveBack();
             }
         }
         else if (this.speedDirection == SpeedDirection.Forward)
         {
             base.DoMoveForward();
         }
         if (Mathf.Abs(Miscs.AngleFromToIgnoreY(base._aiEntity.FaceDirection, targetDirection)) >= this.angelThreshold)
         {
             base._aiController.TrySteer(targetDirection, this.GetSteerRatio());
             return(TaskStatus.Running);
         }
     }
     return(TaskStatus.Success);
 }
示例#4
0
        public override void PostUpdate()
        {
            this._timer -= Time.deltaTime;
            Vector3 vector = this._targetPosition - base._owner.cameraPosition;
            float   f      = Miscs.AngleFromToIgnoreY(-base._owner.cameraForward, -vector);

            if ((Mathf.Abs(f) < 20f) || (this._timer < 0f))
            {
                base.End();
            }
            else
            {
                float b = base._owner.anchorPolar - f;
                base._owner.anchorPolar               = Mathf.Lerp(base._owner.anchorPolar, b, (Time.deltaTime * 5f) / 5f);
                base._owner.posLerpRatio              = 2f;
                base._owner.forwardLerpRatio          = 2f;
                base._owner.needLerpPositionThisFrame = true;
                base._owner.needLerpForwardThisFrame  = true;
            }
        }
示例#5
0
        public override void Enter()
        {
            if (base._owner.followAvatarControlledRotate.active)
            {
                base._owner.followAvatarControlledRotate.SetExitingControl(false);
            }
            float f    = Miscs.AngleFromToIgnoreY(-base._owner.cameraForward, -base._owner.avatar.FaceDirection);
            float num2 = Mathf.Abs(f);

            if (num2 < 10f)
            {
                this._targetPolar = base._owner.anchorPolar;
            }
            else if ((num2 > 90f) && !base._owner.avatar.IsAnimatorInTag(AvatarData.AvatarTagGroup.Stable))
            {
                this._targetPolar = base._owner.anchorPolar - (Mathf.Sign(f) * 90f);
            }
            else
            {
                this._targetPolar = base._owner.anchorPolar - f;
            }
            this._polar = base._owner.anchorPolar;
        }
示例#6
0
 public bool CanRotate()
 {
     return(Mathf.Abs(Miscs.AngleFromToIgnoreY(-base._owner.cameraForward, -base._owner.avatar.FaceDirection)) > 10f);
 }