//-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public CollectibleReward(Reward reward, bool isDrop = false)
        {
            this.reward			= reward;
            this.showMessage	= !reward.OnlyShowMessageInChest;
            this.hasDuration	= reward.HasDuration;
            this.isCollectibleWithItems = reward.IsCollectibleWithItems;
            this.isDrop			= isDrop;

            // Physics.
            Physics.CollisionBox		= new Rectangle2I(-4, -9, 8, 8);
            Physics.SoftCollisionBox	= new Rectangle2I(-5, -9, 9, 8);
            EnablePhysics(
                PhysicsFlags.Bounces |
                PhysicsFlags.HasGravity |
                PhysicsFlags.CollideRoomEdge |
                PhysicsFlags.CollideWorld |
                PhysicsFlags.HalfSolidPassable |
                PhysicsFlags.DestroyedInHoles);
            soundBounce = reward.BounceSound;

            // Graphics.
            centerOffset					= new Point2I(0, -5);
            Graphics.DrawOffset				= new Point2I(-8, -13);
            Graphics.RipplesDrawOffset		= new Point2I(0, 1);
            Graphics.IsGrassEffectVisible	= true;
            Graphics.IsRipplesEffectVisible	= true;
        }
 public SpriteSheet(Image image, int cellWidth, int cellHeight, int offsetX, int offsetY, int spacingX, int spacingY)
 {
     this.image		= image;
     this.cellSize	= new Point2I(cellWidth, cellHeight);
     this.offset		= new Point2I(offsetX, offsetY);
     this.spacing	= new Point2I(spacingX, spacingY);
 }
Beispiel #3
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public Seed(SeedType type)
        {
            this.type = type;

            // Flags for seed's dropped from satchel
            EnablePhysics(
                PhysicsFlags.HasGravity |
                PhysicsFlags.DestroyedOutsideRoom |
                PhysicsFlags.DestroyedInHoles);

            /*
            // Flags for seed Projectiles
            EnablePhysics(
                PhysicsFlags.DestroyedOutsideRoom |
                PhysicsFlags.CollideWorld |
                PhysicsFlags.ReboundSolid |
                PhysicsFlags.HalfSolidPassable |
                PhysicsFlags.LedgePassable);
            */

            Physics.CollisionBox		= new Rectangle2F(-1, -1, 2, 2);
            Physics.SoftCollisionBox	= new Rectangle2F(-1, -1, 2, 2);
            graphics.DrawOffset			= new Point2I(-4, -6);
            centerOffset				= new Point2I(0, -2);
        }
 public SpriteSheet(Image image, Point2I cellSize, Point2I offset, Point2I spacing)
 {
     this.image		= image;
     this.cellSize	= cellSize;
     this.offset		= offset;
     this.spacing	= spacing;
 }
