示例#1
0
    public override void Act(UnityEngine.Transform player, UnityEngine.Transform npc)
    {
        dragonController.StateChange = false;
        AnimatorStateInfo stateinfo0 = animator.GetCurrentAnimatorStateInfo(0);

        if (!stateinfo0.IsName(info.name))
        {
            animator.SetInteger("State", info.id);
        }

        //float factor = ScenesManager.Instance.IsFreeze ? 0.3f : 1;

        #region SpecialCircle
        if (dragonController.ActionType == E_ActionType.SpecialCircle)
        {
            Vector3 direction = Vector3.zero;
            if (stayInArea)
            {
                direction = destPos - npc.position;
            }
            else
            {
                direction = ioo.cameraManager.position - npc.position;
            }
            Quaternion toRotation = Quaternion.LookRotation(direction);
            npc.rotation = Quaternion.Lerp(npc.rotation, toRotation, Time.fixedDeltaTime * dragonController.RotationSpeed);

            direction = destPos - npc.position;
            if (curIndex == 1)
            {
                dragonController.StayTimeUpdate();
            }

            if (direction.magnitude < attackDistance * 0.5f)
            {
                if (dragonController.stayTime > 0)
                {
                    if (!stayInArea)
                    {
                        ++curIndex;
                        stayInArea = true;
                    }
                    AreaManager.Instance.GetRandomPositionInArea(dragonController.stayArea, ref destPos);
                }
                else
                {
                    stayInArea = false;
                    ++curIndex;
                    if (curIndex >= wayPoints.Length)
                    {
                        dragonController.StateChange = true;
                    }
                    else
                    {
                        destPos = wayPoints[curIndex];
                    }
                }
            }
            //else
            //    npc.position += direction.normalized * Time.fixedDeltaTime * dragonController.MoveSpeed * factor;
        }
        #endregion

        #region ShakeScreen
        if (dragonController.ActionType == E_ActionType.ShakeScreen)
        {
            Vector3 direction = Vector3.zero;
            direction = destPos - npc.position;
            Quaternion toRotation = Quaternion.LookRotation(direction);
            npc.rotation = Quaternion.Lerp(npc.rotation, toRotation, Time.fixedDeltaTime * dragonController.RotationSpeed);
            direction    = destPos - npc.position;

            if (direction.magnitude < attackDistance * 0.5f)
            {
                if (!dragonController.Actived)
                {
                    AreaManager.Instance.GetRandomPositionInArea(dragonController.stayArea, ref destPos);
                }
                else
                {
                    if (direction.magnitude < attackDistance * 0.5f)
                    {
                        if (FindNextPoint(curIndex))
                        {
                            dragonController.StateChange = true;
                        }
                        else
                        {
                            ++curIndex;
                        }
                    }
                }
            }
            //else
            //    npc.position += direction.normalized * Time.fixedDeltaTime * dragonController.MoveSpeed * factor;
        }
        #endregion
    }