Example #1
0
            private void EndDrag(bool abort)
            {
                ReleaseHandle();
                Application.RemoveMessageFilter(this);
                DragControl.FindForm().Capture = false;

                OnEndDrag(abort);
            }
Example #2
0
        /// <summary>
        /// Adds a control to a drag pane.
        /// </summary>
        /// <param name="control"></param>
        void AddComponentControl(Control controlContained, string text)
        {
            DragControl control = new DragControl();

            control.Text             = text;
            control.ControlContained = controlContained;
            control.CreateControl();
            this.dragContainerControl1.AddDragControl(control);
        }
Example #3
0
        private void Pane_BeginDrag()
        {
            Point pt = new Point(0, 0);

            pt = DragControl.PointToScreen(pt);

            m_mouseOffset.X = pt.X - StartMousePosition.X;
            m_mouseOffset.Y = pt.Y - StartMousePosition.Y;
        }
Example #4
0
        private void ContentWindow_BeginDrag(Point captionLocation)
        {
            Point pt = captionLocation;

            pt = DragControl.PointToScreen(pt);

            m_mouseOffset.X = pt.X - StartMousePosition.X;
            m_mouseOffset.Y = pt.Y - StartMousePosition.Y;
        }
Example #5
0
 public BEPUikDragControl(BEPUikBone bone, BEPUikScene scene, BEPUikDragControlDefinition definition, SimObjectBase instance)
     : base(scene, definition.Name)
 {
     this.bone                      = bone;
     dragControl                    = new DragControl();
     dragControl.TargetBone         = bone.IkBone;
     dragControl.LinearMotor.Offset = (instance.Translation - bone.Owner.Translation).toBepuVec3();
     dragControl.MaximumForce       = definition.MaximumForce;
 }
Example #6
0
    private void HandleControl_MouseDown(object sender, MouseEventArgs e)
    {
        bool flag = e.Button == MouseButtons.Left;

        if (flag)
        {
            DragControl.ReleaseCapture();
            DragControl.SendMessage(this.SelectControl.FindForm().Handle, 161, 2, 0);
        }
    }
Example #7
0
        private void AutoHideWindowSplitter_BeginDrag(Point ptSplitter)
        {
            m_splitterLocation = DragControl.PointToScreen(ptSplitter);
            Point ptMouse = StartMousePosition;

            m_mouseOffset.X = m_splitterLocation.X - ptMouse.X;
            m_mouseOffset.Y = m_splitterLocation.Y - ptMouse.Y;

            Rectangle rect = GetWindowSplitterDragRectangle();

            SplitterOutline.Show(rect);
        }
        private void AutoHideWindowSplitter_BeginDrag(Point ptSplitter)
        {
            m_splitterLocation = DragControl.PointToScreen(ptSplitter);
            Point ptMouse = StartMousePosition;

            m_mouseOffset.X = m_splitterLocation.X - ptMouse.X;
            m_mouseOffset.Y = m_splitterLocation.Y - ptMouse.Y;

            Rectangle rect = GetWindowSplitterDragRectangle();

            DragOutline = DrawHelper.CreateDragOutline(rect, OutlineBorderWidth);
        }
