Beispiel #1
0
 /// <summary>
 /// Get block at (x, y) coord.
 /// </summary>
 public Option <T> GetBlock(int x, int y)
 {
     if (MapUtil.CheckBounds(parentMap, x, y))
     {
         return(parentMap[x, y]);
     }
     else
     {
         return(Option.None <T>());
     }
 }
Beispiel #2
0
 public bool DamageBlock(int x, int y, int damage)
 {
     if (MapUtil.CheckBounds(parentMap, x, y))
     {
         bool success = false;
         parentMap[x, y].MatchSome(b => success = b.DealDamage(damage));
         return(success);
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Set a block to a value on the blockMap, updating tileset in the process.
        /// </summary>
        public bool SetBlock(int x, int y, Option <T> block)
        {
            if (MapUtil.CheckBounds(parentMap, x, y))
            {
                // Coords are within bounds!

                parentMap[x, y] = block;
                int tileSetId = -1; // If none, clear the cell.
                block.MatchSome(v => tileSetId = GetBlockID(v));
                parent.SetCell(x, y, tileSetId);
                parent.UpdateBitmaskArea(new Vector2(x, y)); // Update this block, and its neighbors, so that the texture is correct.
                return(true);                                // Success!
            }
            else
            {
                // Coords are not within bounds.
                return(false);
            }
        }