Ejemplo n.º 1
0
    public void CreateCard(int shapeIndex, int cardIndex)
    {
        var card = Instantiate(_cardClone);

        card.SetCardIndex((cardIndex + 1) * 10);
        card.SetBackgroundSprite(BackGroundSprite);
        card.SetBackCardSprite(BackCardSprite);
        card.SetParent(transform);

        ShapeSystem.GetInstance().CreateCardShapeCenter(card, shapeIndex);

        if (cardIndex < 13)
        {
            ShapeSystem.GetInstance().InitizlizeCardShapeSide(card, shapeIndex);

            TextSystem.GetInstance().AddCardText(card, NormalTextPos, NormalTextScale, 1);
            TextSystem.GetInstance().AddCardText(card, NormalTextPos, NormalTextScale, -1);
        }
        else
        {
            TextSystem.GetInstance().AddCardText(card, JokerTextPos, JokerTextScale, 1);
            TextSystem.GetInstance().AddCardText(card, JokerTextPos, JokerTextScale, -1);
        }

        card.SetScale(CardScale);
        card.SetSortingOrder(Cards.Count);
        card.gameObject.SetActive(false);
        Cards.Add(card);
    }
Ejemplo n.º 2
0
        private void BasicCad_Form_MouseMove(object sender, MouseEventArgs e)
        {
            PointF cursPos = this.PointToClient(Cursor.Position);

            if (cadSystem.clickCache.count() > 0)
            {
                PointF     start       = cadSystem.gridSystem.GetCursorReal();
                RectangleF invalidrect = new RectangleF(Math.Min(start.X, cursPos.X) - 30,
                                                        Math.Min(start.Y, cursPos.Y) - 30,
                                                        Math.Abs(start.X - cursPos.X) + 60,
                                                        Math.Abs(start.Y - cursPos.Y) + 60);
                Invalidate(new Region(invalidrect));
            }
            if (tool_MoveDim.Checked == true && ShapeSystem.GetActiveShape() is LinearDimension)
            {
                if (e.Button == MouseButtons.Left)
                {
                    ShapeSystem.AdjustDimByRealCursor(this.PointToClient(Cursor.Position), ShapeSystem.GetActiveShape().IdShape);
                    Invalidate();
                }
            }
            if (global_mousePan != null)
            {
                Invalidate();
            }
        }
Ejemplo n.º 3
0
        private void BasicCad_Form_MouseDown(object sender, MouseEventArgs e)
        {
            PointF cursPos = this.PointToClient(Cursor.Position);

            if (e.Button == MouseButtons.Left && tool_MoveDim.Checked)
            {
                if (!ShapeSystem.ActivateShapeUnderPoint <LinearDimension>(cursPos))
                {
                    ShapeSystem.DeselectActiveShapes();
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (!ShapeSystem.ActivateShapeUnderPoint(cursPos))
                {
                    ShapeSystem.DeselectActiveShapes();
                }
            }
            else if (e.Button == MouseButtons.Middle)
            {
                if (global_mousePan == null)
                {
                    this.Cursor     = Cursors.NoMove2D;
                    global_mousePan = mousePan.mousePanGrid(cursPos);
                }
            }
        }
Ejemplo n.º 4
0
        /**********************
        * PAINT
        **********************/
        private void BasicCad_Paint(object sender, PaintEventArgs e)
        {
            PointF cursPos = this.PointToClient(Cursor.Position);
            var    g       = e.Graphics;

            if (global_mousePan != null)
            {
                PointF fakeOrigin = new PointF(cursPos.X - global_mousePan.start.X, cursPos.Y - global_mousePan.start.Y);
                cadSystem.gridSystem.DrawOrigin(g);
                cadSystem.gridSystem.DrawGrid(g, fakeOrigin);
                cadSystem.gridSystem.DrawCurs(g, fakeOrigin);
                cadSystem.gridSystem.DrawOrigin(g, fakeOrigin);
                //return;
            }
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.Default;
            g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            cadSystem.gridSystem.DrawGrid(g);
            cadSystem.gridSystem.DrawOrigin(g);
            ShapeSystem.RefreshAll(g);
            cadSystem.gridSystem.DrawSnaps(g);

            if (cadSystem.clickCache.count() > 0)
            {
                cadSystem.gridSystem.DrawLineToCursor(g, cadSystem.gridSystem.GetCursorReal(), cursPos);
            }
            cadSystem.gridSystem.DrawCurs(g);
        }
Ejemplo n.º 5
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ShapeSystem.RemoveActiveShape())
     {
         treeView_Update();
         Invalidate();
     }
 }
Ejemplo n.º 6
0
 private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Name == "MAIN_Shapes")
     {
         return;
     }
     ShapeSystem.MakeActiveShape(ShapeSystem.GetShapeById(Convert.ToInt16(e.Node.Name)));
     Invalidate();
 }
