Ejemplo n.º 1
0
                // Constructor

                /**
                 * Constructing a map involves constructing the internal objects layer and the internal block layer.
                 * The block mask will be immutable, since it will never be modified. OTOH the solid mask (for the objects layer)
                 *   will be mutable. But those layers are initialized inside the tilemap.
                 */
                public Tilemap(Behaviours.Map relatedMap, uint width, uint height, Texture2D source, int maskApplicationOffsetX = 0, int maskApplicationOffsetY = 0)
                {
                    if (relatedMap == null)
                    {
                        throw new NullReferenceException("Related map for tile map must not be null");
                    }

                    if (width < 1 || width > MAX_WIDTH || height < 1 || height > MAX_HEIGHT)
                    {
                        throw new InvalidDimensionsException(width, height);
                    }

                    RelatedMap = relatedMap;
                    Width      = width;
                    Height     = height;
                    solidMask  = new SolidMask(width, height);
                    if (source != null)
                    {
                        Bitmask bitMask = new Bitmask(source);
                        if (width != bitMask.Width || height != bitMask.Height || maskApplicationOffsetX != 0 || maskApplicationOffsetY != 0)
                        {
                            bitMask = bitMask.Translated(width, height, maskApplicationOffsetX, maskApplicationOffsetY);
                        }
                        blockMask = bitMask;
                    }
                    else
                    {
                        blockMask = new Bitmask(width, height);
                    }
                }
Ejemplo n.º 2
0
 private Bitmask ParsePresenceData(Texture2D presenceData, int presenceDataOffsetX, int presenceDataOffsetY)
 {
     if (presenceData != null)
     {
         Bitmask parsedPresenceData = new Bitmask(presenceData);
         if (Width != presenceData.width || Height != presenceData.width || presenceDataOffsetX != 0 || presenceDataOffsetY != 0)
         {
             parsedPresenceData = parsedPresenceData.Translated(Width + 1, Height + 1, presenceDataOffsetX, presenceDataOffsetY);
         }
         return(parsedPresenceData);
     }
     else
     {
         return(new Bitmask(Width + 1, Height + 1));
     }
 }