예제 #1
0
        public void setShape(FxShape shape)
        {
            mShape           = shape;
            activate.Checked = shape.Active;
            switch (mShape.Effect)
            {
            case FxShape.FxEffect.FLOOR_MIRROR:
                effect.SelectedIndex = 0;
                break;

            case FxShape.FxEffect.WALL_MIRROR:
                effect.SelectedIndex = 1;
                break;

            case FxShape.FxEffect.PARTICLE_BARRIER:
                effect.SelectedIndex = 2;
                break;
            }
            setActive(mShape.Active);
            strength.Value  = shape.Strength;
            depOnRP.Checked = shape.DependingOnRoomPosition;
            if (mShape.Active)
            {
                setEffect(mShape.Effect);
            }
        }
예제 #2
0
        public Room duplicate(string name)
        {
            Room rm = new Room();

            rm.mData              = mData;
            rm.Name               = name;
            rm.Size               = Size;
            rm.ScrollOffset       = ScrollOffset;
            rm.Depthmap           = Depthmap;
            rm.Zoom               = Zoom;
            rm.Background         = Background;
            rm.ParallaxBackground = ParallaxBackground;
            rm.DoubleWalkmap      = DoubleWalkmap;
            rm.FXShapes           = new ArrayList(FXShapes.Count);
            for (int i = 0; i < FXShapes.Count; ++i)
            {
                FxShape shape = (FxShape)FXShapes[i];
                rm.FXShapes.Add(shape.Clone());
            }
            rm.HasInventory = HasInventory;
            rm.InvPos       = InvPos;
            rm.InvScale     = InvScale;
            rm.InvSize      = InvSize;
            rm.InvSpacing   = InvSpacing;
            rm.Walkmap      = (WalkMapEntry[, ])Walkmap.Clone();
            rm.Lighting     = Lighting;
            foreach (ObjectInstance inst in Objects)
            {
                ObjectInstance newinst = inst.duplicate(Name, rm.Name);
                rm.Objects.Add(newinst);
            }
            foreach (CharacterInstance inst in Characters)
            {
                CharacterInstance newinst = inst.duplicate(rm.Name);
                rm.Characters.Add(newinst);
            }
            Script roomscr = mData.getScript(Script.Type.ROOM, Name);

            mData.addScript(roomscr.duplicate(rm.Name));
            for (int x = 0; x <= Walkmap.GetUpperBound(0); ++x)
            {
                for (int y = 0; y <= Walkmap.GetUpperBound(1); ++y)
                {
                    if (Walkmap[x, y].hasScript)
                    {
                        Script wmscr = mData.getScript(Script.Type.WALKMAP, Script.toScriptName(x, y, Name, mData));
                        mData.addScript(wmscr.duplicate(Script.toScriptName(x, y, rm.Name, mData)));
                    }
                }
            }
            return(rm);
        }
예제 #3
0
        public Object Clone()
        {
            FxShape shape = new FxShape();

            shape.Active = Active;
            shape.DependingOnRoomPosition = DependingOnRoomPosition;
            shape.Effect       = Effect;
            shape.Room         = Room;
            shape.Depth        = Depth;
            shape.MirrorOffset = MirrorOffset;
            shape.Strength     = Strength;
            shape.Positions    = (Vec2i[])Positions.Clone();
            return(shape);
        }
예제 #4
0
 public void setShape(FxShape shape)
 {
     mShape = shape;
     activate.Checked = shape.Active;
     switch (mShape.Effect)
     {
         case FxShape.FxEffect.FLOOR_MIRROR:
             effect.SelectedIndex = 0;
             break;
         case FxShape.FxEffect.WALL_MIRROR:
             effect.SelectedIndex = 1;
             break;
         case FxShape.FxEffect.PARTICLE_BARRIER:
             effect.SelectedIndex = 2;
             break;
     }
     setActive(mShape.Active);
     strength.Value = shape.Strength;
     depOnRP.Checked = shape.DependingOnRoomPosition;
     if (mShape.Active)
         setEffect(mShape.Effect);
 }
예제 #5
0
        public Room(AdvData data)
        {
            mData              = data;
            Name               = "Room" + (data.NumRooms + 1);
            Size               = new Vec2i(data.WindowXRes, data.Settings.Resolution.y);
            Depthmap           = new Vec2i(5, 10);
            Zoom               = 3;
            Background         = "";
            ParallaxBackground = "";
            FXShapes           = new ArrayList();
            for (int i = 0; i < 3; ++i)
            {
                FxShape fs = new FxShape(i);
                FXShapes.Add(fs);
            }
            Vec2i wmsize = data.Settings.Resolution / data.WalkGridSize;

            wmsize.x  *= 3 * 2;
            wmsize.y  *= 2 * 2;
            Walkmap    = new WalkMapEntry[wmsize.x, wmsize.y];
            Lighting   = Color.White;
            InvScale   = new Vec2f(1.0f, 1.0f);
            InvSpacing = 10;
        }
