Esempio n. 1
0
        /// <summary>
        /// 开始移动
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async ETVoid StartMove(M2C_PathfindingResult message)
        {
            if (!this.Entity.GetComponent <StackFsmComponent>().ChangeState <NavigateState>(StateTypes.Run, "Navigate", 1))
            {
                return;
            }
            PlayRunAnimationByMoveSpeed();

            // 取消之前的移动协程
            this.EtCancellationTokenSource?.Cancel();
            this.EtCancellationTokenSource = ComponentFactory.Create <ETCancellationTokenSource>();
            this.Path.Clear();

            for (int i = 0; i < message.Xs.Count; ++i)
            {
                this.Path.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
            }

            this.UnitPosInServer = new Vector3(message.X, message.Y, message.Z);
            await this.StartMove_Internal(this.EtCancellationTokenSource.Token);

            this.EtCancellationTokenSource.Dispose();
            this.EtCancellationTokenSource = null;
            this.Entity.GetComponent <StackFsmComponent>().RemoveState("Navigate");
            this.Entity.GetComponent <AnimationComponent>().PlayAnimByStackFsmCurrent();
        }
Esempio n. 2
0
        public async ETVoid StartMove(M2C_PathfindingResult message)
        {
            // 取消之前的移动协程
            this.CancellationTokenSource?.Cancel();
            this.CancellationTokenSource = new CancellationTokenSource();

            this.Path.Clear();
            for (int i = 0; i < message.Xs.Count; ++i)
            {
                this.Path.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
            }
            ServerPos = new Vector3(message.X, message.Y, message.Z);

            await StartMove(this.CancellationTokenSource.Token);

            this.CancellationTokenSource.Dispose();
            this.CancellationTokenSource = null;
        }