Ejemplo n.º 1
0
        private bool CreateSpecialTile(out Tile toAdd)
        {
            toAdd = new SpecialTile(int.Parse(tsLblSelX.Text), int.Parse(tsLblSelY.Text));
            if (cmbSpecialType.SelectedIndex < 0 || cmbWarpAnim.SelectedIndex < 0 || lvTiles2.SelectedIndices.Count == 0)
            {
                return(false);
            }
            SpecialTileSpec type = (SpecialTileSpec)cmbSpecialType.SelectedIndex;

            object[] paramList;
            if (type == SpecialTileSpec.WARP)
            {
                int      outID, outX, outY;
                WarpAnim add = (WarpAnim)cmbWarpAnim.SelectedIndex;
                if (!int.TryParse(txtDestWarpX.Text, out outX) || !int.TryParse(txtDestWarpY.Text, out outY) || !int.TryParse(txtDestWarpMap.Text, out outID))
                {
                    MessageBox.Show("Error: please enter valid values for X, Y, and Dest");
                    return(false);
                }
                paramList    = new object[4];
                paramList[0] = outID; paramList[1] = outX; paramList[2] = outY; paramList[3] = add;
            }
            else
            {
                paramList = null;
            }

            (toAdd as SpecialTile).SetType(type, paramList);
            (toAdd as SpecialTile).Graphic = lvTiles2.SelectedIndices[0];
            return(true);
        }
Ejemplo n.º 2
0
 public void CopyTypeFrom(SpecialTile other)
 {
     this.Type   = other.Type;
     this.s_id   = other.s_id;
     this.d_map  = other.d_map;
     this.d_x    = other.d_x;
     this.d_y    = other.d_y;
     this.d_anim = other.d_anim;
 }
Ejemplo n.º 3
0
 public override void Load(Stream stream)
 {
     Type    = (SpecialTileSpec)stream.ReadByte();
     d_map   = stream.ReadInt();
     d_x     = stream.ReadInt();
     d_y     = stream.ReadInt();
     d_anim  = (WarpAnim)stream.ReadByte();
     density = (float)stream.ReadDouble();
     stream.ReadByte();             // Throwaway byte (Field.GraphicTile was written here)
     base.Load(stream);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Format - None/Wall/Jump: null; Grass/Water: spawn_id; Warp: dest_warp_id, dest_x, dest_y, warpanim;
        /// </summary>
        /// <param name="type">Type to set the special tyle as</param>
        /// <param name="list">See format in summary</param>
        public void SetType(SpecialTileSpec type, params object[] list)
        {
            //updates stored values when type == Type
            switch (type)
            {
            case SpecialTileSpec.NONE:
            case SpecialTileSpec.WALL:
            case SpecialTileSpec.JUMP:
                if (list != null)
                {
                    throw new ArgumentException("Invalid parameters for this TileType");
                }
                Type  = type;
                d_map = d_x = d_y = s_id = -1;
                break;

            case SpecialTileSpec.GRASS:
            case SpecialTileSpec.WATER:
            case SpecialTileSpec.CAVE:
                if (list == null || list.Length != 1 || !(list[0].GetType() == typeof(int)))
                {
                    throw new ArgumentException("Invalid parameters for this TileType");
                }
                Type  = type;
                d_map = d_x = d_y = -1;
                s_id  = (int)list[0];
                break;

            case SpecialTileSpec.WARP:                     //TODO: add in WarpAnim
                if (list == null || list.Length != 4 ||
                    list[0].GetType() != typeof(int) || list[1].GetType() != typeof(int) ||
                    list[2].GetType() != typeof(int) || list[3].GetType() != typeof(WarpAnim))
                {
                    throw new ArgumentException("Invalid parameters for this TileType");
                }
                Type   = type;
                s_id   = -1;
                d_map  = (int)list[0];
                d_x    = (int)list[1];
                d_y    = (int)list[2];
                d_anim = (WarpAnim)list[3];
                break;

            case SpecialTileSpec.NUM_VALS:
            default:
                throw new InvalidOperationException("TileType must be a valid value.");
            }
        }