Пример #1
0
    /// <summary>
    /// 实际移动的逻辑
    /// </summary>
    /// <returns></returns>
    public override IEnumerator RunLogic()
    {
        var playerMove = GetAttr().GetComponent <MoveController>();

        physics     = playerMove.GetComponent <IPhysicCom>();
        networkMove = GetAttr().GetComponent <MonsterSync>();
        while (!quit)
        {
            //var netPos = networkMove.GetServerVelocity();
            var isNetMove = MobaUtil.IsServerMoveBySpeedOrPos(networkMove);
            if (isNetMove)
            {
                //MoveByNet();
                yield return(GetAttr().StartCoroutine(MoveSmooth()));
            }
            else
            {
                aiCharacter.ChangeState(AIStateEnum.IDLE);
                break;
            }
            //yield return null;

            /*
             * physics.TurnTo(playerMove.directionTo);
             *
             * var runTime = playerMove.runTime;
             * var passTime = 0.0f;
             * var curPos = playerMove.curPos;
             * var tarPos = playerMove.targetPos;
             * var curLogicFrameId = playerMove.logicFrameId;
             *
             * while (passTime < runTime && !quit)
             * {
             *  var newPos = Vector3.Lerp(curPos, tarPos, Mathf.Clamp01(passTime / runTime));
             *  physics.MoveTo(newPos);
             *  passTime += Time.deltaTime;
             *  yield return null;
             * }
             * if (!quit)
             * {
             *  //继续执行移动命令
             *  //否则结束进入Idle状态
             *  if (curLogicFrameId != playerMove.logicFrameId)
             *  {
             *      aiCharacter.SetRun();
             *  }
             *  else
             *  {
             *      aiCharacter.ChangeState(AIStateEnum.IDLE);
             *  }
             * }
             */
        }
    }
Пример #2
0
    public override IEnumerator RunLogic()
    {
        var monSync = GetAttr().GetComponent <MonsterSync>();

        while (!quit)
        {
            var isNetMove = MobaUtil.IsServerMoveBySpeedOrPos(monSync);
            if (isNetMove)
            {
                aiCharacter.ChangeState(AIStateEnum.MOVE);
            }
            yield return(null);
        }
    }