예제 #1
0
 private void ToolStripButton7_Click(object sender, EventArgs e)
 {
     drawingMethod = delegate(ref Graphics graphics, Bitmap bitmap, PictureBox canvas, Point start, Point finish, Pen pen, Brush brush)
     {
         Bitmap bitmap2 = new Bitmap(bitmap);
         graphics = Graphics.FromImage(bitmap2);
         Rectangle rectangle;
         if (finish.X > start.X && finish.Y > start.Y)
         {
             rectangle = new Rectangle(start.X, start.Y, finish.X - start.X, finish.Y - start.Y);
         }
         else if (finish.X < start.X && finish.Y < start.Y)
         {
             rectangle = new Rectangle(finish.X, finish.Y, start.X - finish.X, start.Y - finish.Y);
         }
         else if (finish.X < start.X && finish.Y > start.Y)
         {
             rectangle = new Rectangle(finish.X, start.Y, start.X - finish.X, finish.Y - start.Y);
         }
         else
         {
             rectangle = new Rectangle(start.X, finish.Y, finish.X - start.X, start.Y - finish.Y);
         }
         graphics.DrawEllipse(pen, rectangle);
         graphics.FillEllipse(brush, rectangle);
         canvas.Image = bitmap2;
     };
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #2
0
 private void ToolStripButton12_Click(object sender, EventArgs e)
 {
     if (colorDialog1.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     choosedColor = colorDialog1.Color;
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #3
0
 private void ToolStripButton1_Click(object sender, EventArgs e)
 {
     drawingMethod = delegate(ref Graphics graphics, Bitmap bitmap, PictureBox canvas, Point start, Point finish, Pen pen, Brush brush)
     {
         graphics.DrawLine(pen, x, y, finish.X, finish.Y);
         x            = finish.X;
         y            = finish.Y;
         canvas.Image = bitmap;
     };
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #4
0
 private void ToolStripButton8_Click(object sender, EventArgs e)
 {
     drawingMethod = delegate(ref Graphics graphics, Bitmap bitmap, PictureBox canvas, Point start, Point finish, Pen pen, Brush brush)
     {
         Bitmap bitmap2 = new Bitmap(bitmap);
         graphics = Graphics.FromImage(bitmap2);
         graphics.DrawLine(pen, start, finish);
         canvas.Image = bitmap2;
     };
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #5
0
        private void СоздатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CanvasForm canvasForm = new CanvasForm();

            canvasForm.MdiParent = this;
            ToolSelection       += canvasForm.ToolSelectionHandler;
            if (drawingMethod != null)
            {
                ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
            }
            canvasForm.Show();
        }
예제 #6
0
 // Start is called before the first frame update
 void Start()
 {
     thoughtSpawningEnabled = false;
     gmToolScript           = GameObject.FindGameObjectWithTag("GameManager")?.GetComponent <ToolSelection>();;
     if (gmToolScript)
     {
         gmToolScript.AnnounceToolChanged += GmToolScript_AnnounceToolChanged;;
     }
     else
     {
         Debug.LogWarning("ThoughtController could not find GameManager's ToolSelection script!");
     }
 }
예제 #7
0
 private void Start()
 {
     mainCamera      = Camera.main;
     draggingEnabled = true;
     gmToolScript    = GameObject.FindGameObjectWithTag("GameManager")?.GetComponent <ToolSelection>();
     if (gmToolScript)
     {
         gmToolScript.AnnounceToolChanged += GmToolScript_AnnounceToolChanged;
     }
     else
     {
         Debug.LogWarning("MouseDrag could not find GameManager's ToolSelection script!");
     }
 }
예제 #8
0
 // Start is called before the first frame update
 void Start()
 {
     currentTool  = originalTool;
     rend         = gameObject.GetComponent <SpriteRenderer>();
     gmToolScript = GameObject.FindGameObjectWithTag("GameManager")?.GetComponent <ToolSelection>();
     if (gmToolScript)
     {
         gmToolScript.AnnounceToolChanged += GmToolScript_AnnounceToolChanged;
     }
     else
     {
         Debug.LogWarning("ToolHolder could not find GameManager's ToolSelection script!");
     }
 }
예제 #9
0
        private void DrawToolGui()
        {
            areToolsFoldedOut = EditorGUILayout.Foldout(areToolsFoldedOut, new GUIContent("Tools", toolsIcons), foldoutStyle);
            if (areToolsFoldedOut)
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Brush:", GUILayout.MaxWidth(40), GUILayout.Height(20));

                    ToolSelection currentToolSelection = sceneManipulator.GetCurrentTool();
                    PaintingBrush currentBrushSize     = sceneManipulator.GetCurrentBrush();

                    Texture[] brushIcons = new Texture[] { preciseBrushIcon, smallBrushIcon, mediumBrushIcon, largeBrushIcon };
                    int       brushId    = (currentToolSelection == ToolSelection.TrianglePainting) ? (int)currentBrushSize : -1;
                    int       newBrushId = GUILayout.Toolbar(brushId, brushIcons, UnityEditor.EditorStyles.miniButton, GUILayout.Width(120), GUILayout.Height(20));

                    int pipetteId    = (currentToolSelection == ToolSelection.Pipette ? 0 : -1);
                    int newPipetteId = GUILayout.Toolbar(pipetteId, new Texture[] { currentToolSelection == ToolSelection.Pipette ? pipetteIcon : pipetteIcon }, UnityEditor.EditorStyles.miniButton, GUILayout.Height(20), GUILayout.Width(30));

                    if (newBrushId != brushId)
                    {
                        sceneManipulator.SetTool(ToolSelection.TrianglePainting);
                        sceneManipulator.SetBrush((PaintingBrush)newBrushId);
                    }
                    else if (newPipetteId != pipetteId)
                    {
                        sceneManipulator.SetTool(newPipetteId == 0 ? ToolSelection.Pipette : ToolSelection.TrianglePainting);
                    }

                    if (GUILayout.Button(new GUIContent("Generate"), GUILayout.MinWidth(10)))
                    {
                        GenerateColliders();
                    }

                    if (GUILayout.Button(new GUIContent("Delete Colliders", deleteIcon), GUILayout.MinWidth(10)))
                    {
                        DeleteColliders();
                    }

                    if (GUILayout.Button(new GUIContent("Delete generated", deleteIcon), GUILayout.MinWidth(10)))
                    {
                        DeleteGenerated();
                    }
                }
                GUILayout.EndHorizontal();
            }             // end foldout

            DrawUiDivider();
        }
예제 #10
0
 private void ToolStripButton10_Click(object sender, EventArgs e)
 {
     drawingMethod = delegate(ref Graphics graphics, Bitmap bitmap, PictureBox canvas, Point start, Point finish, Pen pen, Brush brush)
     {
         if (fontDialog1.ShowDialog() == DialogResult.Cancel)
         {
             return;
         }
         Font   font    = fontDialog1.Font;
         string text    = Interaction.InputBox("Введите текст", "Текст", "Lorem ipsum dolor sit amet");
         Bitmap bitmap2 = new Bitmap(bitmap);
         graphics = Graphics.FromImage(bitmap2);
         graphics.DrawString(text, font, brush, start);
         canvas.Image = bitmap2;
     };
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #11
0
 // Start is called before the first frame update
 void Start()
 {
     type = (EThought)Random.Range(1, 6);
     SetThoughSprite(gameObject, type);
     thoughtControlEnabled = false;
     velx         = Random.Range(-5.0f, 5.0f);
     vely         = Random.Range(-5.0f, 5.0f);
     screenBounds = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
     screenOrigo  = Camera.main.ScreenToWorldPoint(Vector2.zero);
     col2D        = GetComponent <BoxCollider2D>();
     gmToolScript = GameObject.FindGameObjectWithTag("GameManager")?.GetComponent <ToolSelection>();;
     if (gmToolScript)
     {
         gmToolScript.AnnounceToolChanged += GmToolScript_AnnounceToolChanged;;
     }
     else
     {
         Debug.LogWarning("ThoughtController could not find GameManager's ToolSelection script!");
     }
 }
예제 #12
0
 private void ToolStripButton3_Click(object sender, EventArgs e)//копирование
 {
     drawingMethod = delegate(ref Graphics graphics, Bitmap bitmap, PictureBox canvas, Point start, Point finish, Pen pen, Brush brush)
     {
         int LeftX = start.X < finish.X ? start.X : finish.X;
         int TopY  = start.Y < finish.Y ? start.Y : finish.Y;
         if (Math.Abs(start.X - finish.X) > 0 && Math.Abs(start.Y - finish.Y) > 0)
         {
             Bitmap bm  = new Bitmap(Math.Abs(start.X - finish.X), Math.Abs(start.Y - finish.Y));
             Bitmap ist = new Bitmap((ActiveMdiChild as CanvasForm).CanvasPictureBox.Image);
             for (int i = LeftX; i < LeftX + bm.Width; i++)
             {
                 for (int j = TopY; j < TopY + bm.Height; j++)
                 {
                     bm.SetPixel(i - LeftX, j - TopY, ist.GetPixel(i, j));
                 }
             }
             Clipboard.SetImage(bm);
             canvas.Invalidate();
         }
     };
     ToolSelection?.Invoke(this, new ToolSelectionEventArgs(new Pen(choosedColor), new SolidBrush(choosedColor), drawingMethod));
 }
예제 #13
0
        public void Initialize(ContentManager contentManager, GraphicsDevice graphicsDevice)
        {
            if (!isInitialized)
            {
                Resources.Initialize(contentManager, graphicsDevice);
                GameData.Initialize();
                EditorResources.Initialize();

                this.inventory               = new Inventory(null);
                this.rewardManager           = new RewardManager(null);
                this.timer                   = Stopwatch.StartNew();
                this.ticks                   = 0;
                this.roomSpacing             = 1;
                this.playAnimations          = false;
                this.tileset                 = GameData.TILESET_CLIFFS;
                this.zone                    = GameData.ZONE_PRESENT;
                this.selectedTilesetTileData = this.tileset.GetTileData(0, 0);
                this.eventMode               = false;

                GameData.LoadInventory(inventory);
                GameData.LoadRewards(rewardManager);

                // Create tileset combo box.
                editorForm.ComboBoxTilesets.Items.Clear();
                foreach (KeyValuePair <string, Tileset> entry in Resources.GetResourceDictionary <Tileset>())
                {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                foreach (KeyValuePair <string, EventTileset> entry in Resources.GetResourceDictionary <EventTileset>())
                {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                editorForm.ComboBoxTilesets.SelectedIndex = 0;

                // Create zone combo box.
                editorForm.ComboBoxZones.Items.Clear();
                foreach (KeyValuePair <string, Zone> entry in Resources.GetResourceDictionary <Zone>())
                {
                    if (tileset.SpriteSheet.Image.HasVariant(entry.Key))
                    {
                        editorForm.ComboBoxZones.Items.Add(entry.Key);
                    }
                }
                editorForm.ComboBoxZones.SelectedIndex = 0;

                // Create tools.
                tools = new List <EditorTool>();
                AddTool(toolPointer   = new ToolPointer());
                AddTool(toolPlace     = new ToolPlace());
                AddTool(toolSquare    = new ToolSquare());
                AddTool(toolFill      = new ToolFill());
                AddTool(toolSelection = new ToolSelection());
                AddTool(toolEyedrop   = new ToolEyedrop());
                currentToolIndex      = 0;
                tools[currentToolIndex].OnBegin();

                this.isInitialized = true;

                Application.Idle += delegate {
                    Update();
                };
            }
        }
예제 #14
0
        public bool DoMouseDown(PickMode initialMode)
        {
            if (currentToolSelection == ToolSelection.TrianglePainting)
            {
                if (targetMeshCollider != null)
                {
                    if (currentHullPainter != null && currentHullPainter.paintingData != null)
                    {
                        Undo.RecordObject(currentHullPainter.paintingData, "Paint Hull");

                        pickMode = PickTriangle(initialMode);
                        if (pickMode != PickMode.Undecided)
                        {
                            //	Debug.Log ("Start drag");

                            Sync();

                            EditorUtility.SetDirty(currentHullPainter.paintingData);

                            isSelectingFaces = true;

                            return(true);
                        }
                        else
                        {
                            //	Debug.Log ("Abandon drag");
                        }
                    }
                    else
                    {
                        // This can happen when unity triggers scene callbacks in an odd order and the currentHullPainter isn't set yet
                        //	Debug.LogError("SceneManipulator has no currentHullPainter!");
                    }
                }
                else
                {
                    Debug.Log("Mouse down but no targetMeshCollider, ignoring");
                }
            }
            else if (currentToolSelection == ToolSelection.Pipette)
            {
                // Raycast against the target mesh collider and see if the triangle we hit is in any current hull

                bool anyFound = false;

                Ray pickRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

                int hitTriIndex = -1;
                if (targetMeshCollider != null && RaycastUtil.Raycast(targetMeshCollider, pickRay, out hitTriIndex, 10000.0f))
                {
                    for (int i = 0; i < currentHullPainter.paintingData.hulls.Count; i++)
                    {
                        Hull hull = currentHullPainter.paintingData.hulls[i];
                        if (hull.selectedFaces.Contains(hitTriIndex))
                        {
                            // Now painting this hull!
                            currentHullPainter.paintingData.activeHull = i;
                            currentToolSelection = ToolSelection.TrianglePainting;
                            anyFound             = true;
                            break;
                        }
                    }
                }

                if (!anyFound)
                {
                    currentToolSelection = ToolSelection.TrianglePainting;
                    currentHullPainter.paintingData.activeHull = -1;
                }
            }

            return(false);
        }
예제 #15
0
 public void SetTool(ToolSelection sel)
 {
     this.currentToolSelection = sel;
 }