예제 #6
0
 private void setEffect(FxShape.FxEffect effect)
 {
     if (effect == FxShape.FxEffect.WALL_MIRROR)
     {
         position.Enabled = true;
         depOnRP.Enabled = true;
     }
     else
     {
         position.Enabled = false;
         depOnRP.Enabled = false;
     }
     if (effect == FxShape.FxEffect.PARTICLE_BARRIER)
     {
         strength.Enabled = false;
     }
     else
     {
         strength.Enabled = true;
     }
 }
 protected bool readObjectsLoop(StreamReader rdr, int ver_major, int ver_minor, TreeNode parent)
 {
     string str;
     while (!rdr.EndOfStream)
     {
         str = rdr.ReadLine();
         if (rdr.EndOfStream)
             return true;
         if (str.Length < 2)
             continue;
         string rest = str.Substring(2);
         //TODO check
         string[] typename = new string[2];
         int idx = rest.IndexOf(' ');
         typename[0] = rest.Substring(0, idx);
         typename[1] = rest.Substring(idx+1);
         //ITEM
         if (typename[0] == "Item")
         {
             Item it = new Item(mAdv);
             it.Name = typename[1];
             int numStates = STATES_MAX;
             int delim = 2;
             if (ver_major == 2 || (ver_major == 3 && ver_minor == 0))
             {
                 numStates = 1;
                 delim = 1;
             }
             for (int state = 0; state < numStates; ++state)
             {
                 ItemState ist;
                 ist.frames = new System.Collections.ArrayList();
                 ist.scripts = new System.Collections.ArrayList();
                 for (int frames = 0; frames < FRAMES_MAX; ++frames)
                 {
                     str = rdr.ReadLine();
                     if (str.Length > 0)
                     {
                         if (delim == 2)
                         {
                             string[] split = str.Split(';');
                             ist.frames.Add(split[0]);
                             if (split.Length > 1)
                                 ist.scripts.Add(split[1].Replace('\xaf', ';'));
                             else
                                 ist.scripts.Add("");
                         }
                         else
                         {
                             ist.frames.Add(str.Substring(0, str.Length + 1 - delim));
                             ist.scripts.Add("");
                         }
                     }
                 }
                 str = rdr.ReadLine();
                 ist.fpsDivider = Convert.ToInt32(str);
                 it.Add(ist);
             }
             if (ver_major == 2 || (ver_major == 3 && ver_minor == 0))
             {
                 for (int i = 1; i < STATES_MAX; ++i)
                 {
                     ItemState ist;
                     ist.frames = new System.Collections.ArrayList();
                     ist.scripts = new System.Collections.ArrayList();
                     ist.fpsDivider = 20;
                     it.Add(ist);
                 }
             }
             mAdv.addItem(it);
         }
         //OBJECT
         else if (typename[0] == "Object")
         {
             AdvObject obj = mAdv.getObject(typename[1]);
             if (obj == null)
             {
                 obj = new AdvObject(mAdv);
                 obj.Name = typename[1];
                 mAdv.addObject(obj);
             }
             str = rdr.ReadLine();
             int x = Convert.ToInt32(str);
             str = rdr.ReadLine();
             int y = Convert.ToInt32(str);
             obj.setSize(0, new Vec2i(x, y));
             str = rdr.ReadLine();
             x = Convert.ToInt32(str);
             obj.Lighten = x != 0;
             for (int state = 0; state < STATES_MAX; ++state)
             {
                 ObjectState os = new ObjectState();
                 os.fpsDivider = readExtendedFrames(rdr, os.frames);
                 obj.Add(os);
             }
         }
         //CHARACTER
         else if (typename[0] == "Character")
         {
             AdvCharacter chr = new AdvCharacter(mAdv);
             chr.Name = typename[1];
             str = rdr.ReadLine();
             chr.TextColor = Convert.ToUInt32(str);
             chr.WalkSpeed = Convert.ToInt32(rdr.ReadLine());
             if (ver_major > 0)
             {
                 int tmp = Convert.ToInt32(rdr.ReadLine());
                 chr.NoZoom = tmp != 0;
                 if (ver_major > 3 || (ver_major == 3 && ver_minor > 0))
                 {
                     tmp = Convert.ToInt32(rdr.ReadLine());
                     chr.RealLeftAnimations = tmp != 0;
                 }
                 tmp = Convert.ToInt32(rdr.ReadLine());
                 chr.MemoryReistent = tmp != 0;
                 tmp = Convert.ToInt32(rdr.ReadLine());
                 chr.Ghost = tmp != 0;
                 chr.Walksound = rdr.ReadLine();
             }
             if (ver_major >= 3)
             {
                 str = rdr.ReadLine();
                 string[] names = str.Split(';');
                 for (int i = 0; i < names.Length - 1; ++i)
                 {
                     chr.setStateName(16 + i, names[i]);
                 }
             }
             else
             {
                 for (int i = 0; i < 20; ++i)
                     chr.setStateName(16 + i, "");
             }
             if (ver_major > 0)
             {
                 chr.Font = Convert.ToInt32(rdr.ReadLine());
                 chr.Zoom = Convert.ToInt32(rdr.ReadLine());
             }
             else
                 chr.Zoom = 100;
             for (int state = 0; state < CHAR_STATES_MAX; ++state)
             {
                 CharacterState cs = new CharacterState();
                 cs.size.x = Convert.ToInt32(rdr.ReadLine());
                 cs.size.y = Convert.ToInt32(rdr.ReadLine());
                 cs.basepoint.x = Convert.ToInt32(rdr.ReadLine());
                 cs.basepoint.y = Convert.ToInt32(rdr.ReadLine());
                 cs.fpsDivider = readExtendedFrames(rdr, cs.frames);
                 chr.Add(cs);
             }
             mAdv.addCharacter(chr);
         }
         //CHARACTER INSTANCE
         else if (typename[0] == "Rcharacter")
         {
             string chr = rdr.ReadLine();
             CharacterInstance charinst = new CharacterInstance(mAdv.getCharacter(chr), mAdv);
             if (charinst.Character == null)
                 throw new UnexpectedValueException("No character for character instance found");
             charinst.Name = typename[1];
             charinst.Room = rdr.ReadLine();
             Vec2i pos;
             pos.x = Convert.ToInt32(rdr.ReadLine());
             pos.y = Convert.ToInt32(rdr.ReadLine());
             charinst.RawPosition = pos;
             charinst.LookDir = Convert.ToInt32(rdr.ReadLine());
             charinst.Unmovable = Convert.ToInt32(rdr.ReadLine()) == 0;
             charinst.Locked = Convert.ToInt32(rdr.ReadLine()) != 0;
             if (!mAdv.CharacterInstances.ContainsKey(charinst.Room.ToLower()))
             {
                 mAdv.CharacterInstances[charinst.Room.ToLower()] = new System.Collections.ArrayList();
             }
             mAdv.CharacterInstances[charinst.Room.ToLower()].Add(charinst);
         }
         //ROOM
         else if (typename[0] == "Room")
         {
             Room room = new Room();
             room.Data = mAdv;
             room.Name = typename[1];
             room.Size.x = Convert.ToInt32(rdr.ReadLine());
             room.Size.y = Convert.ToInt32(rdr.ReadLine());
             room.ScrollOffset.x = Convert.ToInt32(rdr.ReadLine());
             room.ScrollOffset.y = Convert.ToInt32(rdr.ReadLine());
             room.Depthmap.x = Convert.ToInt32(rdr.ReadLine());
             room.Depthmap.y = Convert.ToInt32(rdr.ReadLine());
             room.Zoom = Convert.ToInt32(rdr.ReadLine());
             room.Background = rdr.ReadLine();
             room.ParallaxBackground = rdr.ReadLine();
             room.FXShapes = new System.Collections.ArrayList();
             if (ver_major >= 3)
             {
                 int tmp = Convert.ToInt32(rdr.ReadLine());
                 room.DoubleWalkmap = tmp != 0;
             }
             else
             {
                 room.DoubleWalkmap = false;
             }
             if (ver_major > 3 || (ver_major == 3 && ver_minor >= 5))
             {
                 str = rdr.ReadLine();
                 string[] col = str.Split(';');
                 room.Lighting = Color.FromArgb(Convert.ToInt32(col[0]), Convert.ToInt32(col[1]), Convert.ToInt32(col[2]));
             }
             else
                 room.Lighting = Color.FromArgb(255, 255, 255);
             if (ver_major >= 3 || (ver_major == 2 && ver_minor >= 8))
             {
                 for (int i = 0; i < FXSHAPES_MAX; ++i)
                 {
                     FxShape shape = new FxShape();
                     str = rdr.ReadLine();
                     string[] split = str.Split(';');
                     shape.Active = Convert.ToInt32(split[0]) != 0;
                     shape.DependingOnRoomPosition = Convert.ToInt32(split[1]) != 0;
                     shape.Effect = (FxShape.FxEffect)Convert.ToInt32(rdr.ReadLine());
                     shape.Room = rdr.ReadLine();
                     shape.Depth = Convert.ToInt32(rdr.ReadLine());
                     shape.MirrorOffset.x = Convert.ToInt32(rdr.ReadLine());
                     shape.MirrorOffset.y = Convert.ToInt32(rdr.ReadLine());
                     shape.Strength = Convert.ToInt32(rdr.ReadLine());
                     str = rdr.ReadLine();
                     split = str.Split(';');
                     for (int pos = 0; pos < 4; ++pos)
                     {
                         shape.Positions[pos].x = Convert.ToInt32(split[2 * pos]);
                         shape.Positions[pos].y = Convert.ToInt32(split[2 * pos + 1]);
                     }
                     room.FXShapes.Add(shape);
                 }
             }
             else
             {
                 for (int i = 0; i < FXSHAPES_MAX; ++i)
                 {
                     FxShape fs = new FxShape(i);
                     room.FXShapes.Add(fs);
                 }
             }
             //inventory
             room.HasInventory = Convert.ToInt32(rdr.ReadLine()) != 0;
             str = rdr.ReadLine();
             string[] inventory = str.Split(';');
             room.InvPos.x = Convert.ToInt32(inventory[0]);
             room.InvPos.y = Convert.ToInt32(inventory[1]);
             room.InvSize.x = Convert.ToInt32(inventory[2]);
             room.InvSize.y = Convert.ToInt32(inventory[3]);
             if (ver_major < 3)
             {
                 if (room.InvSize.x == 0 || room.InvSize.y == 0)
                     room.HasInventory = false;
                 else
                     room.HasInventory = true;
             }
             System.Globalization.NumberFormatInfo info = new System.Globalization.NumberFormatInfo();
             info.NumberDecimalSeparator = ",";
             try
             {
                 room.InvScale.x = Single.Parse(inventory[4], info);
                 room.InvScale.y = Single.Parse(inventory[5], info);
             }
             catch (Exception)
             {
                 info.NumberDecimalSeparator = ".";
                 room.InvScale.x = Single.Parse(inventory[4], info);
                 room.InvScale.y = Single.Parse(inventory[5], info);
             }
             if (ver_major > 3 || (ver_major == 3 && ver_minor >= 5)){
                 room.InvSpacing = Convert.ToInt32(inventory[6]);
             }
             else
                 room.InvSpacing = 10;
             //walkmap
             str = rdr.ReadLine();
             int walkmapX = 32;
             int walkGridSize = mAdv.Settings.Resolution.x / walkmapX;
             int walkmapY = mAdv.Settings.Resolution.y / walkGridSize;
             walkmapX *= 3;
             walkmapY *= 2;
             int walkmapXOut = walkmapX * 2;
             int walkmapYOut = walkmapY * 2;
             if (ver_major >= 3)
             {
                 walkmapX *= 2;
                 walkmapY *= 2;
             }
             room.Walkmap = new Room.WalkMapEntry[walkmapXOut, walkmapYOut];
             for (int i = 0; i < walkmapX * walkmapY; ++i)
             {
                 int x = i / walkmapY;
                 int y = i % walkmapY;
                 room.Walkmap[x, y].isFree = str[2 * i] != '1';
                 room.Walkmap[x, y].hasScript = str[2 * i + 1] == '1';
             }
             if (mAdv.CharacterInstances.ContainsKey(room.Name.ToLower()))
                 room.Characters = mAdv.CharacterInstances[room.Name.ToLower()];
             mAdv.addRoom(room);
             mLastRoom = room;
         }
         //OBJECT INSTANCE
         else if (typename[0] == "Roomobject")
         {
             string obj = rdr.ReadLine();
             AdvObject newobj = mAdv.getObject(obj);
             if (newobj == null)
             {
                 //this happens during room import
                 newobj = new AdvObject(mAdv);
                 newobj.Name = obj;
                 mAdv.addObject(newobj);
                 //auto add objects
                 if (parent != null)
                 {
                     TreeNode tno = new TreeNode(obj);
                     tno.Tag = ResourceID.OBJECT;
                     tno.ImageIndex = Utilities.ResourceIDToImageIndex((ResourceID)tno.Tag);
                     tno.SelectedImageIndex = tno.ImageIndex;
                     parent.Nodes.Add(tno);
                 }
             }
             ObjectInstance objinst = new ObjectInstance(mAdv.getObject(obj), mAdv);
             objinst.Name = typename[1];
             objinst.Position.x = Convert.ToInt32(rdr.ReadLine());
             objinst.Position.y = Convert.ToInt32(rdr.ReadLine());
             objinst.State = Convert.ToInt32(rdr.ReadLine());
             objinst.Layer = Convert.ToInt32(rdr.ReadLine());
             objinst.Depth = Convert.ToInt32(rdr.ReadLine())*2;
             if (ver_major > 3 || (ver_major == 3 && ver_minor >= 5))
             {
                 objinst.Depth = Convert.ToInt32(rdr.ReadLine());
             }
             objinst.Locked = Convert.ToInt32(rdr.ReadLine()) != 0;
             mLastRoom.Objects.Add(objinst);
         }
     }
     return true;
 }
