コード例 #1
0
        /// <summary>
        /// Individual puzzle. Create a square from 4 triangles.
        /// </summary>
        /// <param name="game">The game object associated with this puzzle.</param>
        /// <param name="player">The player who may complete this puzzle.</param>
        public CreateASquare(Game game, Player player)
            : base(game, player)
        {
            Triangles = new List<Triangle>();
            countUpdates = 0;

            tri1 = new Triangle();
            tri2 = new Triangle();
            tri3 = new Triangle();
            tri4 = new Triangle();

            tri1.Location = new Rectangle(120, 37, 84, 42);
            tri2.Location = new Rectangle(78, 79, 84, 42);
            tri3.Location = new Rectangle(162, 79, 84, 42);
            tri4.Location = new Rectangle(120, 121, 84, 42);

            //Are you proud of me yet?
            tri1.Rot = (randNum = Game1.random.Next(0,2)) == 0 ? Orientation.Up : randNum == 1 ? Orientation.Left : Orientation.Right;
            tri2.Rot = (randNum = Game1.random.Next(0,2)) == 0 ? Orientation.Left : randNum == 1 ? Orientation.Up : Orientation.Down;
            tri3.Rot = (randNum = Game1.random.Next(0,2)) == 0 ? Orientation.Right : randNum == 1 ? Orientation.Up : Orientation.Down;
            tri4.Rot = (randNum = Game1.random.Next(0,2)) == 0 ? Orientation.Down : randNum == 1 ? Orientation.Left : Orientation.Right;

            tri1.Stat = Status.Waiting;
            tri2.Stat = Status.Waiting;
            tri3.Stat = Status.Waiting;
            tri4.Stat = Status.Waiting;

            Triangles.Add(tri1);
            Triangles.Add(tri2);
            Triangles.Add(tri3);
            Triangles.Add(tri4);

            leftClick = new LeftClick(game, player);
        }
コード例 #2
0
        public DragCircleAvoidBlocks(Game game, Player player)
            : base(game, player)
        {
            backgroundRec = new Rectangle(0, 0, 250, 150);
            goalRec = new Rectangle(90, 128, 22, 22);
            ball1Rec = new Rectangle(4, 0, 22, 22);
            ball2Rec = new Rectangle(223, 128, 22, 22);
            block1Rec = new Rectangle(180, 45, 70, 17);
            block2Rec = new Rectangle(200, 83, 50, 17);

            leftWall1 = new Rectangle(0, 0, 3, 141);
            topWall1 = new Rectangle(28, 11, 87, 3);
            rightWall1 = new Rectangle(114, 11, 3, 141);
            bottomWall1 = new Rectangle(0, 138, 86, 3);
            topPart1 = new Rectangle(28, 0, 3, 12);
            bottomPart1 = new Rectangle(86, 138, 3, 12);

            leftWall2 = new Rectangle(133, 0, 3, 141);
            topWall2 = new Rectangle(28 + 133, 11, 87, 3);
            rightWall2 = new Rectangle(114 + 133, 11, 3, 141);
            bottomWall2 = new Rectangle(0 + 133, 138, 86, 3);
            topPart2 = new Rectangle(28 + 133, 0, 3, 12);
            bottomPart2 = new Rectangle(86 + 133, 138, 3, 12);

            block1State = block2State = BlockState.Waiting;
            ball1State = ball2State = ClickedState.Released;

            leftClick = new LeftClick(game, player);
        }
コード例 #3
0
 public static void OnLeftClick()
 {
     if (LeftClick != null)
     {
         LeftClick.Invoke();
     }
 }
コード例 #4
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject(-1))
        {
            if (LeftClick != null)
            {
                LeftClick.Invoke(this, EventArgs.Empty);
            }
            else
            {
            }
        }

        if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject(-1))
        {
            if (RightClick != null)
            {
                RightClick.Invoke(this, EventArgs.Empty);
            }
            else
            {
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            CancelClick?.Invoke(this, EventArgs.Empty);
        }
    }
コード例 #5
0
 private void Mouse0Input()
 {
     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         LeftClick?.Invoke();
     }
 }
