コード例 #1
0
        public override IEnumerator RunLogic()
        {
            var playerMove  = GetAttr().GetComponent <MoveController>();
            var vcontroller = playerMove.vcontroller;
            var curInfo     = GetAttr().GetComponent <ISyncInterface>();

            while (!quit)
            {
                var isLocalMoving = MobaUtil.IsLocalMove(vcontroller);
                var isNetMove     = MobaUtil.IsServerMoveBySpeedOrPos(curInfo);
                //增加假的移动帧 降低启动时间
                if (isLocalMoving)
                {
                    //sync.AddFakeMove();
                }
                if (isNetMove || isLocalMoving)
                {
                    aiCharacter.ChangeState(AIStateEnum.MOVE);
                }
                yield return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// MoveController 摇杆输入
        /// MobaMeSync 网络输入
        /// 两个综合考虑
        /// </summary>
        /// <returns></returns>
        public override IEnumerator RunLogic()
        {
            networkMove = GetAttr().GetComponent <ISyncInterface>();
            var physics = GetAttr().GetComponent <CreepMeleeAI>();

            while (!quit)
            {
                //var curInfo = networkMove.GetServerVelocity();
                var isLocalMove = MobaUtil.IsLocalMove(vcontroller);
                var isNetMove   = MobaUtil.IsServerMoveBySpeedOrPos(networkMove);
                if (isLocalMove || isNetMove)
                {
                    if (isNetMove)//依赖服务器寻路
                    {
                        //MoveByNet();
                        //多个服务器发过来的帧率 有可能导致预测失败 现在的位置超过了预测位置导致玩家不断回头
                        //yield return GetAttr().StartCoroutine(MoveSmooth());
                        MoveByNet();
                        yield return(new WaitForFixedUpdate());
                    }
                    else if (isLocalMove) //依赖本地的寻路
                    {
                        MoveByHand();
                        yield return(new WaitForFixedUpdate());
                    }
                }
                else
                {
                    break;
                }
            }
            if (!quit)
            {
                aiCharacter.ChangeState(AIStateEnum.IDLE);
            }
        }