예제 #8
0
 void RoomDlg_MouseDown(object sender, MouseEventArgs e)
 {
     Point click = new Point(e.X, e.Y);
     Vec2i pos = new Vec2i(e.X, e.Y);
     mMousePos = pos;
     if (mMode == ViewMode.Objects)
     {
         bool dragDepthFound = false;
         foreach (ObjectInstance obj in mRoom.Objects)
         {
             if (obj.Layer != 1)
                 continue;
             Vec2i depthcenter = new Vec2i(obj.Position.x, obj.Depth * mData.WalkGridSize/2 - mData.WalkGridSize / 4);
             if ((depthcenter - pos - mRoom.ScrollOffset).length() <= 5)
             {
                 mDragObject = obj;
                 mDragOffset = depthcenter - pos;
                 mDragDepth = true;
                 dragDepthFound = true;
                 break;
             }
         }
         if (!dragDepthFound)
         {
             mDragDepth = false;
             bool dragSecond = e.Button == MouseButtons.Middle;
             mDragObject = getObjectAt(pos + mRoom.ScrollOffset, dragSecond);
             mControl.SelectedObject = mDragObject;
             if (mDragObject != null)
             {
                 mDragOffset = mDragObject.getPosition() - pos;
             }
         }
         if (e.Button == MouseButtons.Right)
         {
             if (mDragObject != null)
             {
                 if (mDragObject.GetType() == typeof(ObjectInstance))
                     menuObject.Items[2].Text = "Show in Object window";
                 else
                     menuObject.Items[2].Text = "Show in Character window";
                 menuObject.Show(this, click);
             }
             else
                 menuRemoveBackground.Show(this, click);
         }
     }
     else if (mMode == ViewMode.Walkmap)
     {
         if (e.Button == MouseButtons.Right)
         {
             Vec2i cp = clickToWalkmap(e.X, e.Y);
             ToolStripMenuItem it = menuWalkmap.Items[9] as ToolStripMenuItem;
             if (mRoom.Walkmap[cp.x, cp.y].hasScript)
             {
                 it.Enabled = true;
             }
             else
                 it.Enabled = false;
             menuWalkmap.Show(this, click);
             return;
         }
         modifyWalkmap(pos.x, pos.y);
         mDragDepth = true;
     }
     else if (mMode == ViewMode.Deepmap)
     {
         int depth = (e.Y+mData.WalkGridSize/2+mRoom.ScrollOffset.y) / mData.WalkGridSize;
         if (depth == mRoom.Depthmap.x)
             mDragDepth = true;
         if (depth == mRoom.Depthmap.y)
             mDragDepthBottom = true;
     }
     else if (mMode == ViewMode.Inventory)
     {
         if (mRoom.HasInventory)
         {
             if (e.Button == MouseButtons.Right)
             {
                 menuInventory.Show(this, click);
             }
             int sizex = mRoom.InvSize.x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30;
             int sizey = mRoom.InvSize.y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5;
             int ydown = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey;
             int xmiddle = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex / 2;
             int ymiddle = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey / 2;
             int xright = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex;
             int xleft = -mRoom.ScrollOffset.x + mRoom.InvPos.x;
             int yup = -mRoom.ScrollOffset.y + mRoom.InvPos.y;
             //bottom
             if (e.X >= xmiddle - 15 && e.X <= xmiddle + 15)
             {
                 if (e.Y <= ydown + 3 && e.Y >= ydown - 5 - 3)
                 {
                     mDragMode = DragMode.DragBottom;
                     mDragOffset.y = e.Y - ydown;
                 }
                 else
                     mDragMode = DragMode.DragNone;
             }
             //right
             else if (e.Y >= ymiddle - 15 && e.Y <= ymiddle + 15)
             {
                 if (e.X <= xright + 3 && e.X >= xright - 5 - 3)
                 {
                     mDragMode = DragMode.DragRight;
                     mDragOffset.x = e.X - xright;
                 }
                 else
                     mDragMode = DragMode.DragNone;
             }
             //corner
             else if (e.X >= xright - 11 - 3 && e.X <= xright + 3)
             {
                 if (e.Y >= ydown - 11 - 3 && e.Y <= ydown + 3)
                     mDragMode = DragMode.DragCorner;
                 else
                     mDragMode = DragMode.DragNone;
             }
             else
                 mDragMode = DragMode.DragNone;
             //elsewhere on inventory
             if (mDragMode == DragMode.DragNone && e.X >= xleft && e.X <= xright)
             {
                 if (e.Y >= yup && e.Y <= ydown)
                 {
                     mDragMode = DragMode.DragPosition;
                     mDragOffset = new Vec2i(e.X, e.Y) - mRoom.InvPos;
                 }
             }
         }
         else
         {
             if (e.Button == MouseButtons.Right)
             {
                 return;
             }
             mRoom.InvPos = new Vec2i(e.X + mRoom.ScrollOffset.x, e.Y + mRoom.ScrollOffset.y);
             mRoom.InvScale = new Vec2f(1.0f, 1.0f);
             mRoom.HasInventory = true;
             mDragMode = DragMode.DragCorner;
             this.Cursor = Cursors.SizeNWSE;
         }
     }
     else if (mMode == ViewMode.Specialfx)
     {
         Vec2i clickpos = pos;
         clickpos += mRoom.ScrollOffset;
         for (int shapeidx = 0; shapeidx < mRoom.FXShapes.Count; ++shapeidx)
         {
             FxShape shape = (FxShape)mRoom.FXShapes[shapeidx];
             if (!shape.Active)
                 continue;
             Vec2i center = new Vec2i();
             for (int i = 0; i < shape.Positions.Length; ++i)
             {
                 if ((shape.Positions[i] - clickpos).length() <= 4)
                 {
                     mDragMode = DragMode.DragCorner;
                     mDraggingShape = shape;
                     mShapeIndex = i;
                     mDragOffset = clickpos - center;
                     return;
                 }
                 center += shape.Positions[i];
             }
             center /= shape.Positions.Length;
             if ((center - clickpos).length() <= 10)
             {
                 mDragMode = DragMode.DragPosition;
                 mDraggingShape = shape;
                 mDragOffset = pos;
                 break;
             }
             Vec2i depthcenter = new Vec2i(center.x, (int)((shape.Depth + 0.5f) * mData.WalkGridSize - mData.WalkGridSize / 2));
             if ((depthcenter - clickpos).length() <= 5)
             {
                 mDragMode = DragMode.DragBottom;
                 mDraggingShape = shape;
                 mDragOffset = depthcenter - pos;
                 return;
             }
         }
     }
 }