Beispiel #5
0
        public Level(string name, int width, int height, int layerCount, Point2I roomSize, Zone zone)
        {
            this.world			= null;
            this.roomSize		= roomSize;
            this.roomLayerCount = layerCount;
            this.dimensions		= Point2I.Zero;
            //this.zone			= zone;

            properties = new Properties(this);
            properties.BaseProperties = new Properties();

            properties.BaseProperties.Set("id", "")
                .SetDocumentation("ID", "", "", "", "The id used to refer to this level.", false, true);

            properties.BaseProperties.Set("dungeon", "")
                .SetDocumentation("Dungeon", "dungeon", "", "", "The dungeon this level belongs to.");
            properties.BaseProperties.Set("dungeon_floor", 0)
                .SetDocumentation("Dungeon Floor", "", "", "", "The floor in the dungeon this level belongs to.");

            properties.BaseProperties.Set("discovered", false);

            properties.Set("id", name);

            properties.BaseProperties.Set("zone", "")
                .SetDocumentation("Zone", "zone", "", "", "The zone type for this room.", true, false);

            Zone = zone;

            Resize(new Point2I(width, height));
        }
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public BaseTileData()
        {
            name			= "";
            type			= null;
            tileset			= null;
            sheetLocation	= Point2I.Zero;
            properties		= new Properties(this);
            events			= new ObjectEventCollection();

            properties.Set("id", "");
            properties.SetDocumentation("id", "ID", "", "", "General",
                "The id used to refer to this tile.");

            properties.Set("enabled", true);
            properties.SetDocumentation("enabled", "Enabled", "", "", "General",
                "True if the tile is spawned upon entering the room.");

            properties.Set("sprite_index", 0);
            properties.SetDocumentation("sprite_index", "Sprite Index", "sprite_index", "", "Internal",
                "The current sprite in the sprite list to draw.");

            properties.Set("substrip_index", 0);
            properties.SetDocumentation("substrip_index", "Animation Substrip Index", "", "", "Internal",
                "The index of the substrip for dynamic animations.", true, true);
        }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public DungeonMapFloor(DungeonFloor dungeonFloor)
        {
            this.dungeonFloor	= dungeonFloor;
            this.floorNumber	= dungeonFloor.FloorNumber;
            this.isDiscovered	= dungeonFloor.IsDiscovered;
            this.size			= new Point2I(8, 8);

            // Create rooms.
            rooms = new DungeonMapRoom[size.X, size.Y];
            isBossFloor = false;

            if (dungeonFloor.Level !=  null) {
                for (int x = 0; x < size.X; x++) {
                    for (int y = 0; y < size.Y; y++) {
                        Point2I loc = new Point2I(x, y);
                        if (dungeonFloor.Level.ContainsRoom(loc)) {
                            Room room = dungeonFloor.Level.GetRoomAt(loc);
                            if (!room.IsHiddenFromMap) {
                                rooms[x, y] = DungeonMapRoom.Create(room, this);
                                if (rooms[x, y] != null && rooms[x, y].IsBossRoom)
                                    isBossFloor = true;
                            }
                        }
                        else
                            rooms[x, y] = null;
                    }
                }
            }
        }
        //-----------------------------------------------------------------------------
        // Bridge Methods
        //-----------------------------------------------------------------------------
        public void CreateBridge(bool instantaneous = false, bool rememberState = false)
        {
            if (bridgeDirection >= 0 && (state == TileBridgeState.Destroyed || state == TileBridgeState.Destroying)) {

                if (state == TileBridgeState.Destroying) {
                    pieceLocation += Directions.ToPoint(bridgeDirection);
                }
                else {
                    pieceLocation = Location + Directions.ToPoint(bridgeDirection);
                }

                state = TileBridgeState.Creating;
                timer = 0;
            }

            if (instantaneous) {
                while (state == TileBridgeState.Creating) {
                    if (RoomControl.IsTileInBounds(pieceLocation) && GetConnectedTile(pieceLocation) == null) {
                        TileData pieceTileData = Resources.GetResource<TileData>(
                            isVertical ? "bridge_vertical" : "bridge_horizontal");
                        Tile pieceTile = Tile.CreateTile(pieceTileData);
                        RoomControl.PlaceTileOnHighestLayer(pieceTile, pieceLocation);
                        pieceLocation += Directions.ToPoint(bridgeDirection);
                    }
                    else {
                        state = TileBridgeState.Created;
                        break;
                    }
                }
            }

            if (state == TileBridgeState.Created || state == TileBridgeState.Creating) {
                Properties.Set("built", true);
            }
        }
 // Draws the item inside the inventory.
 protected override void DrawSprite(Graphics2D g, Point2I position, int lightOrDark)
 {
     Sprite spr = sprite[level];
     if (inventory.IsWeaponEquipped(this) && spriteEquipped != null)
         spr = spriteEquipped[level];
     g.DrawSprite(spr, lightOrDark, position);
 }
 public static void DrawSprite(Graphics g, SpriteAnimation sprite, int variantID, Point2I position, Point2I sourceSize)
 {
     if (sprite.IsAnimation)
         DrawSprite(g, sprite.Animation.GetFrameAsSprite(0), variantID, position.X, position.Y, sourceSize.X, sourceSize.Y);
     else
         DrawSprite(g, sprite.Sprite, variantID, position.X, position.Y, sourceSize.X, sourceSize.Y);
 }
