Beispiel #1
0
        public BeamPlace GetPlace(Vector2 pos)
        {
            Vector2 gridPos = Ground.NearestGridPoint(pos);
            int     xIdx    = (int)Mathf.Floor((gridPos.x - Ground.minX) / Ground.gridSize); // TODO: this is COPY/PASTA EVERYWHERE!!! FIX!!!
            int     zIdx    = (int)Mathf.Floor((gridPos.y - Ground.minZ) / Ground.gridSize);

            //Debug.Log(string.Format("gridPos: {0}, xIdx: {1}, zIdx: {2}", gridPos, xIdx, zIdx));
            return(Ground.IndicesAreOnMap(xIdx, zIdx) ? GetPlace(xIdx, zIdx) : null); // note this returns null for "no place" and for "out of bounds"
        }
Beispiel #2
0
        public BeamPlace ClaimPlace(IBike bike, int xIdx, int zIdx, long expireTimeMs)
        {
            BeamPlace p = Ground.IndicesAreOnMap(xIdx, zIdx) ? (GetPlace(xIdx, zIdx) ?? SetupPlace(bike, xIdx, zIdx, expireTimeMs)) : null;

            return((p?.bike == bike) ? p : null);
        }