Exemple #1
0
        public override void SetObject(Map.Object obj)
        {
            this.obj = obj;
            // читаем Xfer
            xfer = obj.GetExtraData <TriggerXfer>();
            scriptActivated.Text = xfer.ScriptOnPressed;
            scriptReleased.Text  = xfer.ScriptOnReleased;
            scriptCollided.Text  = xfer.ScriptOnCollided;
            // единственный способ отличить PressurePlate/Trigger от Button/Lever
            if (ThingDb.Things[obj.Name].ExtentType != "BOX")
            {
                groupBoxArea.Enabled = false;
            }
            else
            {
                sizeX.Value = xfer.SizeX;
                sizeY.Value = xfer.SizeY;
                plateEdgeColor.BackColor = xfer.EdgeColor;
                plateBackColor.BackColor = xfer.BackColor;
            }

            flagsBox.SetItemChecked(0, (xfer.AllowedObjClass & 0x2) == 0x2);               // NO_UPDATE
            flagsBox.SetItemChecked(1, (xfer.AllowedObjClass & 0x4) == 0x4);               // DESTROYED
            flagsBox.SetItemChecked(2, (xfer.AllowedObjClass & 0x1) == 0x1);               //MISSILE
            flagsBox.SetItemChecked(3, (xfer.AllowedObjClass & 0x8) == 0x8);               // NO_COLLIDE
            flagsBox.SetItemChecked(4, (xfer.AllowedObjClass & 0x80000000) == 0x80000000); // NPC
            flagsBox.SetItemChecked(5, (xfer.AllowedObjClass & 0x10) == 0x10);             // EQUIPPED
            flagsBox.SetItemChecked(6, (xfer.AllowedObjClass & 0x1000000) == 0x1000000);   // ENABLED
            flagsBox.SetItemChecked(7, (xfer.AllowedObjClass & 0x2000000) == 0x2000000);   // NO_AUTO_DROP
            flagsBox.SetItemChecked(8, (xfer.AllowedObjClass & 0x8000000) == 0x8000000);   // NO_PUSH_CHARACTERS
            flagsBox.SetItemChecked(9, (xfer.AllowedObjClass & 0x1000) == 0x1000);         // wand
            numericUpDown1.Value = xfer.AllowedTeamID;
            LoadScripts();
        }
Exemple #2
0
 public override void SetDefaultData(Map.Object obj)
 {
     obj.NewDefaultExtraData();
     xfer = obj.GetExtraData <TriggerXfer>();
     if (ThingDb.Things[obj.Name].ExtentType != "BOX")
     {
         xfer.BackColor = Color.Black;
         xfer.EdgeColor = Color.Black;
     }
 }
Exemple #3
0
        /// <summary>
        /// Renders extent for triggers and pressureplates
        /// </summary>
        private void DrawTriggerExtent(Graphics g, Map.Object obj, Map.Object underCursor = null)
        {
            ThingDb.Thing tt = ThingDb.Things[obj.Name];
            if (!tt.HasClassFlag(ThingDb.Thing.ClassFlags.TRIGGER))
            {
                return;
            }

            TriggerXfer trigger       = obj.GetExtraData <TriggerXfer>();
            bool        isUnderCursor = false;


            if (underCursor != null)
            {
                isUnderCursor = underCursor.Equals(obj);
            }

            bool isSelected  = mapRenderer.SelectedObjects.Items.Contains(obj);
            bool isSelected2 = MapInterface.RecSelected.Contains(obj);

            if (isSelected && isSelected2 && MapInterface.KeyHelper.ShiftKey)
            {
                isSelected  = false;
                isSelected2 = false;
            }


            if (isSelected || isSelected2)
            {
                if (mapRenderer.proHand && isUnderCursor)
                {
                    MainWindow.Instance.mapView.mapPanel.Cursor = Cursors.Hand;
                }
            }

            int       x           = (int)obj.Location.X;
            int       y           = (int)obj.Location.Y;
            Rectangle triggerRect = new Rectangle(x - trigger.SizeX / 2, y - trigger.SizeY / 2, trigger.SizeX, trigger.SizeY);

            using (var m = new System.Drawing.Drawing2D.Matrix())
            {
                m.RotateAt(45, obj.Location);
                g.Transform = m;

                switch (tt.DrawType)
                {
                case "TriggerDraw":

                    g.DrawRectangle(triggerPen, triggerRect);
                    if (isSelected || isSelected2)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 255, 0)), triggerRect);
                    }
                    else if (isUnderCursor)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(60, 0, 255, 0)), triggerRect);
                    }

                    break;

                case "PressurePlateDraw":
                    Rectangle shadeRect = new Rectangle(triggerRect.X + 1, triggerRect.Y + 1, triggerRect.Width, triggerRect.Height);
                    Pen       pen       = new Pen(trigger.BackColor, 1F);
                    g.DrawRectangle(pen, shadeRect);
                    pen = new Pen(trigger.EdgeColor, 1F);
                    g.DrawRectangle(pen, triggerRect);
                    if (isSelected || isSelected2)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 255, 0)), triggerRect);
                    }
                    else if (isUnderCursor)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(60, 0, 255, 0)), triggerRect);
                    }
                    break;
                }
                g.ResetTransform();
            }
        }