Beispiel #11
0
 // Draws the item inside the inventory.
 protected override void DrawSprite(Graphics2D g, Point2I position, int lightOrDark)
 {
     Sprite spr = sprite[level];
     if (spriteEquipped != null)
         spr = spriteEquipped[level];
     g.DrawSprite(isEquipped ? spr : sprite[level], lightOrDark, position);
 }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public ViewControl()
 {
     this.viewSize		= GameSettings.VIEW_SIZE;
     this.panSpeed		= GameSettings.VIEW_PAN_SPEED;
     this.position		= Vector2F.Zero;
     this.shakeOffset	= Vector2F.Zero;
 }
        private Point2I spacing; // Pixels between cells.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public SpriteSheet(Image image)
        {
            this.image		= image;
            this.cellSize	= Point2I.Zero;
            this.offset		= Point2I.Zero;
            this.spacing	= Point2I.Zero;
        }
Beispiel #14
0
 public Sprite(Image image, Rectangle2I sourceRect, Point2I drawOffset)
 {
     this.image			= image;
     this.sourceRect		= sourceRect;
     this.drawOffset		= drawOffset;
     this.nextPart		= null;
 }
        public MonsterBeetle()
        {
            // General.
            MaxHealth		= 1;
            ContactDamage	= 1;
            color			= MonsterColor.Green;

            // Movement.
            moveSpeed					= 0.5f;
            //numMoveAngles				= 8;
            //isMovementDirectionBased	= true;
            changeDirectionsOnCollide	= true;
            movesInAir					= false;
            stopTime.Set(0, 0);
            moveTime.Set(50, 80);

            // Physics.
            Physics.Bounces			= true; // This is here for when the monster is digged up or dropped from the ceiling.
            Physics.ReboundRoomEdge	= true;
            Physics.ReboundSolid	= true;

            // Graphics.
            animationMove				= GameData.ANIM_MONSTER_BEETLE;
            Graphics.DrawOffset			= new Point2I(-8, -14) + new Point2I(0, 3);
            centerOffset				= new Point2I(0, -6) + new Point2I(0, 3);
            syncAnimationWithDirection	= true;

            // Interactions.
            SetReaction(InteractionType.SwitchHook, SenderReactions.Intercept, Reactions.Damage);
        }
Beispiel #16
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public Sprite()
 {
     this.image			= null;
     this.sourceRect		= Rectangle2I.Zero;
     this.drawOffset		= Point2I.Zero;
     this.nextPart		= null;
 }
 public BaseTileData(BaseTileData copy)
 {
     type				= copy.type;
     tileset				= copy.tileset;
     sheetLocation		= copy.sheetLocation;
     properties			= new Properties();
     properties.SetAll(copy.properties);
 }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public EventTileDataInstance()
 {
     this.room				= null;
     this.position			= Point2I.Zero;
     this.data				= null;
     this.modifiedProperties	= new Properties();
     this.modifiedProperties.PropertyObject = this;
 }
 public override void OnMouseDragMove(MouseEventArgs e)
 {
     Point2I mousePos	= new Point2I(e.X, e.Y);
     Room	room		= LevelDisplayControl.SampleRoom(mousePos);
     Point2I tileCoord	= LevelDisplayControl.SampleTileCoordinates(mousePos);
     if (room != null)
         ActivateTile(e.Button, room, tileCoord);
 }
