Example #1
0
        /// <summary>
        /// 移动任务处理方法
        /// </summary>
        public static async ETTask MoveAsync(this GamerPathComponent self, List <Vector3> path)
        {
            Gamer gamer = self.GetParent <Gamer>();

            if (path.Count == 0)
            {
                return;
            }
            // 第一个点是unit的当前位置,所以不用发送
            for (int i = 1; i < path.Count; ++i)
            {
                // 每移动3个点发送下3个点给客户端
                if (i % 3 == 1)
                {
                    self.BroadcastPath(path, i, 3);
                }
                Vector3 v3 = path[i];
                await gamer.GetComponent <GamerMoveComponent>().MoveToAsync(v3, self.CancellationTokenSource.Token);
            }
        }