Beispiel #1
0
        private Vector3 speed; // keeps sprite speed between ticks

        public MouseMovementSystem(LocalGameRunner initializer)
        {
            text   = initializer.text;
            sprite = initializer.selector;
            map    = GameModel.localMap;
            bounds = new IntBounds3(0, 0, 0, map.xSize, map.ySize, map.zSize);
        }
Beispiel #2
0
 public LocalMap(int xSize, int ySize, int zSize)
 {
     this.xSize = xSize;
     this.ySize = ySize;
     this.zSize = zSize;
     blockType  = new BlockTypeMap(this);
     bounds     = new IntBounds3(0, 0, 0, xSize - 1, ySize - 1, zSize - 1);
     util       = new LocalMapUtil(this);
 }
Beispiel #3
0
 public IntBounds3 normalizeBounds(IntBounds3 bounds)
 {
     bounds.minX = Mathf.Max(bounds.minX, 0);
     bounds.maxX = Mathf.Min(bounds.maxX, map.xSize - 1);
     bounds.minY = Mathf.Max(bounds.minY, 0);
     bounds.maxY = Mathf.Min(bounds.maxY, map.ySize - 1);
     bounds.minZ = Mathf.Max(bounds.minZ, 0);
     bounds.maxZ = Mathf.Min(bounds.maxZ, map.zSize - 1);
     return(bounds);
 }
Beispiel #4
0
        public Vector3Int getRandomPosition(Vector3Int center, int xRange, int zRange)
        {
            IntBounds3 bounds = new IntBounds3(center, xRange, xRange, zRange);

            normalizeBounds(bounds);
            List <Vector3Int> positions = new List <Vector3Int>();

            bounds.iterate((x, y, z) => {
                int blockType = map.blockType.get(x, y, z);
                if (blockType != BlockTypeEnum.SPACE.CODE &&
                    blockType != BlockTypeEnum.WALL.CODE &&
                    blockType != BlockTypeEnum.FARM.CODE)          // passable position
                {
                    positions.Add(new Vector3Int(x, y, z));
                }
            });
            return(positions[Random.Range(0, positions.Count - 1)]);
        }
Beispiel #5
0
 private void _handleSelection(IntBounds3 bounds)
 {
     if (currentTool == NONE)
     {
         return;                      // TODO add unit/building/item/plant/block selection for NONE tool
     }
     bounds.iterate((x, y, z) => {
         if (currentTool.designation != null)   // tool applies designation
         {
             if (currentTool.designation.VALIDATOR.validate(x, y, z))
             {
                 GameModel.get().designationContainer.createDesignation(new Vector3Int(x, y, z), currentTool.designation);
             }
         }
         else if (currentTool == CLEAR)
         {
             GameModel.get().designationContainer.cancelDesignation(new Vector3Int(x, y, z));
         }
     });
 }
Beispiel #6
0
 public static void handleSelection(IntBounds3 bounds) => get()._handleSelection(bounds);