Beispiel #20
0
 //-----------------------------------------------------------------------------
 // Slots
 //-----------------------------------------------------------------------------
 // Adds the slot to the slot group.
 public Slot AddSlot(Point2I position, int width)
 {
     Slot slot = new Slot(this, position, width);
     slots.Add(slot);
     if (slots.Count == 1)
         currentSlot = slot;
     return slot;
 }
Beispiel #21
0
 //-----------------------------------------------------------------------------
 // Rewards
 //-----------------------------------------------------------------------------
 public Collectible SpawnCollectibleFromBreakableTile(Reward reward, Point2I position)
 {
     Collectible collectible = new Collectible(reward);
     gameControl.RoomControl.SpawnEntity(collectible);
     collectible.Position = position;
     collectible.Physics.ZVelocity = 1.5f;
     return collectible;
 }
Beispiel #22
0
        public override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Point2I mousePos	= new Point2I(e.X, e.Y);
            Room room			= LevelDisplayControl.SampleRoom(mousePos);
            Point2I tileCoord	= LevelDisplayControl.SampleTileCoordinates(mousePos);

            if (EditorControl.EventMode) {
                if (EditorControl.EventMode && e.Button == MouseButtons.Left) {
                    //EventTileData eventTile = Resources.GetResource<EventTileData>("warp");
                    EventTileData eventTile = Resources.GetResource<EventTileData>("npc");

                    //Point2I mousePos	= new Point2I(e.X, e.Y);
                    //Room room		= LevelDisplayControl.SampleRoom(mousePos);

                    if (room != null) {
                        Point2I roomPos = LevelDisplayControl.GetRoomDrawPosition(room);
                        Point2I pos = (mousePos - roomPos) / 8;
                        pos *= 8;
                        //Point2I tileCoord = LevelDisplayControl.SampleTileCoordinates(mousePos);
                        room.CreateEventTile(eventTile, pos);
                    }
                }
                else if (EditorControl.EventMode && e.Button == MouseButtons.Right) {
                    EventTileDataInstance eventTile = LevelDisplayControl.SampleEventTile(new Point2I(e.X, e.Y));
                    if (eventTile != null) {
                        eventTile.Room.RemoveEventTile(eventTile);
                    }
                }
                else if (e.Button == MouseButtons.Middle) {
                    // Select events.
                    EventTileDataInstance selectedEventTile = LevelDisplayControl.SampleEventTile(mousePos);

                    if (selectedEventTile != null) {
                        Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord);
                        EditorControl.PropertyGridControl.OpenProperties(selectedEventTile.Properties, selectedEventTile);
                    }
                    else {
                        EditorControl.PropertyGridControl.CloseProperties();
                    }
                }
            }
            else {
                if (e.Button == MouseButtons.Middle) {
                    // Select tiles.
                    TileDataInstance selectedTile = room.GetTile(tileCoord, editorControl.CurrentLayer);

                    if (selectedTile != null) {
                        Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord);
                        EditorControl.PropertyGridControl.OpenProperties(selectedTile.Properties, selectedTile);
                    }
                    else {
                        EditorControl.PropertyGridControl.CloseProperties();
                    }
                }
            }
        }
Beispiel #23
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public EventTile()
 {
     roomControl		= null;
     eventData		= null;
     position		= Vector2F.Zero;
     size			= Point2I.One;
     properties		= new Properties();
     collisionBox	= new Rectangle2I(0, 0, 16, 16);
 }
 public EventTileDataInstance(EventTileData tileData, Point2I position)
 {
     this.room				= null;
     this.position			= position;
     this.data				= tileData;
     this.modifiedProperties	= new Properties();
     this.modifiedProperties.PropertyObject = this;
     this.modifiedProperties.BaseProperties = tileData.Properties;
 }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public TileDataInstance()
 {
     this.room		= null;
     this.location	= Point2I.Zero;
     this.layer		= 0;
     this.tileData	= null;
     this.properties = new Properties();
     this.properties.PropertyObject = this;
 }