Example #9
0
        private void TabWindowSplitter_BeginDrag(Point ptSplitter)
        {
            m_splitterLocation = ptSplitter;
            m_splitterLocation = DragControl.PointToScreen(m_splitterLocation);
            Point ptMouse = StartMousePosition;

            m_mouseOffset.X = m_splitterLocation.X - ptMouse.X;
            m_mouseOffset.Y = m_splitterLocation.Y - ptMouse.Y;

            Rectangle rect = TabWindowSplitter_GetDragRectangle();

            DragFrame = DrawHelper.CreateDragFrame(rect, DragBorderWidth);
        }
            private void EndDrag(bool abort)
            {
                ReleaseHandle();

                if (PatchController.EnableActiveXFix == false)
                {
                    Application.RemoveMessageFilter(this);
                }

                DragControl.FindForm().Capture = false;

                OnEndDrag(abort);
            }
            private void EndDrag(bool abort)
            {
                ReleaseHandle();
                Application.RemoveMessageFilter(this);
                var findForm = DragControl.FindForm();

                if (findForm != null)
                {
                    findForm.Capture = false;
                }

                OnEndDrag(abort);
            }
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public InverseKinematicsTestDemo2(DemosGame game)
            : base(game)
        {
            game.Camera.Position = new Vector3(0, 3, 5);
            Box ground = new Box(new Vector3(0, -3, 0), 30, 1, 30);

            Space.Add(ground);
            Space.ForceUpdater.Gravity = new Vector3(0, -9.81m, 0);

            var solver = new IKSolver();

            solver.ActiveSet.UseAutomass = true;
            //solver.AutoscaleControlImpulses = true;
            //solver.AutoscaleControlMaximumForce = Fix64.MaxValue;
            solver.ControlIterationCount     = 20;
            solver.FixerIterationCount       = 0;
            solver.VelocitySubiterationCount = 3;


            List <Bone>   bones;
            List <Entity> boneEntities;
            int           boneCount = 10;

            BuildStick(new Vector3(0, 0.5m, 0), boneCount, out bones, out boneEntities);

            DragControl dragger = new DragControl {
                TargetBone = bones[boneCount - 1], MaximumForce = Fix64.MaxValue
            };

            dragger.LinearMotor.Rigidity       = 16;
            dragger.LinearMotor.LocalOffset    = new Vector3(0, 0.5m, 0);
            dragger.LinearMotor.TargetPosition = new Vector3(10, 0, 0);


            bones[0].Pinned = true;

            var controls = new List <Control>();

            controls.Add(dragger);

            solver.Solve(controls);

            var tipLocation = bones[boneCount - 1].Position + Matrix3x3.CreateFromQuaternion(bones[boneCount - 1].Orientation).Up * 0.5m;

            for (int i = 0; i < bones.Count; ++i)
            {
                boneEntities[i].Position    = bones[i].Position;
                boneEntities[i].Orientation = bones[i].Orientation;
                Space.Add(boneEntities[i]);
            }
        }
Example #13
0
        public override void DragAndDrop(Point p)
        {
            FrameworkElement ctrl = this.Controller.Control;

            if (!LayoutHelper.IsPointInsideElementBounds(p, ctrl, new Thickness()))
            {
                DragControl.SetVisible(false);
                DataObject dragData = new DataObject("DragDropDataDG", DragControl.DataContext);
                DragDrop.DoDragDrop(ctrl, dragData, DragDropEffects.Copy);
                DragControl.SetVisible(true);
                return;
            }
            base.DragAndDrop(p);
        }
            protected bool BeginDrag()
            {
                // Avoid re-entrance;
                lock (this)
                {
                    if (DragControl == null)
                        return false;

                    StartMousePosition = Control.MousePosition;

                    if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
                        return false;

                    DragControl.FindForm().Capture = true;
                    AssignHandle(DragControl.FindForm().Handle);
                    Application.AddMessageFilter(this);
                    return true;
                }
            }
Example #15
0
 protected bool BeginDrag()
 {
     lock (this)
     {
         if (DragControl == null)
         {
             return(false);
         }
         StartMousePosition = Control.MousePosition;
         if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
         {
             return(false);
         }
         DragControl.FindForm().Capture = true;
         AssignHandle(DragControl.FindForm().Handle);
         Application.AddMessageFilter(this);
         return(true);
     }
 }
Example #16
0
        private void Content_BeginDrag(Rectangle rectTabWindow)
        {
            TabWindow tabWindow = (TabWindow)DragControl;

            Point pt;

            if (tabWindow is DocumentWindow)
            {
                pt = new Point(rectTabWindow.Top, rectTabWindow.Left);
            }
            else
            {
                pt = new Point(rectTabWindow.Left, rectTabWindow.Bottom);
            }

            pt = DragControl.PointToScreen(pt);

            m_mouseOffset.X = pt.X - StartMousePosition.X;
            m_mouseOffset.Y = pt.Y - StartMousePosition.Y;
        }
        private void Content_BeginDrag(Rectangle rectPane)
        {
            DockPane pane = (DockPane)DragControl;

            Point pt;

            if (pane.DockState == DockState.Document)
            {
                pt = new Point(rectPane.Top, rectPane.Left);
            }
            else
            {
                pt = new Point(rectPane.Left, rectPane.Bottom);
            }

            pt = DragControl.PointToScreen(pt);

            m_mouseOffset.X = pt.X - StartMousePosition.X;
            m_mouseOffset.Y = pt.Y - StartMousePosition.Y;
        }
