Esempio n. 1
0
        //Stop Drawing Rectangle
        // - AKA Mouse Up
        // On mouse up try to save the rectangle
        private void StopDrawingRectangle(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //Flag that we are done drawing
            Drawing = false;
            //Verify the rectangle did not overlap the player's current location
            if(!thePlayer.playerIntersectsWith(tmpDrawnRectangle)){
                //If user was drawing both
                if (DrawingBoth)
                {
                    //Add to collision block list
                    colBoxes.Add(tmpDrawnRectangle);

                    //create and add to vision block list
                    FancyRectangle tmpFancy = new FancyRectangle(tmpDrawnRectangle);
                    obstructBoxes.Add(tmpFancy);

                    //Add each line of new Vision block to Line block list
                    List<Line> tmpLines = tmpFancy.getLines();
                    foreach (Line tmpLn in tmpLines)
                    {
                        this.obstructLine.Add(tmpLn);
                    }
                }
                //If user was drawing just collision
                else if (DrawingCol)
                {
                    //Add to the collision block list
                    colBoxes.Add(tmpDrawnRectangle);
                }
                //If user was drawing just vision
                else
                {
                    //Create and add to vision block list
                    FancyRectangle tmpFancy = new FancyRectangle(tmpDrawnRectangle);
                    obstructBoxes.Add(tmpFancy);

                    //Add each line of vision block list to line block list
                    List<Line> tmpLines = tmpFancy.getLines();
                    foreach (Line tmpLn in tmpLines)
                    {
                        this.obstructLine.Add(tmpLn);
                    }
                }
            }

            //Clear the temp rectangle
            tmpDrawnRectangle = new Rectangle();
        }
Esempio n. 2
0
        private void myGameArea_MouseUp(object sender, MouseEventArgs e)
        {
            if (Drawing)
            {
                Drawing = false;
                Rectangle tmpRect = currentDrawingRect();

                switch (this.typeOfDrawing)
                {
                    case 0://save rectangle as both collision & vision
                        FancyRectangle tmpFRect = new FancyRectangle(this.shrinkRectangle(tmpRect));
                        this.currentLevel.addColBox(tmpRect);
                        this.currentLevel.addObsBox(tmpFRect);
                        break;
                    case 1://save rectangle as collision only
                        this.currentLevel.addColBox(tmpRect);
                        break;
                    case 2://save rectangle as vision only
                        FancyRectangle tmpFRect2 = new FancyRectangle(tmpRect);
                        this.currentLevel.addObsBox(tmpFRect2);
                        break;
                    case 3://save rectangle as hunter spawn
                        this.currentLevel.addHunterSpawn(tmpRect);
                        break;
                    case 4://save rectangle as Supernatural spawn
                        this.currentLevel.addSupernaturalSpawn(tmpRect);
                        break;
                    case 5://save rectangle as item spawn
                        this.currentLevel.addItemSpawn(tmpRect);
                        break;
                    case 6://save rectangle as Portal
                        if (DrawingAnotherPortal)
                        {
                            Portal linkedPortal = new Portal(getNextPortalID(), firstPortal.portalID, tmpRect);
                            firstPortal.linkedPortalID = linkedPortal.portalID;
                            this.currentLevel.addPortal(firstPortal);
                            this.currentLevel.addPortal(linkedPortal);
                            DrawingAnotherPortal = false;
                            enableAll();
                        }
                        else
                        {
                            firstPortal = new Portal(getNextPortalID(), -1, tmpRect);
                            this.portalIDs.Add(firstPortal.portalID);
                            DrawingAnotherPortal = true;
                            disableAll();
                        }
                        break;
                }
                tmpDiagLine = new Line();
            }
            else if (DrawingDeleteBox)
            {
                Deleting = true;
                removeRect();
                Deleting = false;
                DrawingDeleteBox = false;
                tmpDiagLine = new Line();
            }
        }