Ejemplo n.º 1
0
 public Tile(int x, int y, TileSolidType solidType, Dictionary <string, string> properties = null)
 {
     X               = x;
     Y               = y;
     SolidType       = solidType;
     this.properties = properties;
 }
Ejemplo n.º 2
0
        public void SetTileAt(int x, int y, TileSolidType solidType, Dictionary <string, string> properties = null)
        {
            if (solidType == TileSolidType.PixelMask)
            {
                throw new Exception("Invalid TileSolidType, use setPixelMaskAt instead.");
            }

            grid[y * Width + x] = new Tile(x, y, solidType, properties);
        }
Ejemplo n.º 3
0
        //-----------------------------------------------------------------------------
        // Mutators
        //-----------------------------------------------------------------------------

        public void SetObject(IPropertyObject propertyObject)
        {
            this.propertyObject = propertyObject;

            // Determine the name of the base type of the property object.
            string baseTypeName = "Object";

            if (propertyObject is TileDataInstance)
            {
                baseTypeName = "Tile";
            }
            else if (propertyObject is EventTileDataInstance)
            {
                baseTypeName = "Event Tile";
            }
            else if (propertyObject is Room)
            {
                baseTypeName = "Room";
            }
            else if (propertyObject is Level)
            {
                baseTypeName = "Level";
            }
            else if (propertyObject is World)
            {
                baseTypeName = "World";
            }
            else if (propertyObject is Dungeon)
            {
                baseTypeName = "Dungeon";
            }
            else if (propertyObject is Script)
            {
                baseTypeName = "Script";
            }

            // Determine the type of the object.
            Type tileType = null;

            tile = null;
            if (propertyObject is TileDataInstance)
            {
                tile     = (TileDataInstance)propertyObject;
                tileType = tile.Type;
                if (tileType == null)
                {
                    tileType = typeof(Tile);
                }
            }
            else if (propertyObject is EventTileDataInstance)
            {
                tileType = ((EventTileDataInstance)propertyObject).Type;
                if (tileType == null)
                {
                    tileType = typeof(EventTile);
                }
            }

            // Only show Tile Interactions tab page for tiles.
            if (propertyObject is TileDataInstance)
            {
                if (!tabControl1.TabPages.Contains(tabPageTileInteractions))
                {
                    tabControl1.TabPages.Add(tabPageTileInteractions);
                }
            }
            else
            {
                if (tabControl1.TabPages.Contains(tabPageTileInteractions))
                {
                    tabControl1.TabPages.Remove(tabPageTileInteractions);
                }
            }

            // Setup the raw properties grid.
            rawPropertyGrid.OpenProperties(propertyObject);

            // Set the form title.
            if (tileType != null)
            {
                Text = String.Format("{0} Properties [{1}]", baseTypeName, tileType.Name);
                groupBoxCustomObjectControls.Text = tileType.Name;
            }
            else
            {
                Text = String.Format("{0} Properties", baseTypeName);
                groupBoxCustomObjectControls.Text = baseTypeName;
            }

            // Remove the custom control for the previous tile type.
            if (customControl != null)
            {
                panelCustomObjectControl.Controls.Remove(customControl);
                //groupBoxCustomObjectControls.Controls.Remove(customControl);
                customControl = null;
            }
            // Add the custom control for the tile type.
            if (tileType != null && customTileTypeControls.ContainsKey(tileType))
            {
                customControl = customTileTypeControls[tileType];
                customControl.Initialize(this);
                customControl.Dock = DockStyle.Fill;
                panelCustomObjectControl.Controls.Add(customControl);
                //groupBoxCustomObjectControls.Controls.Add(customControl);
            }

            // Setup events tab.
            eventsTab.SetupObject(propertyObject);

            // ID.
            textBoxId.Text = propertyObject.Properties.GetString("id", "");

            // Spawn type.
            checkBoxStartDisabled.Checked = !propertyObject.Properties.GetBoolean("enabled", true);
            checkBoxPoofEffect.Checked    = propertyObject.Properties.GetBoolean("spawn_poof_effect", false);

            if (tile != null)
            {
                // Size.
                numberBoxWidth.Value  = tile.Size.X;
                numberBoxHeight.Value = tile.Size.Y;

                // Solid type.
                TileSolidType solidType = (TileSolidType)
                                          tile.Properties.GetInteger("solidity", (int)TileSolidType.NotSolid);
                ComboBoxItem <TileSolidType> .SelectComboBoxItem(comboBoxSolidType, solidType);

                // Ledge Direction.
                int ledgeDir = tile.Properties.GetInteger("ledge_direction", Directions.Down);
                ComboBoxItem <int> .SelectComboBoxItem(comboBoxLedgeDirection, ledgeDir);

                // Collision model.
                ComboBoxItem <CollisionModel> .SelectComboBoxItem(comboBoxCollisionModel, tile.CollisionModel);

                // Environment type.
                TileEnvironmentType envType = (TileEnvironmentType)
                                              tile.Properties.GetInteger("environment_type", (int)TileEnvironmentType.Normal);
                ComboBoxItem <TileEnvironmentType> .SelectComboBoxItem(comboBoxMovementType, envType);

                // Reset condition
                ComboBoxItem <TileResetCondition> .SelectComboBoxItem(comboBoxResetCondition, tile.ResetCondition);

                //  Interactions.
                checkBoxCuttable.Checked            = tile.Flags.HasFlag(TileFlags.Cuttable);
                checkBoxPickupable.Checked          = tile.Flags.HasFlag(TileFlags.Pickupable);
                checkBoxMovable.Checked             = tile.Flags.HasFlag(TileFlags.Movable);
                checkBoxBurnable.Checked            = tile.Flags.HasFlag(TileFlags.Burnable);
                checkBoxBombable.Checked            = tile.Flags.HasFlag(TileFlags.Bombable);
                checkBoxDigable.Checked             = tile.Flags.HasFlag(TileFlags.Digable);
                checkBoxBoomerangable.Checked       = tile.Flags.HasFlag(TileFlags.Boomerangable);
                checkBoxSwitchable.Checked          = tile.Flags.HasFlag(TileFlags.Switchable);
                checkBoxBreakOnSwitch.Checked       = !tile.Flags.HasFlag(TileFlags.SwitchStays);
                checkBoxMoveOnce.Checked            = tile.Properties.GetBoolean("move_once", false);
                comboBoxSwordLevel.SelectedIndex    = tile.Properties.GetInteger("cuttable_sword_level", 0);
                comboBoxBraceletLevel.SelectedIndex = tile.Properties.GetInteger("pickupable_bracelet_level", 0);
                checkBoxDisableOnDestroy.Checked    = tile.Properties.GetBoolean("disable_on_destroy", false);

                // Move direction.
                ComboBoxItem <int> .SelectComboBoxItem(comboBoxMoveDirection,
                                                       tile.Properties.GetInteger("move_direction", -1));
            }

            // Setup custom controls.
            if (customControl != null)
            {
                customControl.SetupObject(propertyObject);
            }
        }