Beispiel #26
0
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public Slot(SlotGroup group, Point2I position, int width)
 {
     this.group			= group;
     this.position		= position;
     this.width			= width;
     this.connections	= new ISlotConnection[4];
     this.item			= null;
     this.disabled		= false;
 }
Beispiel #27
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public TileGrid(Point2I size, int layerCount)
        {
            this.size		= size;
            this.layerCount	= layerCount;
            this.tiles		= new TileGridTile[size.X, size.Y, layerCount];
            this.eventTiles	= new List<EventTileDataInstance>();

            Clear();
        }
Beispiel #28
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public Unit()
        {
            EnablePhysics();

            health			= 1;
            healthMax		= 1;
            direction		= Directions.Right;
            centerOffset	= new Point2I(8, 8);
        }
 public TileDataInstance(TileData tileData, int x, int y, int layer)
 {
     this.room		= null;
     this.location	= new Point2I(x, y);
     this.layer		= layer;
     this.tileData	= tileData;
     this.properties = new Properties();
     this.properties.PropertyObject = this;
     this.properties.BaseProperties = tileData.Properties;
 }
Beispiel #30
0
        //-----------------------------------------------------------------------------
        // Static Methods
        //-----------------------------------------------------------------------------

        // Clamp is exclusive.
        public static Point2I Clamp(Point2I value, Rectangle2I bounds)
        {
            if (bounds.IsEmpty)
            {
                return(Point2I.Zero);
            }
            return(new Point2I(
                       GMath.Clamp(value.X, bounds.Min.X, bounds.Max.X - 1),
                       GMath.Clamp(value.Y, bounds.Min.Y, bounds.Max.Y - 1)));
        }
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public EffectCreateSomariaBlock(Point2I tileLocation, float zPosition, ItemCane itemCane)
            : base(GameData.ANIM_EFFECT_SOMARIA_BLOCK_CREATE)
        {
            this.itemCane		= itemCane;
            this.tileLocation	= tileLocation;
            this.position		= (tileLocation * GameSettings.TILE_SIZE) + new Vector2F(8, 8);
            this.zPosition		= zPosition;

            Graphics.DepthLayer	= DepthLayer.EffectSomariaBlockPoof;
        }
Beispiel #32
0
        /** <summary> Parses the point. </summary> */
        public static Point2I Parse(string text)
        {
            Point2I value = Point2I.Zero;

            if (text.Length > 0)
            {
                if (text[0] == '(')
                {
                    text = text.Substring(1);
                }
                if (text[text.Length - 1] == ')')
                {
                    text = text.Substring(0, text.Length - 1);
                }

                int commaPos = text.IndexOf(',');
                if (commaPos == -1)
                {
                    commaPos = text.IndexOf(' ');
                }
                if (commaPos != -1)
                {
                    string strX = text.Substring(0, commaPos);
                    string strY = text.Substring(commaPos + 1);

                    try {
                        value.X = Int32.Parse(strX);
                        value.Y = Int32.Parse(strY);
                    } catch (FormatException e) {
                        throw e;
                    } catch (ArgumentNullException e) {
                        throw e;
                    } catch (OverflowException e) {
                        throw e;
                    }
                }
                else
                {
                    throw new FormatException();
                }
            }
            else
            {
                throw new ArgumentNullException();
            }

            return(value);
        }
Beispiel #33
0
 public static int FromPoint(Point2I point)
 {
     if (point.X > 0)
     {
         return(Directions.Right);
     }
     if (point.Y < 0)
     {
         return(Directions.Up);
     }
     if (point.X < 0)
     {
         return(Directions.Left);
     }
     if (point.Y > 0)
     {
         return(Directions.Down);
     }
     return(-1);
 }