コード例 #6
0
        private void CheckLeftClick()
        {
            if (LeftClick != null)
            {
                double  down    = 0;
                double  up      = 0;
                Point3D highest = list[0];
                Point3D lowest  = list[0];

                bool clicked = false;
                foreach (Point3D point in list)
                {
                    double isLowest = CheckPoint(point, highest);
                    double backHigh = CheckPoint(point, lowest);

                    if (isLowest == 0)
                    {
                        highest = point;
                        lowest  = point;
                        up      = 0;
                        down    = 0;
                        continue;
                    }

                    if (down <= MinDepth && (isLowest == 0 && backHigh == 0))
                    {
                        highest = point;
                        lowest  = point;
                        up      = 0;
                        down    = 0;
                        continue;
                    }

                    if (isLowest < 0 && isLowest < down)
                    {
                        down   = isLowest;
                        lowest = point;
                    }

                    if (down <= MinDepth && backHigh > 0 && backHigh > up)
                    {
                        up = backHigh;
                    }

                    if (up >= MaxDepth)
                    {
                        clicked = true;
                        break;
                    }
                }

                if (clicked)
                {
                    clickWait = SingleClickWaitCount;
                    LeftClick.Invoke();
                }
            }
        }
コード例 #7
0
ファイル: Cell.cs プロジェクト: MultiTeemer/MineSweeper
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         LeftClick.SafeInvoke();
     }
     else if (eventData.button == PointerEventData.InputButton.Right)
     {
         RightClick.SafeInvoke();
     }
 }
