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; })); }
public Task Stop() { return(SyncContext.Execute(() => { mNavMeshAgent.ResetPath(); })); }
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; })); }
public Task SetLookAt(Vector2 position, IMapData mapData) { return(SyncContext.Execute(() => { mLookTarget = GameUtils.GetPosition(position, mapData); transform.rotation = Quaternion.LookRotation(mLookTarget.Value - transform.localPosition); })); }
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); })); }
public Task <bool> ReleasePoint(int pointId) { return(SyncContext.Execute(() => mLockedPoints.Remove(pointId))); }