Ejemplo n.º 1
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         OnSpacePressed?.Invoke();
     }
 }
Ejemplo n.º 2
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         OnSpacePressed?.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 3
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && !_isStarted)
     {
         Time.timeScale = 1;
         OnSpacePressed?.Invoke(this, EventArgs.Empty); //Call event to start start timer (facepalm, cringe)
         _isStarted = true;
     }
 }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         OnSpacePressed?.Invoke(this, new OnSpacePressedEventArgs {
             myTestEventArgsFloat = 30.0f
         });
     }
 }
Ejemplo n.º 5
0
        private void Update(bool y)
        {
            if (y)
            {
                //if(OnSpacePressed != null)
                //    OnSpacePressed(x, EventArgs.Empty); // chamar o evento como se fosse uma função

                OnSpacePressed?.Invoke(this, EventArgs.Empty); // o mesmo que o if acima
                // invoke é executar o evento
            }
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         //Space Pressed!
         spaceCount++;
         //if(OnSpacePressed != null) OnSpacePressed(this, EventArgs.Empty);//
         OnSpacePressed?.Invoke(this, new OnSpacePressedEventArgs {
             spaceCount = spaceCount
         });
     }
 }
Ejemplo n.º 7
0
        public void StartListning()
        {
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);

                if (key.Key.Equals(ConsoleKey.A))
                {
                    OnAPressed?.Invoke(this, new EventArgs());
                }
                else if (key.Key.Equals(ConsoleKey.D))
                {
                    OnDPressed?.Invoke(this, new EventArgs());
                }
                else if (key.Key.Equals(ConsoleKey.Spacebar))
                {
                    OnSpacePressed?.Invoke(this, new EventArgs());
                }
                else
                {
                }
            }
        }
        public void StartListerning()
        {
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                if (key.Key.Equals(ConsoleKey.LeftArrow))
                {
                    OnLeftPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.RightArrow))
                {
                    OnRightPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Spacebar))
                {
                    OnSpacePressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.R))
                {
                    OnKeyRPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Q))
                {
                    OnKeyQPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Escape))
                {
                    OnEscPressed?.Invoke(this, new EventArgs());
                }
            }
        }
Ejemplo n.º 9
0
        private void Update()
        {
            if (CheckKey(KeyCode.W))
            {
                OnWPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.W);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.A))
            {
                OnAPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.A);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.S))
            {
                OnSPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.S);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.D))
            {
                OnDPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.D);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.Space))
            {
                OnSpacePressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.Space);
                OnKeyPressed?.Invoke(this, args);
            }

            RunKey(KeyCode.G);
            RunKey(KeyCode.H);
            RunKey(KeyCode.Q);
            RunKey(KeyCode.Escape);

            var scrollDelta = Input.GetAxis("Mouse ScrollWheel");

            if (scrollDelta != 0.0F)
            {
                ScrollEventArgs args;
                if (scrollDelta > 0.0F)
                {
                    args = new ScrollEventArgs(true);
                    OnScrollUp?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    args = new ScrollEventArgs(false);
                    OnScrollDown?.Invoke(this, EventArgs.Empty);
                }
                OnScroll?.Invoke(this, args);
            }

            if (CheckMouseSingle(MouseButton.LEFT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.LEFT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnLeftMouseClick?.Invoke(this, args);
            }
            if (CheckMouseSingle(MouseButton.RIGHT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.RIGHT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnRightMouseClick?.Invoke(this, args);
            }
        }
Ejemplo n.º 10
0
 private void OnKeyPressed(object sender, KeyEventArgs e)
 {
     if (started)
     {
         if (stop == 0)
         {
             if (e.Code == Keyboard.Key.W)
             {
                 if (!up)
                 {
                     _updateY += -1;
                     up        = true;
                 }
             }
             else if (e.Code == Keyboard.Key.S)
             {
                 if (!down)
                 {
                     _updateY += 1;
                     down      = true;
                 }
             }
             else if (e.Code == Keyboard.Key.A)
             {
                 if (!left)
                 {
                     _updateX += -1;
                     left      = true;
                 }
             }
             else if (e.Code == Keyboard.Key.D)
             {
                 if (!right)
                 {
                     _updateX += 1;
                     right     = true;
                 }
             }
             else if (e.Code == Keyboard.Key.R)
             {
                 roundOver = !roundOver;
             }
         }
         if (roundOver)
         {
             if (e.Code == Keyboard.Key.E)
             {
                 if (stop == 0)
                 {
                     stop     = 2;
                     _updateX = 0;
                     _updateY = 0;
                     up       = false;
                     down     = false;
                     left     = false;
                     right    = false;
                     OnEPressed?.Invoke();
                 }
                 else if (stop == 2)
                 {
                     stop = 0;
                     OnEPressed?.Invoke();
                 }
             }
             else if (e.Code == Keyboard.Key.Escape)
             {
                 if (stop == 0)
                 {
                     stop     = 1;
                     _updateX = 0;
                     _updateY = 0;
                     up       = false;
                     down     = false;
                     left     = false;
                     right    = false;
                     OnEscapePressed?.Invoke();
                 }
                 else if (stop == 1)
                 {
                     stop = 0;
                     OnEscapePressed?.Invoke();
                 }
                 else if (stop == 2)
                 {
                     stop = 0;
                     OnEPressed?.Invoke();
                 }
             }
         }
         else if (!roundOver)
         {
             if (e.Code == Keyboard.Key.Space)
             {
                 if (stop == 0)
                 {
                     stop     = 3;
                     _updateX = 0;
                     _updateY = 0;
                     up       = false;
                     down     = false;
                     left     = false;
                     right    = false;
                     OnSpacePressed?.Invoke();
                 }
                 else if (stop == 3)
                 {
                     stop = 0;
                     OnSpacePressed?.Invoke();
                 }
             }
         }
     }
 }