コード例 #8
0
        public override void Update(double dt)
        {
            PrevKeyboard    = CurrentKeyboard;
            CurrentKeyboard = Keyboard.GetState();

            PrevMouse    = CurrentMouse;
            CurrentMouse = Mouse.GetState();

            bool isOverUI = IsOverUI();

            if (CurrentMouse.LeftButton == ButtonState.Pressed)
            {
                if (LeftButtonDown != null && !isOverUI)
                {
                    LeftButtonDown.Invoke(new InputEventArgs(this));
                }
            }

            if (CurrentMouse.RightButton == ButtonState.Pressed)
            {
                if (RightButtonDown != null && !isOverUI)
                {
                    RightButtonDown.Invoke(new InputEventArgs(this));
                }
            }

            if (CurrentMouse.LeftButton == ButtonState.Pressed && PrevMouse.LeftButton == ButtonState.Released)
            {
                if (LeftClick != null && !isOverUI)
                {
                    LeftClick.Invoke(new InputEventArgs(this));
                }
            }

            if (CurrentMouse.RightButton == ButtonState.Pressed && PrevMouse.RightButton == ButtonState.Released)
            {
                if (RightClick != null && !isOverUI)
                {
                    RightClick.Invoke(new InputEventArgs(this));
                }
            }

            foreach (KeyListener listener in _listeners)
            {
                if (CurrentKeyboard.IsKeyDown(listener.Primary) && (listener.Continuous || !PrevKeyboard.IsKeyDown(listener.Primary)))
                {
                    listener.Trigger(listener.Primary, this);
                }
                else if (CurrentKeyboard.IsKeyDown(listener.Alternate) && (listener.Continuous || !PrevKeyboard.IsKeyDown(listener.Alternate)))
                {
                    listener.Trigger(listener.Alternate, this);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Individual puzzle. Find all sixes or nines from a grid.
        /// </summary>
        /// <param name="game">The game object associated with this puzzle.</param>
        /// <param name="player">The player who may complete this puzzle.</param>
        public NumeralSearch(Game game, Player player)
            : base(game, player)
        {
            nPosition = new HashSet<int>();
            for (int i = 0; i < amountToFind; i++)
                nPosition.Add(Game1.random.Next(0, columns*rows));

            leftClick = new LeftClick(game, player);

            timeToComplete = new TimeSpan(0, 0, 0, 0, (int) (40 / (double) Game1.gameDifficulty));
        }
コード例 #10
0
 private void MessageSink_MouseEventReceived(MouseEvent obj)
 {
     if (obj == MouseEvent.IconLeftMouseUp)
     {
         LeftClick?.Invoke();
     }
     else if (obj == MouseEvent.IconRightMouseUp)
     {
         RightClick?.Invoke();
     }
 }
コード例 #11
0
    public void OnPointerDown(PointerEventData eventData)
    {
        firstMousePos = eventData.position.y;
        if (Input.GetMouseButtonDown(0))
        {
            LeftClick?.Invoke(eventData);
        }

        if (Input.GetMouseButtonDown(1))
        {
            RightClick?.Invoke(eventData);
        }
    }
コード例 #12
0
 /// <summary>
 /// Create a new UIItemSlot.
 /// </summary>
 /// <param name="position">Position of the slot (px). If parent is not null, position is added to parent position.</param>
 /// <param name="size">Size of the slot</param>
 /// <param name="parent">Parent UIObject</param>
 /// <param name="condition">Condition checked before item is placed in slot. If null, all items are permitted.</param>
 /// <param name="drawBackground">Method run when slot background is drawn. If null, slot is drawn with default background texture.</param>
 /// <param name="drawItem">Method run when item in slot is drawn. If null, item is drawn in center of slot.</param>
 /// <param name="postDrawItem">Method run after item in slot is drawn. Use to draw elements over the item.</param>
 /// <param name="leftClick">Method run when slot is left clicked. Leave null for default behavior.</param>
 /// <param name="rightClick">Method run when slot is right clicked. Leave null for default behavior.</param>
 /// <param name="drawAsNormalItemSlot">Draw as an inventory ItemSlot.</param>
 /// <param name="contextForItemSlot">Context for slot if drawAsNormalItemSlot is true.</param>
 public UIItemSlot(Vector2 position, int size    = 52, UIObject parent = null, Condition condition = null,
                   DrawInItemSlot drawBackground = null, DrawInItemSlot drawItem = null, DrawInItemSlot postDrawItem = null,
                   LeftClick leftClick           = null, RightClick rightClick   = null, bool drawAsNormalItemSlot = false,
                   int contextForItemSlot        = 1) : base(position, new Vector2(size), parent)
 {
     this.item                 = new Item();
     this.conditions           = condition;
     this.drawBack             = drawBackground;
     this.drawItem             = drawItem;
     this.postDrawItem         = postDrawItem;
     this.leftClick            = leftClick;
     this.rightClick           = rightClick;
     this.drawAsNormalItemSlot = drawAsNormalItemSlot;
     this.contextForItemSlot   = contextForItemSlot;
 }
コード例 #13
0
ファイル: CustomButton.cs プロジェクト: arsdever/listen2me
        protected override void OnMouseUp(MouseEventArgs e)
        {
            clickFinished = DateTime.Now;
            IsDown        = false;

            ClickEventArgs args = new ClickEventArgs(
                new System.Windows.Point(e.Location.X, e.Location.Y),
                new System.Windows.Duration(clickFinished - clickStarted)
                );

            if (isHover)
            {
                LeftClick?.Invoke(this, args);
            }

            Refresh();
        }
コード例 #14
0
        public void OnPointerClick(PointerEventData eventData)
        {
            Debug.Log(eventData.button);
            switch (eventData.button)
            {
            case PointerEventData.InputButton.Left:
                LeftClick?.Invoke();
                break;

            case PointerEventData.InputButton.Middle:
                MiddleClick?.Invoke();
                break;

            case PointerEventData.InputButton.Right:
                RightClick?.Invoke();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #15
0
 private void LeftButton_Click(object sender, RoutedEventArgs e)
 {
     DismissWindow();
     LeftClick?.Invoke(this, e);
 }
コード例 #16
0
 public static void Postfix(int x, int y, CoopMenu __instance)
 {
     LeftClick?.Invoke(__instance, x, y);
 }
コード例 #17
0
 public TextNamesColorOfCircle(Game game, Player player)
     : base(game, player)
 {
     leftClick = new LeftClick(game, player);
 }
コード例 #18
0
 private void btnLeft_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     DismissWindow();
     LeftClick?.Invoke(this, e);
 }
コード例 #19
0
 private void btn_Update_Click(object sender, RoutedEventArgs e)
 {
     LeftClick.Invoke(this, e);
 }