예제 #9
0
        void writeObjects(Stream strm)
        {
            StreamWriter swr = new StreamWriter(strm, Encoding.GetEncoding(1252));

            swr.WriteLine("3.6 Point&Click Project File. DO NOT MODIFY!!");
            swr.WriteLine();
            for (int i = 0; i < STATES_MAX; ++i)
            {
                for (int frames = 0; frames < FRAMES_MAX; ++frames)
                {
                    string[] data = mData.Cursor.getFrame(i, frames);
                    if (data != null)
                    {
                        swr.WriteLine(data[0]);
                    }
                    else
                    {
                        swr.WriteLine();
                    }
                }
                swr.WriteLine(mData.Cursor.getCommand(i) + 1);
                swr.WriteLine(mData.Cursor.getFPSDivider(i));
                swr.WriteLine(mData.Cursor.getHotspot(i).x);
                swr.WriteLine(mData.Cursor.getHotspot(i).y);
                swr.WriteLine(mData.Cursor.getItemOffset(i).x);
                swr.WriteLine(mData.Cursor.getItemOffset(i).y);
            }
            foreach (KeyValuePair <string, Item> item in mData.Items)
            {
                swr.Write("//Item ");
                swr.WriteLine(item.Value.Name);
                for (int i = 0; i < STATES_MAX; ++i)
                {
                    for (int frames = 0; frames < FRAMES_MAX; ++frames)
                    {
                        string[] data = item.Value.getFrame(i, frames);
                        if (data != null)
                        {
                            swr.Write(data[0]);
                        }
                        //else
                        //    swr.Write();
                        swr.Write(';');
                        string scr = item.Value.getScript(i, frames);
                        swr.WriteLine(scr != null ? scr.Replace(';', '\xaf') : "");
                    }
                    swr.WriteLine(item.Value.getFPSDivider(i));
                }
            }
            foreach (KeyValuePair <string, AdvObject> obj in mData.Objects)
            {
                swr.Write("//Object ");
                swr.WriteLine(obj.Value.Name);
                swr.WriteLine(obj.Value.getSize(0).x);
                swr.WriteLine(obj.Value.getSize(0).y);
                swr.WriteLine(obj.Value.Lighten ? -1 : 0);
                for (int i = 0; i < STATES_MAX; ++i)
                {
                    for (int frames = 0; frames < FRAMES2_MAX; ++frames)
                    {
                        string[] data = obj.Value.getFrame(i, frames);
                        if (data == null || data.Length == 0)
                        {
                            swr.WriteLine();
                            swr.WriteLine();
                        }
                        else if (data.Length == 1)
                        {
                            swr.WriteLine(data[0]);
                            swr.WriteLine();
                        }
                        else
                        {
                            swr.WriteLine(data[0]);
                            swr.WriteLine(data[1]);
                        }
                        swr.Write(obj.Value.getFramePartOffset(i, frames, 0).x);
                        swr.Write(';');
                        swr.Write(obj.Value.getFramePartOffset(i, frames, 0).y);
                        swr.Write(';');
                        swr.Write(obj.Value.getFramePartOffset(i, frames, 1).x);
                        swr.Write(';');
                        swr.Write(obj.Value.getFramePartOffset(i, frames, 1).y);
                        swr.Write(';');
                        string scr = obj.Value.getScript(i, frames);
                        swr.WriteLine(scr != null ? scr.Replace(';', '\xaf') : "");
                    }
                    swr.WriteLine(obj.Value.getFPSDivider(i));
                }
            }
            foreach (KeyValuePair <string, AdvCharacter> charact in mData.Characters)
            {
                AdvCharacter chr = charact.Value;
                swr.Write("//Character ");
                swr.WriteLine(chr.Name);
                swr.WriteLine(chr.TextColor);
                swr.WriteLine(chr.WalkSpeed);
                swr.WriteLine(chr.NoZoom ? -1 : 0);
                swr.WriteLine(chr.RealLeftAnimations ? -1 : 0);
                swr.WriteLine(chr.MemoryReistent ? -1 : 0);
                swr.WriteLine(chr.Ghost ? -1 : 0);
                swr.WriteLine(chr.Walksound);
                for (int i = 0; i < 20; ++i)
                {
                    swr.Write(chr.getStateName(16 + i, false));
                    swr.Write(';');
                }
                swr.WriteLine();
                swr.WriteLine(chr.Font);
                swr.WriteLine(chr.Zoom);
                for (int i = 0; i < CHAR_STATES_MAX; ++i)
                {
                    swr.WriteLine(chr.getSize(i).x);
                    swr.WriteLine(chr.getSize(i).y);
                    swr.WriteLine(chr.getHotspot(i).x);
                    swr.WriteLine(chr.getHotspot(i).y);
                    for (int frames = 0; frames < FRAMES2_MAX; ++frames)
                    {
                        string[] data = chr.getFrame(i, frames);
                        if (data == null || data.Length == 0)
                        {
                            swr.WriteLine();
                            swr.WriteLine();
                        }
                        else if (data.Length == 1)
                        {
                            swr.WriteLine(data[0]);
                            swr.WriteLine();
                        }
                        else
                        {
                            swr.WriteLine(data[0]);
                            swr.WriteLine(data[1]);
                        }
                        swr.Write(chr.getFramePartOffset(i, frames, 0).x);
                        swr.Write(';');
                        swr.Write(chr.getFramePartOffset(i, frames, 0).y);
                        swr.Write(';');
                        swr.Write(chr.getFramePartOffset(i, frames, 1).x);
                        swr.Write(';');
                        swr.Write(chr.getFramePartOffset(i, frames, 1).y);
                        swr.Write(';');
                        string scr = chr.getScript(i, frames);
                        swr.WriteLine(scr != null ? scr.Replace(';', '\xaf') : "");
                    }
                    swr.WriteLine(chr.getFPSDivider(i));
                }
            }
            foreach (KeyValuePair <string, ArrayList> charact in mData.CharacterInstances)
            {
                foreach (CharacterInstance chr in charact.Value)
                {
                    swr.Write("//Rcharacter ");
                    swr.WriteLine(chr.Name);
                    swr.WriteLine(chr.Character.Name);
                    swr.WriteLine(chr.Room);
                    swr.WriteLine(chr.RawPosition.x);
                    swr.WriteLine(chr.RawPosition.y);
                    swr.WriteLine(chr.LookDir);
                    swr.WriteLine(chr.Unmovable ? 0 : -1);
                    swr.WriteLine(chr.Locked ? -1 : 0);
                }
            }
            foreach (KeyValuePair <string, Room> rom in mData.Rooms)
            {
                Room room = rom.Value;
                swr.Write("//Room ");
                swr.WriteLine(room.Name);
                swr.WriteLine(room.Size.x);
                swr.WriteLine(room.Size.y);
                swr.WriteLine(room.ScrollOffset.x);
                swr.WriteLine(room.ScrollOffset.y);
                swr.WriteLine(room.Depthmap.x);
                swr.WriteLine(room.Depthmap.y);
                swr.WriteLine(room.Zoom);
                swr.WriteLine(room.Background);
                swr.WriteLine(room.ParallaxBackground);
                swr.WriteLine(room.DoubleWalkmap ? -1 : 0);
                swr.Write(room.Lighting.R); swr.Write(";");
                swr.Write(room.Lighting.G); swr.Write(";");
                swr.WriteLine(room.Lighting.B);
                for (int i = 0; i < FXSHAPES_MAX; ++i)
                {
                    FxShape shape = (FxShape)room.FXShapes[i];
                    swr.Write(shape.Active ? -1 : 0);
                    swr.Write(';');
                    swr.WriteLine(shape.DependingOnRoomPosition ? -1 : 0);
                    swr.WriteLine((int)shape.Effect);
                    swr.WriteLine(shape.Room);
                    swr.WriteLine(shape.Depth);
                    swr.WriteLine(shape.MirrorOffset.x);
                    swr.WriteLine(shape.MirrorOffset.y);
                    swr.WriteLine(shape.Strength);
                    for (int pos = 0; pos < 4; ++pos)
                    {
                        swr.Write(shape.Positions[pos].x);
                        swr.Write(';');
                        swr.Write(shape.Positions[pos].y);
                        swr.Write(';');
                    }
                    swr.WriteLine();
                }
                //Inventory
                swr.WriteLine(room.HasInventory ? -1 : 0);
                swr.Write(room.InvPos.x); swr.Write(';');
                swr.Write(room.InvPos.y); swr.Write(';');
                swr.Write(room.InvSize.x); swr.Write(';');
                swr.Write(room.InvSize.y); swr.Write(';');
                System.Globalization.NumberFormatInfo info = new System.Globalization.NumberFormatInfo();
                info.NumberDecimalSeparator = ",";
                swr.Write(String.Format(info, "{0:0.##############}", room.InvScale.x)); swr.Write(';');
                swr.Write(String.Format(info, "{0:0.##############}", room.InvScale.y)); swr.Write(';');
                swr.WriteLine(room.InvSpacing);
                //walkmap
                for (int i = 0; i <= room.Walkmap.GetUpperBound(0); ++i)
                {
                    for (int j = 0; j <= room.Walkmap.GetUpperBound(1); ++j)
                    {
                        Room.WalkMapEntry entry = room.Walkmap[i, j];
                        swr.Write(entry.isFree ? 0 : 1);
                        swr.Write(entry.hasScript ? 1 : 0);
                    }
                }
                swr.WriteLine();
                //objects
                foreach (ObjectInstance obj in room.Objects)
                {
                    swr.Write(";;Roomobject ");
                    swr.WriteLine(obj.Name);
                    swr.WriteLine(obj.Object.Name);
                    swr.WriteLine(obj.Position.x);
                    swr.WriteLine(obj.Position.y);
                    swr.WriteLine(obj.State);
                    swr.WriteLine(obj.Layer);
                    swr.WriteLine(obj.Depth / 2);
                    swr.WriteLine(obj.Depth);
                    swr.WriteLine(obj.Locked ? -1 : 0);
                }
            }
            swr.Flush();
        }
