Example #1
0
        public override TaskStatus OnUpdate()
        {
            if (this.targetEntity.Value == null)
            {
                return(TaskStatus.Failure);
            }
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (this.syncWithAttackTarget && ((this.targetEntity.Value as BaseMonoMonster).GetAttackTarget() == null))
            {
                return(TaskStatus.Failure);
            }
            Vector3 targetPostion = this.GetTargetPostion();

            if (this.isTeleporting)
            {
                if (this.teleportTimeSpan.Value > 0f)
                {
                    if (this.teleportTimer >= this.teleportTimeSpan.Value)
                    {
                        this.isTeleporting = false;
                    }
                }
                else if (component.gameObject.activeSelf)
                {
                    component.FireEffect("Monster_TeleportTo_Small");
                    this.isTeleporting = false;
                }
            }
            if (Vector3.Distance(component.XZPosition, targetPostion) > 1f)
            {
                if (this.teleportTimeSpan.Value > 0f)
                {
                    if (!this.isTeleporting)
                    {
                        this.teleportTimer = 0f;
                        this.isTeleporting = true;
                    }
                }
                else if (component.gameObject.activeSelf)
                {
                    component.FireEffect("Monster_TeleportFrom_Small");
                    this.isTeleporting = true;
                }
            }
            if (this.syncWithAttackTarget)
            {
                Vector3 vector2 = targetPostion - component.transform.position;
                component.transform.forward = vector2.normalized;
            }
            else
            {
                component.transform.forward = this.targetEntity.Value.transform.forward;
            }
            if (this.isTeleporting && (this.teleportTimeSpan.Value > 0f))
            {
                this.teleportTimer          += Time.deltaTime;
                component.transform.position = Vector3.Lerp(component.transform.position, targetPostion, this.teleportTimer / this.teleportTimeSpan.Value);
            }
            else
            {
                component.transform.position = targetPostion;
            }
            component.SetLocomotionBool("IsMove", (this.targetEntity.Value as BaseMonoAnimatorEntity).GetLocomotionBool("IsMove"), false);
            component.SetLocomotionBool("IsMoveHorizontal", (this.targetEntity.Value as BaseMonoAnimatorEntity).GetLocomotionBool("IsMoveHorizontal"), false);
            component.SetLocomotionFloat("MoveSpeed", (this.targetEntity.Value as BaseMonoAnimatorEntity).GetLocomotionFloat("MoveSpeed"), false);
            component.SetLocomotionFloat("AbsMoveSpeed", (this.targetEntity.Value as BaseMonoAnimatorEntity).GetLocomotionFloat("AbsMoveSpeed"), false);
            if (this.syncOneFrame && !this.isTeleporting)
            {
                return(TaskStatus.Success);
            }
            return(TaskStatus.Running);
        }