Example #18
0
        public DragSpin()
        {
            bitmap         = new Bitmap(20, 20);
            dirty          = true;
            textBox        = new TextBox();
            dragger        = new DragControl();
            dragger.Cursor = Cursors.SizeNS;

            if (background == null)
            {
                try{
                    background = new Bitmap(this.GetType(), "DragSpin.bmp");
                }
                catch (ArgumentException)
                {
                    background = new Bitmap(20, 20);
                    Graphics gfx = Graphics.FromImage(background);
                    gfx.FillRectangle(Brushes.White, 0, 0, 20, 20);
                    gfx.DrawLine(Pens.Black, 0, 0, 20, 20);
                    gfx.DrawLine(Pens.Black, 0, 20, 20, 0);
                }
            }

            dragger.Paint     += draggerPaint;
            dragger.KeyDown   += draggerKeyDown;
            dragger.KeyUp     += draggerKeyUp;
            dragger.MouseDown += draggerMouseDown;
            dragger.MouseUp   += draggerMouseUp;
            dragger.MouseMove += draggerMouseMove;
            dragger.LostFocus += draggerLostFocus;

            dragger.MouseWheel += handleMouseWheel;
            textBox.MouseWheel += handleMouseWheel;

            textBox.Text         = val.ToString(formatString);
            textBox.TextChanged += handleTextChanged;
            textBox.LostFocus   += handleTextLostFocus;

            Controls.Add(textBox);
            Controls.Add(dragger);
        }