Beispiel #34
0
        // Return a point the given angle.
        public static Point2I ToPoint(int angle)
        {
            Point2I point = Point2I.Zero;

            if (angle % 8 == SouthEast || angle % 8 == East || angle % 8 == NorthEast)
            {
                point.X = 1;
            }
            else if (angle % 8 >= NorthWest && angle % 8 <= SouthWest)
            {
                point.X = -1;
            }
            if (angle % 8 >= NorthEast && angle % 8 <= NorthWest)
            {
                point.Y = -1;
            }
            else if (angle % 8 >= SouthWest && angle % 8 <= SouthEast)
            {
                point.Y = 1;
            }
            return(point);
        }
Beispiel #35
0
 /** <summary> Constructs a copy of the specified point. </summary> */
 public Point2I(Point2I p)
 {
     this.X = p.X;
     this.Y = p.Y;
 }
Beispiel #36
0
 /** <summary> Returns a nonnegative random point less than the specified maximum. </summary> */
 public static Point2I NextPoint(Point2I maxPoint)
 {
     return(new Point2I(random.Next(maxPoint.X), random.Next(maxPoint.Y)));
 }
Beispiel #37
0
 /** <summary> Constructs a copy of the specified rectangle. </summary> */
 public Rectangle2I(Rectangle2I r)
 {
     this.Point = r.Point;
     this.Size  = r.Size;
 }
Beispiel #38
0
 /** <summary> Constructs a rectangle with the specified size. </summary> */
 public Rectangle2I(Point2I size)
 {
     this.Point = Point2I.Zero;
     this.Size  = size;
 }
Beispiel #39
0
 /** <summary> Constructs a rectangle with the specified size. </summary> */
 public Rectangle2I(int width, int height)
 {
     this.Point = Point2I.Zero;
     this.Size  = new Point2I(width, height);
 }
Beispiel #40
0
 /** <summary> Constructs a rectangle with the specified size. </summary> */
 public Rectangle2I(int size)
 {
     this.Point = Point2I.Zero;
     this.Size  = new Point2I(size);
 }
Beispiel #41
0
 /** <summary> Constructs a rectangle with the specified position and size. </summary> */
 public Rectangle2I(Point2I point, Point2I size)
 {
     this.Point = point;
     this.Size  = size;
 }
Beispiel #42
0
 /** <summary> Constructs a rectangle with the specified position and size. </summary> */
 public Rectangle2I(int x, int y, Point2I size)
 {
     this.Point = new Point2I(x, y);
     this.Size  = size;
 }
Beispiel #43
0
        //========== COLLISION ===========

        /** <summary> Returns true if the specified vector is colliding with this rectangle. </summary> */
        public bool Colliding(Point2I point)
        {
            return((point < Max) &&
                   (point >= Min));
        }
Beispiel #44
0
 /** <summary> Constructs a rectangle with the specified position and size. </summary> */
 public Rectangle2I(Point2I point, int width, int height)
 {
     this.Point = point;
     this.Size  = new Point2I(width, height);
 }
Beispiel #45
0
        //=========== CONTAINS ===========

        // Returns true if the specified vector is inside this rectangle.
        public bool Contains(Point2I point)
        {
            return((point < Max) &&
                   (point >= Min));
        }
Beispiel #46
0
 /** <summary> Stretches the corners of the rectangle out by the specified amount. </summary> */
 public void Inflate(Point2I amount)
 {
     Point -= amount;
     Size  += amount * 2;
 }
Beispiel #47
0
 /** <summary> Returns a rectangle with the corners stretched out by the specified amount. </summary> */
 public Rectangle2I Inflated(Point2I amount)
 {
     return(new Rectangle2I(Point - amount, Size + amount * 2));
 }
Beispiel #48
0
        //========= CONSTRUCTORS =========

        /** <summary> Constructs a rectangle with the specified position and size. </summary> */
        public Rectangle2I(int x, int y, int width, int height)
        {
            this.Point = new Point2I(x, y);
            this.Size  = new Point2I(width, height);
        }