예제 #10
0
 public Room(AdvData data)
 {
     mData = data;
     Name = "Room" + (data.NumRooms + 1);
     Size = new Vec2i(data.WindowXRes, data.Settings.Resolution.y);
     Depthmap = new Vec2i(5, 10);
     Zoom = 3;
     Background = "";
     ParallaxBackground = "";
     FXShapes = new ArrayList();
     for (int i = 0; i < 3; ++i)
     {
         FxShape fs = new FxShape(i);
         FXShapes.Add(fs);
     }
     Vec2i wmsize = data.Settings.Resolution / data.WalkGridSize;
     wmsize.x *= 3 * 2;
     wmsize.y *= 2 * 2;
     Walkmap = new WalkMapEntry[wmsize.x, wmsize.y];
     Lighting = Color.White;
     InvScale = new Vec2f(1.0f, 1.0f);
     InvSpacing = 10;
 }
예제 #11
0
 public Object Clone()
 {
     FxShape shape = new FxShape();
     shape.Active = Active;
     shape.DependingOnRoomPosition = DependingOnRoomPosition;
     shape.Effect = Effect;
     shape.Room = Room;
     shape.Depth = Depth;
     shape.MirrorOffset = MirrorOffset;
     shape.Strength = Strength;
     shape.Positions = (Vec2i[])Positions.Clone();
     return shape;
 }