Ejemplo n.º 7
0
 public static void ConventionalTest()
 {
     foreach (var s in ShapeSystem.shapes)
     {
         foreach (var other in ShapeSystem.shapes)
         {
             if (s != other && Collision.IsColliding(s, other))
             {
                 ShapeSystem.OnCollisionEnter(s, other);
             }
         }
     }
 }
Ejemplo n.º 8
0
        /**********************
        * FORM EVENTS
        **********************/

        private void BasicCad_Load(object sender, EventArgs e)
        {
            LMBControls.Renderer = new ToolStripButtonRenderer();
            RMBControls.Renderer = new ToolStripButtonRenderer();
            cadSystem            = new CadSystem(new PointF(145, 24), this.Size, .25F, 96);
            ShapeSystem.setBaseColors(
                new Pen(Color.FromArgb(255, 20, 20, 20), 2),
                new Pen(Color.OrangeRed, 2));
            AdjustSnapDistance.Value = (decimal)cadSystem.gridSystem.getGridIncrements();
            _writer = new ConsoleRedirection.TextBoxStreamWriter(txt_Console);
            // Redirect the out Console stream
            Console.SetOut(_writer);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            treeView_Init();
        }
Ejemplo n.º 9
0
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            Ray     r = cam.ScreenPointToRay(Input.mousePosition);
            Vector3 p = r.GetPoint(10);
            ShapeSystem.SpawnShape(new Circle(p, Random.Range(1f, 4f)));
        }

        ShapeSystem.Update();
        CollisionDetectionSystem.DetectCollisions();

        if (Input.GetKeyDown(KeyCode.F1))
        {
            long quadtreeResult         = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.QuadtreeTest(); }, 10);
            long quadtreeNonAllocResult = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.QuadtreeNonAllocTest(); }, 10);
            long conventionalResult     = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.ConventionalTest(); }, 10);
            print("Quadtree Benchmark Time: " + quadtreeResult);
            print("Quadtree(Non Alloc) Benchmark Time: " + quadtreeNonAllocResult);
            print("Conventional Benchmark Time: " + conventionalResult);
        }

        if (Input.GetKeyDown(KeyCode.F2))
        {
            Settings.mode = Settings.CollisionDetectionMode.Conventional;
        }

        if (Input.GetKeyDown(KeyCode.F3))
        {
            Settings.mode = Settings.CollisionDetectionMode.QuadtreeAllocated;
        }

        if (Input.GetKeyDown(KeyCode.F4))
        {
            Settings.mode = Settings.CollisionDetectionMode.QuadtreeNonAllocated;
        }

        if (Input.GetKeyDown(KeyCode.F5))
        {
            Settings.debugDrawShapes = !Settings.debugDrawShapes;
        }

        if (Input.GetKeyDown(KeyCode.F6))
        {
            Settings.debugDrawTree = !Settings.debugDrawTree;
        }
    }
Ejemplo n.º 10
0
        private void treeView_Update()
        {
            //Validate Existing Branches
            TreeNode ShapeNode = treeView.Nodes[0];

            //Remove old
            RemoveAbandonedNodes(ShapeNode);
            DataView orderedView = ShapeSystem.DT_ShapeList.DefaultView;

            orderedView.Sort = "IdShape ASC";
            foreach (DataRowView row in orderedView)
            {
                var parentId = row[1].ToString();
                var Id       = row[0].ToString();
                var name     = row[2].ToString();
                var desc     = row[3].ToString();

                //check for new nodes and add
                if (!(checkNodeExistence(ShapeNode, Id)))
                {
                    TreeNode newNode = new TreeNode();
                    newNode.Name = Id;
                    newNode.Text = name + Id;
                    TreeNode parentNode = FindParentNodesRecursive(ShapeNode, parentId);
                    if (parentNode != null)
                    {
                        parentNode.Nodes.Add(newNode);
                    }
                    else
                    {
                        if (parentId != "-1")
                        {
                            ShapeSystem.FixParentAbandonmentIssues(Convert.ToInt16(Id));
                        }
                        ShapeNode.Nodes.Add(newNode);
                    }
                }
            }

            treeView.ExpandAll();
        }
Ejemplo n.º 11
0
 public void Search(Shape s)
 {
     if (!Collision.IsColliding(s, boundry))
     {
         return;
     }
     for (int i = 0; i < shapesCounter; i++)
     {
         if (s != shapes[i] && Collision.IsColliding(s, shapes[i]))
         {
             ShapeSystem.OnCollisionEnter(s, shapes[i]);
         }
     }
     if (subdivided)
     {
         tl.Search(s);
         tr.Search(s);
         bl.Search(s);
         br.Search(s);
     }
 }
Ejemplo n.º 12
0
 void Update()
 {
     ShapeSystem.Update();
     CollisionDetectionSystem.QuadtreeTest();
 }