Example #19
0
    void HandleRelease()
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, 100, gridMask))
        {
            if (hit.collider != null)
            {
                // From Bottom Left - Board is currently 19.2 x 8.4 with 32x14 slots, 0.6 or 60 pixels
                int i = (int)(hit.point.y / 0.6f); // row
                int j = (int)(hit.point.x / 0.6f); // col

                if (isTower)
                {
                    GameObject obj = gameGrid.CheckGrid(i, j);
                    if (obj == null)
                    {
                        DragControl dc = dragObject.GetComponent <DragControl>();
                        if (dc.buttonRef != null)
                        {
                            GameObject tower = GameObject.Instantiate(dc.buttonRef.Tower);
                            tower.transform.position = new Vector3(j * 0.6f + 0.3f, i * 0.6f + 0.3f, -1);
                            gameGrid.SetGrid(i, j, tower);
                            Game.charges -= dc.cost;
                            Destroy(dragObject);
                            Game.grid.UpdateCostGrid();
                            return;
                        }
                    }
                }
            }
        }

        Destroy(dragObject);
    }
        protected virtual void DragControl_LMB_Up(object sender, MouseEventArgs e)
        {
            e.Handled = true;

            _isDragging = false;

            DragRenderTransform.X = 0;
            DragRenderTransform.Y = 0;

            DragControl.ReleaseMouseCapture();

            if (Configuration.AppConfig.Instance.animateControls)
            {
                DoubleAnimation da = new DoubleAnimation(Opacity, 1, TimeSpan.FromSeconds(0.5));

                this.BeginAnimation(OpacityProperty, da);
            }
            else
            {
                Opacity = 1;
            }

            OnStoppedDrag?.Invoke();
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.pnlTopMenu     = new System.Windows.Forms.Panel();
     this.pnlUserControl = new System.Windows.Forms.Panel();
     this.btnMiniWin     = new System.Windows.Forms.Button();
     this.btnMaxiWindow  = new System.Windows.Forms.Button();
     this.btnClose       = new System.Windows.Forms.Button();
     this.panel1         = new System.Windows.Forms.Panel();
     this.btnContact     = new System.Windows.Forms.Button();
     this.btnStudy       = new System.Windows.Forms.Button();
     this.btnWork        = new System.Windows.Forms.Button();
     this.btnNote        = new System.Windows.Forms.Button();
     this.btnProfile     = new System.Windows.Forms.Button();
     this._dragControl   = new InforApp.DragControl();
     this.pnlTopMenu.SuspendLayout();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // pnlTopMenu
     //
     this.pnlTopMenu.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                     | System.Windows.Forms.AnchorStyles.Left)
                                                                    | System.Windows.Forms.AnchorStyles.Right)));
     this.pnlTopMenu.BackColor = System.Drawing.Color.Black;
     this.pnlTopMenu.Controls.Add(this.btnMiniWin);
     this.pnlTopMenu.Controls.Add(this.btnMaxiWindow);
     this.pnlTopMenu.Controls.Add(this.btnClose);
     this.pnlTopMenu.Location = new System.Drawing.Point(0, 0);
     this.pnlTopMenu.Name     = "pnlTopMenu";
     this.pnlTopMenu.Size     = new System.Drawing.Size(1080, 25);
     this.pnlTopMenu.TabIndex = 0;
     //
     // pnlUserControl
     //
     this.pnlUserControl.Location = new System.Drawing.Point(80, 25);
     this.pnlUserControl.Margin   = new System.Windows.Forms.Padding(0);
     this.pnlUserControl.Name     = "pnlUserControl";
     this.pnlUserControl.Size     = new System.Drawing.Size(1000, 680);
     this.pnlUserControl.TabIndex = 2;
     //
     // btnMiniWin
     //
     this.btnMiniWin.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     this.btnMiniWin.Location = new System.Drawing.Point(990, 0);
     this.btnMiniWin.Name     = "btnMiniWin";
     this.btnMiniWin.Size     = new System.Drawing.Size(25, 25);
     this.btnMiniWin.TabIndex = 9;
     this.btnMiniWin.UseVisualStyleBackColor = true;
     this.btnMiniWin.Click += new System.EventHandler(this.btnMiniWin_Click);
     //
     // btnMaxiWindow
     //
     this.btnMaxiWindow.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     this.btnMaxiWindow.Location = new System.Drawing.Point(1020, 0);
     this.btnMaxiWindow.Name     = "btnMaxiWindow";
     this.btnMaxiWindow.Size     = new System.Drawing.Size(25, 25);
     this.btnMaxiWindow.TabIndex = 8;
     this.btnMaxiWindow.UseVisualStyleBackColor = true;
     this.btnMaxiWindow.Click += new System.EventHandler(this.btnMaxiWindow_Click);
     //
     // btnClose
     //
     this.btnClose.Anchor    = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     this.btnClose.BackColor = System.Drawing.Color.Transparent;
     this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
     this.btnClose.Font      = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.btnClose.ForeColor = System.Drawing.Color.Transparent;
     this.btnClose.Location  = new System.Drawing.Point(1050, 0);
     this.btnClose.Name      = "btnClose";
     this.btnClose.Size      = new System.Drawing.Size(25, 25);
     this.btnClose.TabIndex  = 7;
     this.btnClose.Text      = "X";
     this.btnClose.UseVisualStyleBackColor = false;
     this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
     //
     // panel1
     //
     this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                | System.Windows.Forms.AnchorStyles.Left)));
     this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
     this.panel1.Controls.Add(this.btnContact);
     this.panel1.Controls.Add(this.btnStudy);
     this.panel1.Controls.Add(this.btnWork);
     this.panel1.Controls.Add(this.btnNote);
     this.panel1.Controls.Add(this.btnProfile);
     this.panel1.Location = new System.Drawing.Point(0, 25);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(80, 680);
     this.panel1.TabIndex = 1;
     //
     // btnContact
     //
     this.btnContact.BackColor                 = System.Drawing.Color.Transparent;
     this.btnContact.BackgroundImageLayout     = System.Windows.Forms.ImageLayout.None;
     this.btnContact.FlatAppearance.BorderSize = 0;
     this.btnContact.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this.btnContact.ForeColor                 = System.Drawing.Color.Transparent;
     this.btnContact.Image      = ((System.Drawing.Image)(resources.GetObject("btnContact.Image")));
     this.btnContact.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
     this.btnContact.Location   = new System.Drawing.Point(0, 308);
     this.btnContact.Name       = "btnContact";
     this.btnContact.Size       = new System.Drawing.Size(80, 80);
     this.btnContact.TabIndex   = 4;
     this.btnContact.Text       = "Contact";
     this.btnContact.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
     this.btnContact.UseVisualStyleBackColor = true;
     this.btnContact.Click += new System.EventHandler(this.btnContact_Click);
     //
     // btnStudy
     //
     this.btnStudy.BackColor                 = System.Drawing.Color.Transparent;
     this.btnStudy.BackgroundImageLayout     = System.Windows.Forms.ImageLayout.None;
     this.btnStudy.FlatAppearance.BorderSize = 0;
     this.btnStudy.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this.btnStudy.ForeColor                 = System.Drawing.Color.Transparent;
     this.btnStudy.Image      = ((System.Drawing.Image)(resources.GetObject("btnStudy.Image")));
     this.btnStudy.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
     this.btnStudy.Location   = new System.Drawing.Point(0, 231);
     this.btnStudy.Name       = "btnStudy";
     this.btnStudy.Size       = new System.Drawing.Size(80, 80);
     this.btnStudy.TabIndex   = 3;
     this.btnStudy.Text       = "Study";
     this.btnStudy.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
     this.btnStudy.UseVisualStyleBackColor = true;
     this.btnStudy.Click += new System.EventHandler(this.btnStudy_Click);
     //
     // btnWork
     //
     this.btnWork.BackColor                 = System.Drawing.Color.Transparent;
     this.btnWork.BackgroundImageLayout     = System.Windows.Forms.ImageLayout.None;
     this.btnWork.FlatAppearance.BorderSize = 0;
     this.btnWork.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this.btnWork.ForeColor                 = System.Drawing.Color.Transparent;
     this.btnWork.Image      = ((System.Drawing.Image)(resources.GetObject("btnWork.Image")));
     this.btnWork.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
     this.btnWork.Location   = new System.Drawing.Point(0, 154);
     this.btnWork.Name       = "btnWork";
     this.btnWork.Size       = new System.Drawing.Size(80, 80);
     this.btnWork.TabIndex   = 2;
     this.btnWork.Text       = "Work";
     this.btnWork.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
     this.btnWork.UseVisualStyleBackColor = true;
     this.btnWork.Click += new System.EventHandler(this.btnWork_Click);
     //
     // btnNote
     //
     this.btnNote.BackColor                 = System.Drawing.Color.Transparent;
     this.btnNote.BackgroundImageLayout     = System.Windows.Forms.ImageLayout.None;
     this.btnNote.FlatAppearance.BorderSize = 0;
     this.btnNote.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this.btnNote.ForeColor                 = System.Drawing.Color.Transparent;
     this.btnNote.Image      = ((System.Drawing.Image)(resources.GetObject("btnNote.Image")));
     this.btnNote.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
     this.btnNote.Location   = new System.Drawing.Point(0, 77);
     this.btnNote.Name       = "btnNote";
     this.btnNote.Size       = new System.Drawing.Size(80, 80);
     this.btnNote.TabIndex   = 1;
     this.btnNote.Text       = "Note";
     this.btnNote.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
     this.btnNote.UseVisualStyleBackColor = true;
     this.btnNote.Click += new System.EventHandler(this.btnNote_Click);
     //
     // btnProfile
     //
     this.btnProfile.BackColor                 = System.Drawing.Color.Transparent;
     this.btnProfile.BackgroundImageLayout     = System.Windows.Forms.ImageLayout.None;
     this.btnProfile.FlatAppearance.BorderSize = 0;
     this.btnProfile.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this.btnProfile.ForeColor                 = System.Drawing.Color.Transparent;
     this.btnProfile.Image      = ((System.Drawing.Image)(resources.GetObject("btnProfile.Image")));
     this.btnProfile.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
     this.btnProfile.Location   = new System.Drawing.Point(0, 0);
     this.btnProfile.Name       = "btnProfile";
     this.btnProfile.Size       = new System.Drawing.Size(80, 80);
     this.btnProfile.TabIndex   = 0;
     this.btnProfile.Text       = "Home";
     this.btnProfile.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
     this.btnProfile.UseVisualStyleBackColor = true;
     this.btnProfile.Click += new System.EventHandler(this.btnProfile_Click);
     //
     // _dragControl
     //
     this._dragControl.SelectControl = this.pnlTopMenu;
     //
     // Form1
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.AutoSize            = true;
     this.ClientSize          = new System.Drawing.Size(1080, 705);
     this.Controls.Add(this.panel1);
     this.Controls.Add(this.pnlTopMenu);
     this.Controls.Add(this.pnlUserControl);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     this.MinimumSize     = new System.Drawing.Size(1000, 680);
     this.Name            = "Form1";
     this.Text            = "Form1";
     this.pnlTopMenu.ResumeLayout(false);
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Example #22
0
    void HandleClick()
    {
        // Clicking anywhere will remove instructions
        if (instructionPref != null)
        {
            Destroy(instructionPref);
        }

        // Start Game
        if (!start && waveControl == null)
        {
            GameObject waveObj = GameObject.Instantiate(waveObjPref);
            waveControl = waveObj.GetComponent <WaveControl>();
            waveControl.Init();
            start = true;
        }

        // Check board selection
        int x = (int)Input.mousePosition.x / (Screen.width / 32);  // 32 cells
        int y = (int)Input.mousePosition.y / (Screen.height / 18); // 14 cells +2+2 on for top and bottom UI

        y -= 2;                                                    // Board starts 2 cells up.



        GameObject obj = Game.grid.CheckGrid(y, x);

        if (obj != null && selectedTower == null)
        {
            selectedTower = obj.GetComponent <Tower>();
            #region Tower
            if (!selected)
            {
                float width  = Screen.width / 32;
                float height = Screen.height / 18;
                selected = true;
                towerSelect.rectTransform.position = new Vector3((x + 0.5f) * width, (y + 2.5f) * height, 0);
                // Drawing the Selection UI varies if near the edge. Take care of specific cases
                // NW corner
                if (x < 2 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                // NE corner
                else if (x > 29 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                // SE corner
                else if (x > 29 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(0, 45, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                }
                // Top
                else if (y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                else if (x > 29)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                else
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(0, 45, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                }
            }
            #endregion
        }
        else // Try looking at UI objects
        {
            RaycastHit2D hit = Physics2D.Raycast(new Vector2(Input.mousePosition.x / Screen.width * 19.2f, Input.mousePosition.y / Screen.height * 10.8f - 1.2f), Vector2.right, 0.1f);

            if (hit.collider != null)
            {
                //Game.TargetEnemy = hit.collider.gameObject.GetComponent<Enemy>();
            }

            #region UI

            // Create a raycast using the mouse position and test against the UI
            PointerEventData pointer = new PointerEventData(EventSystem.current);
            pointer.position = Input.mousePosition;
            List <RaycastResult> raycast = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pointer, raycast);

            if (raycast.Count == 0)
            {
                selected = false;
                towerSelect.rectTransform.position = new Vector3(-100, 0);
                selectedTower = null;
                return; // found nothing
            }

            // You can click either a UI element, or Tower on the board.
            // First check if selecting UI element - Towers, Abilities, Pause, Speed, Menu

            for (int i = 0; i < raycast.Count; i++)
            {
                Debug.Log(raycast[0]);


                TowerButton towerBtn = raycast[i].gameObject.GetComponent <TowerButton>();
                if (towerBtn != null) // Tower UI Element found
                {
                    if (Game.charges < towerBtn.cost)
                    {
                        return;                               // make sure u have enough money
                    }
                    dragObject = GameObject.Instantiate(dragPref);
                    DragControl dc = dragObject.GetComponent <DragControl>();
                    //dc.obj = towerBtn.Tower;
                    dc.buttonRef = towerBtn;
                    dc.sprite    = towerBtn.Tower.GetComponent <SpriteRenderer>().sprite;
                    isTower      = true;
                    dc.cost      = towerBtn.cost;
                    break;
                }
                AbilityBtn abilityBtn = raycast[i].gameObject.GetComponent <AbilityBtn>();
                if (abilityBtn != null)
                {
                    if (Game.charges > 0)
                    {
                        if (abilityBtn.abilityType == AbilityType.Red && Game.redCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartRed();
                            Game.redCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Blue && Game.blueCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartBlue();
                            Game.blueCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Yellow && Game.yellowCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartYellow();
                            Game.yellowCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Purple && Game.purpleCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartPurple();
                            Game.purpleCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Orange && Game.orangeCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartOrange();
                            Game.orangeCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Green && Game.greenCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartGreen();
                            Game.greenCount--;
                        }
                        break;
                    }
                }
                SpeedBtn speedBtn = raycast[i].gameObject.GetComponent <SpeedBtn>();
                if (speedBtn != null)
                {
                    speedBtn.Click();
                }

                if (raycast[i].gameObject.tag == "Pause")
                {
                    if (Game.isPaused)
                    {
                        Game.isPaused  = false;
                        Game.GameSpeed = Game.Speed;
                        Time.timeScale = Game.Speed;
                    }
                    else
                    {
                        Game.isPaused  = true;
                        Time.timeScale = 0;
                        Game.GameSpeed = 0;
                    }
                }

                if (raycast[i].gameObject.tag == "Charge")
                {
                    if (selectedTower != null)
                    {
                        if (selectedTower.ChargeTower())
                        {
                            Game.charges--;
                        }
                    }
                }
                else if (raycast[i].gameObject.tag == "Sell")
                {
                    if (selectedTower != null)
                    {
                        // Destory tower, get half half a charge
                        selectedTower.SellTower();
                        Game.chargeCounter += chargeMax / 2;
                    }
                }
            }
            #endregion

            // Remove tower selection
            selected = false;
            towerSelect.rectTransform.position = new Vector3(-100, 0);
            selectedTower = null;
        }
    }
Example #23
0
 void dragContainerControl1_DragControlAdded(DragContainerControl container, DragControl control)
 {
 }
Example #24
0
 /// <summary>
 /// Destroy sessionInformation upon closing its UI component.
 /// </summary>
 void dragContainerControl1_DragControlRemoved(DragContainerControl container, DragControl control)
 {
     if (control.ControlContained is PlatformExpertSessionControl)
     {
         _expert.Manager.UnRegisterExpertSession(((PlatformExpertSessionControl)control.ControlContained).Session);
     }
 }
Example #25
0
        public override void OnApplyTemplate()
        {
            dragControl = (DragControl)Template.FindName("PART_DragControl", this);
            dragControl.Designable = this;

            base.OnApplyTemplate();
        }
Example #26
0
    void Awake()
    {
        playerInstance = GameObject.Find("Player").GetComponent<Player>();

        gameControlInstance = gc.GetComponent<GameControl> ();
        gameControlGUIInstance = gc.GetComponent<GameControlGUI> ();
        shopControlInstance = gc.GetComponent<ShopControl> ();
        shopControlGUIInstance = gc.GetComponent<ShopControlGUI> ();
        clickControlInstance = gc.GetComponent<ClickControl> ();
        gridControlInstance = gc.GetComponent<GridControl>();
        optionControlInstance = gc.GetComponent<OptionControl>();
        dragControlInstance = gc.GetComponent<DragControl>();
        eventGUIInstance = gc.GetComponent<EventGUI>();
        enemyLibraryInstance = gc.GetComponent<EnemyLibrary>();
        cardLibraryInstance = gc.GetComponent<CardLibrary>();
        goalLibraryInstance = gc.GetComponent<GoalLibrary>();
        guiStyleLibraryInstance = gc.GetComponent<GUIStyleLibrary>();
        mainMenuInstance = gc.GetComponent<MainMenu>();
        encyclopediaMenuInstance = gc.GetComponent<EncyclopediaMenu>();
        godChoiceMenuInstance = gc.GetComponent<GodChoiceMenu>();
        customizeMenuInstance = gc.GetComponent<CustomizeMenu>();
        gridCursorControlInstance = gc.GetComponent<GridCursorControl>();
        menuControlInstance = gc.GetComponent<MenuControl>();
        tutorialInstance = gc.GetComponent<Tutorial>();
        deckAnimateInstance = deck.GetComponent<DeckAnimate>();

        shopAndGoalParentCanvasInstance = goalandshopparent
                                          .GetComponent<ShopAndGoalParentCanvas>();
        shopGridCanvasInstance = shopgrid
                                 .GetComponent<ShopGridCanvas>();
        gridCursorControlGUIInstance = gridcursorcontrolgui
                                       .GetComponent<GridCursorControlGUI>();
    }
 public ExternalDragControl()
 {
     dragControl = new DragControl();
 }