コード例 #1
0
        public Task <PlacementPoint> TryAllocatePoint()
        {
            return(SyncContext.Execute(() =>
            {
                if (PlacementPoints == null)
                {
                    return PlacementPoint.Invalid;
                }

                for (int i = 0; i < PlacementPoints.Length; i++)
                {
                    if (mLockedPoints.Contains(i))
                    {
                        continue;
                    }

                    if (!IsFree(i))
                    {
                        continue;
                    }

                    mLockedPoints.Add(i);
                    return new PlacementPoint(i,
                                              GameUtils.GetFlatPosition(transform.localPosition + PlacementPoints[i].transform.position -
                                                                        transform.position));
                }

                return PlacementPoint.Invalid;
            }));
        }
コード例 #2
0
ファイル: UnitView.cs プロジェクト: gormel/rts
 public Task Stop()
 {
     return(SyncContext.Execute(() =>
     {
         mNavMeshAgent.ResetPath();
     }));
 }
コード例 #3
0
        public Task <PlacementPoint> TryAllocatePoint()
        {
            return(SyncContext.Execute(() =>
            {
                if (BuilderPoints == null)
                {
                    return PlacementPoint.Invalid;
                }

                for (int i = 0; i < BuilderPoints.Length; i++)
                {
                    if (!mBusyPoints.Contains(i))
                    {
                        var ray = new Ray(BuilderPoints[i].transform.position, Vector3.up);
                        if (Physics.Raycast(ray))
                        {
                            continue;
                        }

                        mBusyPoints.Add(i);
                        return new PlacementPoint(i, GameUtils.GetFlatPosition(transform.localPosition + BuilderPoints[i].transform.position - transform.position));
                    }
                }

                return PlacementPoint.Invalid;
            }));
        }
コード例 #4
0
ファイル: UnitView.cs プロジェクト: gormel/rts
 public Task SetLookAt(Vector2 position, IMapData mapData)
 {
     return(SyncContext.Execute(() =>
     {
         mLookTarget = GameUtils.GetPosition(position, mapData);
         transform.rotation = Quaternion.LookRotation(mLookTarget.Value - transform.localPosition);
     }));
 }
コード例 #5
0
ファイル: UnitView.cs プロジェクト: gormel/rts
 public Task SetTarget(Vector2 position, IMapData mapData)
 {
     return(SyncContext.Execute(() =>
     {
         mLookTarget = null;
         Target = position;
         IsArrived = false;
         var target = GameUtils.GetPosition(position, mapData);
         mWaypointInst.transform.position = target;
         mWaypointInst.SetActive(true);
         mNavMeshAgent.SetDestination(target);
     }));
 }
コード例 #6
0
 public Task <bool> ReleasePoint(int pointId)
 {
     return(SyncContext.Execute(() => mLockedPoints.Remove(pointId)));
 }