Example #1
0
 public UniversalDetector(int languageFilter) { 
     this.start = true;
     this.inputState = InputState.PureASCII;
     this.lastChar = 0x00;   
     this.bestGuess = -1;
     this.languageFilter = languageFilter;
 }
Example #2
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (!Game.IsActive)
                return;

            input = new InputState();
            WiimoteLib.PointF ws = wm.WiimoteState.IRState.Midpoint;
            input.Position.X = GameEngine.WIDTH * (1 - ws.X);
            input.Position.Y = GameEngine.HEIGHT * ws.Y;
            float time = gameTime.ElapsedGameTime.Milliseconds; // time elapsed since last update
            Vector2 posDiff = input.Position - buffer.CurrentPosition;
            input.Velocity = posDiff / time;
            WiimoteLib.Point3F acc = wm.WiimoteState.AccelState.Values;
            input.Acceleration = new Vector2(acc.X, acc.Y);

            input.Pause = wm.WiimoteState.ButtonState.Home;
            input.Confirm = wm.WiimoteState.ButtonState.A;

            if (ws.X == 0.0f && ws.Y == 0.0f) // sensor bar out of range
            {
                input.Position = lastPosition;
                posDiff = new Vector2();
            }
            else
            {
                lastPosition = input.Position;
            }

            if (Math.Abs(posDiff.X) > POS_DIFF_THRESHOLD || Math.Abs(posDiff.Y) > POS_DIFF_THRESHOLD) // add only only if the baton has moved at least a decent amount of distance
            {
                buffer.Add(input);
            }
            base.Update(gameTime);
        }
Example #3
0
 void Awake()
 {
     input = serverinput.GetValue(GetComponent<BasePlayer>()) as InputState;
     player = GetComponent<BasePlayer>();
     enabled = true;
     ispressed = false;
 }
Example #4
0
        protected override bool OnHover(InputState state)
        {
            icon.ClearTransformations();

            ResizeTo(size_extended, transform_time, EasingTypes.OutElastic);

            int duration = 0; //(int)(Game.Audio.BeatLength / 2);
            if (duration == 0) duration = pulse_length;

            double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration;
            double startTime = Time.Current + offset;

            // basic pulse
            icon.Transforms.Add(new TransformScale
            {
                StartValue = new Vector2(1.1f),
                EndValue = Vector2.One,
                StartTime = startTime,
                EndTime = startTime + duration,
                Easing = EasingTypes.Out,
                LoopCount = -1,
                LoopDelay = duration
            });

            return true;
        }
Example #5
0
	void Start () {

		//body2D = GetComponent<Rigidbody2D> ();
		player = gameObject.GetComponent<Transform> ();
		player.position = setPosition ((int)Positions.TOP);
		inputState = GetComponent<InputState>();
	}
 public RunnerStatsMessage(RunnerState currentState, Vector3 velocity, CollisionInfo contacts, InputState currentInput)
 {
     CurrentState = currentState;
     Velocity = velocity;
     Contacts = contacts;
     CurrentInput = currentInput;
 }
Example #7
0
        /// <summary>
        /// This is how we hook keyboard/other input.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="allowFull"></param>
        /// <returns></returns>
        public override bool UpdatePlayerActionInput(InputState input, bool allowFull)
        {
            // this is a simple, hard coded example to handle input from a player
            // we can probably add some kind of modifier key here for doing something else cool
            if (input.IsKeyReleased(Keys.OemPlus))
            {
                bool canAutoTarget = false;
                bool canTargetSpace = false;
                bool isAutoTarget;
                bool isTargetBlocked;

                // find something to kill
                ITarget targetHere = this._world.Cursor.GetTargetHere(canAutoTarget, canTargetSpace, out isAutoTarget, out isTargetBlocked);
                if (null != targetHere)
                {
                    // output some data to the debug log
                    DebugLog.Write("Terminating target: {0}", targetHere.DisplayName);

                    // kill it
                    Damage.ApplyDamage(targetHere, targetHere.Health);
                }
            }

            return base.UpdatePlayerActionInput(input, allowFull);
        }
Example #8
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (nameMenuEntry.IsSelected)
                nameMenuEntry.HandleInput(gameTime,input);

            base.HandleInput(gameTime,input);
        }
        public DirectionalIndicator(
                ContentUtil content, 
                InputState.Move move,
                float beatTimeInMs,
                float travelSpeed)
        {
            this.recordings = new List<RecordedStart>();
            this.color = Color.White;
            this.move = move;
            this.beatTimeInMs = beatTimeInMs;
            this.travelSpeed = travelSpeed;
            String texName = "hud/arrow_" + move.ToString().ToLower();
            this.texture = new ScaledTexture(
                content.load<Texture2D>(texName), TEXTURE_SCALE);
            switch (move) {
                case InputState.Move.UP:
                    this.direction = new Vector2(0, 1);
                    break;
                case InputState.Move.DOWN:
                    this.direction = new Vector2(0, -1);
                    break;
                case InputState.Move.LEFT:
                    this.direction = new Vector2(1, 0);
                    break;
                case InputState.Move.RIGHT:
                    this.direction = new Vector2(-1, 0);
                    break;
            }

            this.isMoving = false;
        }
        public override void HandleInput(InputState inputState)
        {
            base.HandleInput(inputState);

            this.mConfirmationDialogComponent.HandleInput(inputState);
            this.mButtonMenuComponent.HandleInput(inputState);
        }
Example #11
0
        //Oxide Hook
        void OnPlayerInput(BasePlayer player, InputState input)
        {
            if (this.allowAdminRotate && player.IsAdmin() && player.GetActiveItem() != null && player.GetActiveItem().info.shortname.Equals("hammer"))
            {
                if (input.WasJustPressed(BUTTON.FIRE_PRIMARY))
                {
                    RaycastHit hit;
                    if (Physics.Raycast(player.eyes.position, (player.eyes.rotation * Vector3.forward), out hit, 2f, Layers.Server.Buildings))
                    {
                        BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity();
                        if (baseEntity != null)
                        {
                            BuildingBlock block = baseEntity.GetComponent<BuildingBlock>();
                            if (block != null && block.blockDefinition.canRotate && !this.instanceIDs.Contains(block.GetInstanceID()))
                            {
                                block.SetFlag(BaseEntity.Flags.Reserved1, true);
                                addBlockToLists(block.GetInstanceID(), DateTime.Now.AddMinutes(-this.amountOfMinutesAfterUpgrade).ToString());

                                int remainingSeconds = timerInterval - DateTime.Now.Subtract(lastTimerTick).Seconds;
                                SendReply(player, "<color=green>You can now rotate this " + block.blockDefinition.info.name.english + " for " + remainingSeconds +  " seconds.</color>");
                            }
                        }
                    }
                }
            }
        }
Example #12
0
 protected virtual void Awake()
 {
     inputState = GetComponent<InputState> ();
     body2d = GetComponent<Rigidbody2D> ();
     collisionState = GetComponent<CollisionState> ();
     spriteRenderer = GetComponent<SpriteRenderer> ();
 }
Example #13
0
    void UpdateEmpty()
    {
        var chrono = FindObjectOfType<Chrono>();
        var disco = FindObjectOfType<Disco>();
        var collider = GetComponent<SphereCollider>();

        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        var info = new RaycastHit();
        var hit = Physics.Raycast(ray, out info);

        if (!hit)
            return;

        var obj = info.collider.gameObject;
        if (!obj)
            return;

        if (obj.CompareTag("Bouncer"))
        {
            hover_object = obj;
            hover_object.GetComponent<Renderer>().material.color = Color.green;

            state = InputState.Hover;
            return;
        }

        if (obj.CompareTag("Palette"))
        {
            hover_object = obj;
            hover_object.GetComponent<Renderer>().material.color = Color.green;

            state = InputState.Hover;
            return;
        }
    }
 private void HandleInput(UserInput button, InputState state)
 {
     if (button == UserInput.A && state == InputState.Ingame)
     {
         m_Jump = true;
     }
 }
Example #15
0
 protected override void HandleInput(UserInput button, InputState state)
 {
     //First we need to define if we are inside the ingame screen
     if (state == InputState.Ingame)
     {
         //If the pressed button equals Start we open the menu screen and disable ingame input
         if (button == UserInput.Start)
         {
             StopAllCoroutines();
             StartCoroutine(OpenPauseMenu());
         }
     }
     //If we are not then maybe we are inside the menus screen?
     else if (state == InputState.PauseMenu)
     {
         switch (button)
         {
             case UserInput.Start:
                 StopAllCoroutines();
                 StartCoroutine(ClosePauseMenu());
                 break;
             case UserInput.Up:
                 Up();
                 break;
             case UserInput.Down:
                 Down();
                 break;
             case UserInput.A:
                 selectedButton.Invoke();
                 break;
         }
     }
 }
 protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState)
 {
     switch(consoleKey.Key)
     {
         case ConsoleKey.End:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 inputState.GotoEnd();
             }
             break;
         case ConsoleKey.Home:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.GotoBegin();
             }
             break;
         case ConsoleKey.LeftArrow:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.CarrageIndex--;
                 Console.Write('\b');
             }
             break;
         case ConsoleKey.RightArrow:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 Console.Write(inputState.Line.ToString().Substring(inputState.CarrageIndex, 1));
                 inputState.CarrageIndex++;
             }
             break;
         default:
             base.ProcessKey(consoleKey, inputState);
             return;
     }
 }
Example #17
0
 protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState)
 {
     switch(consoleKey.Key)
     {
         case ConsoleKey.Backspace:
             if(inputState.CarrageIndex > 0)
             {
                 inputState.Line.Remove(inputState.CarrageIndex - 1, 1);
                 inputState.CarrageIndex--;
                 Console.Write("\b");
                 inputState.RefreshTail(1);
             }
             break;
         case ConsoleKey.Delete:
             if(inputState.CarrageIndex < inputState.Line.Length)
             {
                 inputState.Line.Remove(inputState.CarrageIndex, 1);
                 inputState.RefreshTail(1);
             }
             break;
         default:
             base.ProcessKey(consoleKey, inputState);
             break;
     }
 }
Example #18
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput( InputState input )
        {
            // Move to the previous menu entry?
            if ( input.MenuUp )
            {
                _selectedEntry--;

                if ( _selectedEntry < 0 )
                    _selectedEntry = _menuEntries.Count - 1;

                // AudioManager.PlaySound( "menu_scroll" );
            }

            // Move to the next menu entry?
            if ( input.MenuDown )
            {
                _selectedEntry++;

                if ( _selectedEntry >= _menuEntries.Count )
                    _selectedEntry = 0;

                // AudioManager.PlaySound( "menu_scroll" );
            }

            // Accept or cancel the menu?
            if ( input.MenuSelect )
            {
                // AudioManager.PlaySound( "menu_select" );
                OnSelectEntry( _selectedEntry );
            }
            else if ( input.MenuCancel )
            {
                OnCancel();
            }
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                return;
            }

            // Look up inputs for the active player profile.
            if (ControllingPlayer == null)
            {
                Debug.WriteLine("ControllingPlayer is null...");
                return;
            }
            var playerIndex = (int)ControllingPlayer.Value;

            var keyboardState = input.CurrentKeyboardStates[playerIndex];
            var gamePadState = input.CurrentGamePadStates[playerIndex];

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            var gamePadDisconnected = !gamePadState.IsConnected &&
                                      input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                const string message = "Pause. Do you really want to exit game?";
                var confirmExit = new DecisionScreen(message);
                confirmExit.Accepted += ConfirmExitGameAccepted;
                ScreenManager.AddScreen(confirmExit, ControllingPlayer);
            }
        }
Example #20
0
        public override void Update(GameTime gameTime)
        {
            // TODO: move this to better location
            if (input.Pause && !lastState.Pause)
            {
                switch (gameState.CurrentScreen)
                {
                    case DataTypes.Screens.Title:
                        break;
                    case DataTypes.Screens.SelectLevel:
                        gameState.CurrentScreen = DataTypes.Screens.Title;
                        break;
                    case DataTypes.Screens.WorldMap:
                        gameState.CurrentScreen = DataTypes.Screens.Title;
                        break;
                    case DataTypes.Screens.Pause:
                        gameState.CurrentScreen = gameState.PreviousScreen;
                        break;
                    default:
                        gameState.CurrentScreen = DataTypes.Screens.Pause;
                        break;
                }
            }

            lastState = input;
            gameState.Input = input;
            base.Update(gameTime);
        }
Example #21
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (_saveNameEntry.IsSelected)
                _saveNameEntry.HandleInput(gameTime, input);

            base.HandleInput(gameTime, input);
        }
Example #22
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     if (_activeMenuEntry!=null)
         _activeMenuEntry.HandleInput(gameTime,input);
     else
         base.HandleInput(gameTime, input);
 }
Example #23
0
 /// <summary>
 /// The same as Update() except only active screens get called.
 /// </summary>
 /// <param name="gameTime">Current GameTime</param>
 /// <param name="input">Input Object to access Mouse and Keyboard</param>
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     foreach (IGuiItem menuEntry in MenuEntries)
     {
         menuEntry.HandleInput(input);
     }
 }
        /// <summary>
        ///     Gets the current InputState.
        /// </summary>
        /// <param name="touch">The current touch.</param>
        /// <param name="state">The state to check against.</param>
        /// <returns>True if the InputState matches the current input</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">touch;null</exception>
        public static bool GetState(Touch touch, InputState state)
        {
            #if UNITY_EDITOR
            switch (state)
            {
                case InputState.Began:
                    return Input.GetMouseButtonDown(0);
                case InputState.Moving:
                    return Input.GetMouseButton(0);
                case InputState.Ended:
                    return Input.GetMouseButtonUp(0);
                case InputState.Canceled:
                    return false;
                default:
                    throw new ArgumentOutOfRangeException("touch", state, null);
            }
            #else
            switch (state)
            {
                case InputState.Began:
                    return touch.phase == TouchPhase.Began;
                case InputState.Moving:
                    return touch.phase == TouchPhase.Moved;
                case InputState.Ended:
                    return touch.phase == TouchPhase.Ended;
                case InputState.Canceled:
                    return touch.phase == TouchPhase.Canceled;
                default:
                    throw new ArgumentOutOfRangeException("touchPhase", state, null);
            }

            #endif //UNITY_EDITOR
        }
Example #25
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            GamePadState gamePadState = input.CurrentGamePadState;

            if (pauseAction.Evaluate(input))
            {
                ScreenManager.AddScreen(new PauseScreen());
            }
            else
            {
                Vector2 movement = Vector2.Zero;

                if (input.touchState.Count > 0)
                {
                    Vector2 touchPosition = input.touchState[0].Position;
                    Vector2 direction = touchPosition - playerPosition;
                    direction.Normalize();
                    movement += direction;
                }

                if (movement.Length() > 1)
                    movement.Normalize();

                playerPosition += movement * 8f;
            }
        }
Example #26
0
        /// <summary>
        /// Evaluates the action against a given InputState.
        /// </summary>
        /// <param name="state">The InputState to test for the action.</param>
        /// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
        /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
        /// <returns>True if the action occurred, false otherwise.</returns>
        public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
        {
            // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
            ButtonPress buttonTest;
            KeyPress keyTest;
            if (newPressOnly)
            {
                buttonTest = state.IsNewButtonPress;
                keyTest = state.IsNewKeyPress;
            }
            else
            {
                buttonTest = state.IsButtonPressed;
                keyTest = state.IsKeyPressed;
            }

            // Now we simply need to invoke the appropriate methods for each button and key in our collections
            foreach (Buttons button in buttons)
            {
                if (buttonTest(button, controllingPlayer, out player))
                    return true;
            }
            foreach (Keys key in keys)
            {
                if (keyTest(key, controllingPlayer, out player))
                    return true;
            }

            // If we got here, the action is not matched
            player = PlayerIndex.One;
            return false;
        }
Example #27
0
        void HandleLeftMoveRightAttack(InputState state,Vector3 acc)
        {
            var player = MyPlayerController.Instance;
            Vector3 weapon = new Vector3(Mathf.Clamp(EulerAsin(-acc.z), -45f, 30f), 0, 0);	// 視線
            const float DUMP = 0.4f;	// 減衰

            if(state == InputState.NONE)
            {
                player.ActAttackEnd();
                if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
            }
            else if(state == InputState.MOVE)
            {
                player.ActAttackEnd();
                if (acc.z < 0) player.MoveForward(-acc.z); else player.MoveBack(acc.z);
                if (acc.x > 0) player.MoveRight(acc.x); else player.MoveLeft(-acc.x);
                weapon = Vector3.zero;
            }
            else if(state == InputState.ATTACK)
            {
                player.ActAttackStart();
                if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
            }
            else if(state == InputState.ATTACK_AND_MOVE)
            {
                player.ActAttackStart();
                if (acc.x > 0) player.TurnRight(acc.x * DUMP); else player.TurnLeft(-acc.x * DUMP);
                if (acc.x > 0) player.MoveRight(acc.x * DUMP); else player.MoveLeft(-acc.x * DUMP);
                if (acc.z < 0) player.MoveForward(-acc.z * DUMP); else player.MoveBack(acc.z * DUMP);
            }
            // 視線
            _BufferWeaponAngle = _BufferWeaponAngle * 0.9f + weapon * 0.1f;
            player.WeaponAngle = _BufferWeaponAngle;
        }
Example #28
0
	void Awake () {
		inputState = GetComponent<InputState> ();
		walkBehaviour = GetComponent<Walk> ();
		duckBehaviour = GetComponent<Duck> ();
		animator = GetComponent<Animator> ();
		collisionState = GetComponent<CollisionState> ();
	}
        public override void HandleInput(GameTime gameTime, InputState inputState)
        {
            base.HandleInput(gameTime, inputState);

            if (increaseCountAction.Evaluate(inputState))
            {
                switch (SelectedMenuItemIndex)
                {
                    case 0:
                        verticalNodeCount = verticalNodeCount + 1 > verticalMax ? verticalMax : verticalNodeCount + 1;
                        MenuItems[0].Text = String.Format("Vertical Nodes: {0}", verticalNodeCount);
                        break;
                    case 1:
                        horizontalNodeCount = horizontalNodeCount + 1 > horizontalMax ? horizontalMax : horizontalNodeCount + 1;
                        MenuItems[1].Text = String.Format("Horizontal Nodes: {0}", horizontalNodeCount);
                        break;
                }
            }

            if (decreaseCountAction.Evaluate(inputState))
            {
                switch (SelectedMenuItemIndex)
                {
                    case 0:
                        verticalNodeCount = verticalNodeCount - 1 < verticalMin ? verticalMin : verticalNodeCount - 1;
                        MenuItems[0].Text = String.Format("Vertical Nodes: {0}", verticalNodeCount);
                        break;
                    case 1:
                        horizontalNodeCount = horizontalNodeCount - 1 < horizontalMin ? horizontalMin : horizontalNodeCount - 1;
                        MenuItems[1].Text = String.Format("Horizontal Nodes: {0}", horizontalNodeCount);
                        break;
                }
            }
        }
Example #30
0
 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     INodeIconConstraint constraint1 = this.Constraint;
     SizeF ef1 = constraint1.MinimumIconSize;
     SizeF ef2 = constraint1.MaximumIconSize;
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, ef1, ef2);
 }
 protected override void OnProgress(TElement element, float progress, InputState istate)
 {
     //
 }
Example #32
0
 protected override void OnHoverLost(InputState state)
 {
     updateHoverState();
     base.OnHoverLost(state);
 }
Example #33
0
        public void HandleInput(InputState input)
        {
            Temp_updateCount++;

            ButtonState currentMouseState  = new ButtonState();
            ButtonState previousMouseState = new ButtonState();;

            if (input.CurrentMouseState.MiddleButton == ButtonState.Pressed)
            {
                currentMouseState  = input.CurrentMouseState.MiddleButton;
                previousMouseState = input.PreviousMouseState.MiddleButton;
            }
            else if (input.CurrentMouseState.RightButton == ButtonState.Pressed)
            {
                currentMouseState  = input.CurrentMouseState.RightButton;
                previousMouseState = input.PreviousMouseState.RightButton;
            }

            if (currentMouseState == ButtonState.Pressed)
            {
                ScreenManager.GetInstance().Game.IsMouseVisible = false;
                //Only record position on click
                if (previousMouseState == ButtonState.Released)
                {
                    TEMP_mouseClickPosition = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y);
                }

                TEMP_mouseDelta = input.CurrentMouseState.X - TEMP_mouseClickPosition.X;
                DebugScreen.GetInstance().SetDebugListing("Mouse Delta:", "" + TEMP_mouseDelta);


                RotateCamera(TEMP_mouseDelta);

                if (input.CurrentMouseState.RightButton == ButtonState.Pressed)
                {
                    if (targetObject != null && targetObject is TEMPPlayerActor)
                    {
                        (targetObject as TEMPPlayerActor).Rotation = new Vector3((targetObject as TEMPPlayerActor).Rotation.X, -rotationRadians, (targetObject as TEMPPlayerActor).Rotation.Z);
                    }
                }
                //NOTE: Resetting this position is causing camera rotation to be jerky
                //Don't reset every tick
                //TEMPORARY SOLUTION - need proper way to make mouse rotation smooth
                if (Temp_updateCount % 5 == 0)
                {
                    Mouse.SetPosition((int)TEMP_mouseClickPosition.X, (int)TEMP_mouseClickPosition.Y);
                }
            }
            else
            {
                ScreenManager.GetInstance().Game.IsMouseVisible = true;
            }



            bool trackingObject = false;

            if (targetObject != null)
            {
                /*   if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || isSoftLocked)
                 * {
                 *     trackingObject = true;
                 * }*/
            }
            else
            {
                trackingObject = true;
            }

            if (trackingObject)
            {
                Vector3 positiveCameraDirection = cameraTarget - CameraPosition;
                Vector3 cameraMove = Vector3.Zero;

                isCameraControllable = true;



                //if (input.CurrentKeyboardState.IsKeyDown(Keys.W))
                //{
                //    cameraMove.X -= cameraMoveSpeed;
                //    if (isSoftLocked)
                //    {
                //        targetObject = null;
                //        isSoftLocked = false;
                //    }
                //}

                //if (input.CurrentKeyboardState.IsKeyDown(Keys.D))
                //{
                //    cameraMove.Z -= cameraMoveSpeed;
                //    if (isSoftLocked)
                //    {
                //        targetObject = null;
                //        isSoftLocked = false;
                //    }
                //}
                //if (input.CurrentKeyboardState.IsKeyDown(Keys.S))
                //{
                //    cameraMove.X += cameraMoveSpeed;
                //    if (isSoftLocked)
                //    {
                //        targetObject = null;
                //        isSoftLocked = false;
                //    }

                //}
                //if (input.CurrentKeyboardState.IsKeyDown(Keys.A))
                //{
                //    cameraMove.Z += cameraMoveSpeed;
                //    if (isSoftLocked)
                //    {
                //        targetObject = null;
                //        isSoftLocked = false;
                //    }
                //}

                //if (input.CurrentKeyboardState.IsKeyDown(Keys.Space)/* && input.PreviousKeyboardState.IsKeyUp(Keys.Space)*/)
                //{
                //    if (TEMP_velJump == 0)
                //    {
                //        TEMP_velJump = 0.5f;
                //    }
                //}

                //cameraTarget.Y += TEMP_velJump;
                //TEMP_velJump -= (9.8f / 200);

                //if (cameraTarget.Y < 0)
                //{
                //    cameraTarget.Y = 0;
                //    TEMP_velJump = 0;
                //}


                //Matrix rotationMatrix = Matrix.CreateRotationY(-rotationRadians);
                //Vector3 transformedReference = Vector3.Transform(cameraMove, rotationMatrix);
                //cameraTarget += transformedReference;
            }

            else
            {
                isCameraControllable = false;
            }



            float scrollWheelChange = 0;

            if (input != null)
            {
                scrollWheelChange = input.PreviousMouseState.ScrollWheelValue - input.CurrentMouseState.ScrollWheelValue;
            }


            if (scrollWheelChange < 0 || (input.CurrentKeyboardState.IsKeyDown(Keys.Add) && input.PreviousKeyboardState.IsKeyUp(Keys.Add)))
            {
                ZoomCameraIn();
            }

            else if (scrollWheelChange > 0 || (input.CurrentKeyboardState.IsKeyDown(Keys.Subtract) && input.PreviousKeyboardState.IsKeyUp(Keys.Subtract)))
            {
                ZoomCameraOut();
            }

            if (Temp_updateCount % 60 == 0)
            {
                Temp_updateCount = 0;
            }
        }
Example #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseButtonEventArgs"/> class.
 /// </summary>
 /// <param name="position">Cursor position.</param>
 /// <param name="positionNorm">Normalized position.</param>
 /// <param name="button">Active buttons.</param>
 /// <param name="state">Key and button actions.</param>
 /// <param name="mods">Modifier flags.</param>
 public MouseButtonEventArgs(Vector2 position, Vector2 positionNorm, MouseButton button, InputState state, KeyMods mods)
 {
     Position     = position;
     PositionNorm = positionNorm;
     Button       = button;
     State        = state;
     Mods         = mods;
 }
Example #35
0
        protected override void OnHoverLost(InputState state)
        {
            FadeEdgeEffectTo(0, transition_time, Easing.OutQuint);

            base.OnHoverLost(state);
        }
Example #36
0
        protected override bool OnHover(InputState state)
        {
            FadeEdgeEffectTo(1, transition_time, Easing.OutQuint);

            return(base.OnHover(state));
        }
 public DragEndEvent(InputState state, MouseButton button, Vector2?screenSpaceMouseDownPosition = null)
     : base(state, button, screenSpaceMouseDownPosition)
 {
 }
Example #38
0
 protected override void OnHoverLost(InputState state)
 {
     contract();
     base.OnHoverLost(state);
 }
Example #39
0
 protected override bool OnHover(InputState state)
 {
     expand();
     return(base.OnHover(state));
 }
        private void DrawSetupPhoton()
        {
            this.DrawInputWithLabel("Photon Cloud Setup", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(WizardText.PHOTON, this.textLabelStyle);
                GUILayout.EndVertical();

                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label(WizardText.PHOTON_DASH, this.textLabelStyle);
                if (GUILayout.Button("Visit Dashboard", this.minimalButtonStyle))
                {
                    string mail = (this.inputState == InputState.Email) ? appIdOrEmail : string.Empty;
                    this.OpenURL(EditorIntegration.UrlCloudDashboard + mail)();
                }

                GUILayout.EndHorizontal();
            }, false);
            GUILayout.Space(15);

            this.DrawInputWithLabel("Photon AppID or Email", () =>
            {
                GUILayout.BeginVertical();

                appIdOrEmail = EditorGUILayout.TextField(appIdOrEmail, this.centerInputTextStyle).Trim();   // trimming all input in/of this field

                GUILayout.EndVertical();
            }, false, true, 300);


            // input state check to show dependent info / buttons
            if (AccountService.IsValidEmail(appIdOrEmail))
            {
                this.inputState = InputState.Email;
            }
            else
            {
                this.inputState = AppSettings.IsAppId(appIdOrEmail) ? InputState.Appid : InputState.NotFinished;
            }

            // button to skip setup
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Skip", GUILayout.Width(100)))
            {
                this.requestHighlighSettings = true;
                this.setupState = SetupState.Skip;
            }

            // SETUP button
            EditorGUI.BeginDisabledGroup(this.inputState == InputState.NotFinished || requestingAppId);
            if (GUILayout.Button("Setup", GUILayout.Width(100)))
            {
                this.requestHighlighSettings = true;
                GUIUtility.keyboardControl   = 0;
                if (this.inputState == InputState.Email && !requestingAppId)
                {
                    requestingAppId = new AccountService().RegisterByEmail(appIdOrEmail, new List <ServiceTypes>()
                    {
                        ServiceTypes.Realtime
                    }, SuccessCallback, ErrorCallback, this.originAssetVersion);
                    if (requestingAppId)
                    {
                        EditorUtility.DisplayProgressBar(WizardText.CONNECTION_TITLE, WizardText.CONNECTION_INFO, 0.5f);
                        this.setupState = SetupState.SendingEmail;
                    }
                }
                else if (this.inputState == InputState.Appid)
                {
                    this.setupState = SetupState.AppIdApplied;

                    // Save App ID
                    AppSettingsInstance.AppIdRealtime = appIdOrEmail;
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            switch (this.setupState)
            {
            case SetupState.RegisteredSuccessful:
                GUILayout.Label(WizardText.RegisteredNewAccountInfo, this.textLabelStyle);
                GUILayout.Label(WizardText.SetupCompleteInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.AppIdApplied:
                GUILayout.Label(WizardText.AppliedToSettingsInfo, this.textLabelStyle);
                GUILayout.Label(WizardText.SetupCompleteInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.AlreadyRegistered:
                GUILayout.Label(WizardText.AlreadyRegisteredInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.RegistrationError:
                GUILayout.Label(WizardText.RegistrationError, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.Skip:
                GUILayout.Label(WizardText.SkipRegistrationInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;
            }
        }
 protected virtual void OnExclusiveDown(InputState istate) /* OVERRIDE ME */ }
Example #42
0
        protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
        {
            if (!HasFocus)
            {
                return(false);
            }

            if (textInput?.ImeActive == true)
            {
                return(true);
            }

            switch (args.Key)
            {
            case Key.Tab:
                return(false);

            case Key.End:
                moveSelection(InternalText.Length, state.Keyboard.ShiftPressed);
                return(true);

            case Key.Home:
                moveSelection(-InternalText.Length, state.Keyboard.ShiftPressed);
                return(true);

            case Key.Left:
            {
                if (!HandleLeftRightArrows)
                {
                    return(false);
                }

                if (selectionEnd == 0)
                {
                    //we only clear if you aren't holding shift
                    if (!state.Keyboard.ShiftPressed)
                    {
                        resetSelection();
                    }
                    return(true);
                }

                int amount = 1;
                if (state.Keyboard.ControlPressed)
                {
                    int lastSpace = InternalText.LastIndexOf(' ', Math.Max(0, selectionEnd - 2));
                    if (lastSpace >= 0)
                    {
                        //if you have something selected and shift is not held down
                        //A selection reset is required to select a word inside the current selection
                        if (!state.Keyboard.ShiftPressed)
                        {
                            resetSelection();
                        }
                        amount = selectionEnd - lastSpace - 1;
                    }
                    else
                    {
                        amount = selectionEnd;
                    }
                }

                moveSelection(-amount, state.Keyboard.ShiftPressed);
                return(true);
            }

            case Key.Right:
            {
                if (!HandleLeftRightArrows)
                {
                    return(false);
                }

                if (selectionEnd == InternalText.Length)
                {
                    if (!state.Keyboard.ShiftPressed)
                    {
                        resetSelection();
                    }
                    return(true);
                }

                int amount = 1;
                if (state.Keyboard.ControlPressed)
                {
                    int nextSpace = InternalText.IndexOf(' ', selectionEnd + 1);
                    if (nextSpace >= 0)
                    {
                        if (!state.Keyboard.ShiftPressed)
                        {
                            resetSelection();
                        }
                        amount = nextSpace - selectionEnd;
                    }
                    else
                    {
                        amount = InternalText.Length - selectionEnd;
                    }
                }

                moveSelection(amount, state.Keyboard.ShiftPressed);
                return(true);
            }

            case Key.Enter:
                selectionStart = selectionEnd = 0;
                TriggerFocusLost(state);
                return(true);

            case Key.Delete:
                if (selectionLength == 0)
                {
                    if (InternalText.Length == selectionStart)
                    {
                        return(true);
                    }

                    if (state.Keyboard.ControlPressed)
                    {
                        int spacePos = selectionStart;
                        while (InternalText[spacePos] == ' ' && spacePos < InternalText.Length)
                        {
                            spacePos++;
                        }

                        spacePos     = MathHelper.Clamp(InternalText.IndexOf(' ', spacePos), 0, InternalText.Length);
                        selectionEnd = spacePos;

                        if (selectionStart == 0 && spacePos == 0)
                        {
                            selectionEnd = InternalText.Length;
                        }

                        if (selectionLength == 0)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        //we're deleting in front of the cursor, so move the cursor forward once first
                        selectionStart = selectionEnd = selectionStart + 1;
                    }
                }

                removeCharacterOrSelection();
                return(true);

            case Key.Back:
                if (selectionLength == 0 && state.Keyboard.ControlPressed)
                {
                    int spacePos = selectionLeft >= 2 ? Math.Max(0, InternalText.LastIndexOf(' ', selectionLeft - 2) + 1) : 0;
                    selectionStart = spacePos;
                }

                removeCharacterOrSelection();
                return(true);
            }

            if (state.Keyboard.ControlPressed)
            {
                //handling of function keys
                switch (args.Key)
                {
                case Key.A:
                    selectionStart = 0;
                    selectionEnd   = InternalText.Length;
                    cursorAndLayout.Invalidate();
                    return(true);

                case Key.C:
                    if (string.IsNullOrEmpty(SelectedText) || !AllowClipboardExport)
                    {
                        return(true);
                    }
                    //System.Windows.Forms.Clipboard.SetText(SelectedText);
                    return(true);

                case Key.X:
                    if (string.IsNullOrEmpty(SelectedText))
                    {
                        return(true);
                    }

                    //if (AllowClipboardExport)
                    //    System.Windows.Forms.Clipboard.SetText(SelectedText);
                    removeCharacterOrSelection();
                    return(true);

                case Key.V:
                    //the text is pasted into the hidden textbox, so we don't need any direct clipboard interaction here.
                    insertString(textInput?.GetPendingText());
                    return(true);
                }

                return(false);
            }

            string str = textInput?.GetPendingText();

            if (!string.IsNullOrEmpty(str))
            {
                if (state.Keyboard.ShiftPressed)
                {
                    audio.Sample.Get(@"Keyboard/key-caps")?.Play();
                }
                else
                {
                    audio.Sample.Get($@"Keyboard/key-press-{RNG.Next(1, 5)}")?.Play();
                }
                insertString(str);
            }

            return(true);
        }
Example #43
0
 protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
 {
     doubleClickWord = null;
     return(true);
 }
        public void Update(SAMTime gameTime, InputState istate)
        {
            if (istate.IsExclusiveJustDown && innerBoundings.Contains(istate.GamePointerPositionOnMap))
            {
                istate.Swallow(InputConsumer.GameEntity);
                OnExclusiveDown(istate);
            }

            if (Fraction.KICycleWaitQueue.Any() && Owner.CannonMap[Fraction.KICycleWaitQueue.Peek()].Fraction != Fraction)
            {
                SAMLog.Warning("AFC::DirtyCycleQueue", $"Cycle Queue for {Fraction.Type} contains {Fraction.KICycleWaitQueue.Peek()} ({Owner.CannonMap[Fraction.KICycleWaitQueue.Peek()].Fraction.Type})");
                Fraction.KICycleWaitQueue.Clear();
                return;
            }

            bool queuePriority = false;

            if (Fraction.KICycleWaitQueue.Any() && Fraction.KICycleWaitQueue.Peek() == Cannon.BlueprintCannonID)
            {
                Fraction.KICycleWaitQueue.Dequeue();
                queuePriority = true;
            }

            timeUntilNextUpdate -= gameTime.ElapsedSeconds;
            if (timeUntilNextUpdate <= 0)
            {
                if (onlySingleUpdate)
                {
                    if (timeUntilNextUpdate < -KIController.MAX_UPDATE_TIME)
                    {
                        SAMLog.Warning("AFC::QTIMEOUT", $"Overriding SingleUpdate condition - Max wait time overstepped for cannon {Cannon.BlueprintCannonID}");

                        DoUpdate(gameTime, istate);
                        return;                         // F**k it, we have waited long enough, now it's our turn
                    }

                    if (Fraction.LastKiSingleCycle == MonoSAMGame.GameCycleCounter)
                    {
                        if (_isWaitingForQueue)
                        {
                            Fraction.KICycleWaitQueue.Enqueue(Cannon.BlueprintCannonID);
                        }
                        _isWaitingForQueue = true;
                        return;                         // We want - but someone else was first
                    }

                    if (Fraction.KICycleWaitQueue.Count == 0)
                    {
                        DoUpdate(gameTime, istate);
                        return;                         // We want and we don't have to wait
                    }

                    if (Fraction.KICycleWaitQueue.Count > 128)
                    {
                        SAMLog.Warning("AFC::QFULL", $"Fraction.KICycleWaitQueue is full for cannon {Cannon.BlueprintCannonID}");

                        return;                         // Queue is full - we delay our update
                    }

                    if (queuePriority)
                    {
                        DoUpdate(gameTime, istate);
                        return;                         // We want and its out turn
                    }

                    Fraction.KICycleWaitQueue.Enqueue(Cannon.BlueprintCannonID);
                    _isWaitingForQueue = true;
                    return;                     // We want - but someone else has priority
                }
                else
                {
                    DoUpdate(gameTime, istate);
                    return;
                }
            }
        }
Example #45
0
 protected override bool OnDragEnd(InputState state)
 {
     dragContainer.MoveTo(Vector2.Zero, 800, EasingTypes.OutElastic);
     return(base.OnDragEnd(state));
 }
Example #46
0
 protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
Example #47
0
 protected override bool OnDragStart(InputState state) => true;
Example #48
0
 public DragEvent(InputState state, MouseButton button, Vector2?screenSpaceMousePosition = null, Vector2?screenSpaceLastMousePosition = null)
     : base(state, button, screenSpaceMousePosition)
 {
     ScreenSpaceLastMousePosition = screenSpaceLastMousePosition ?? state.Mouse.Position;
 }
Example #49
0
        /// <summary>
        /// Handles input
        /// </summary>
        /// <param name="gameTime">the game's time</param>
        /// <param name="input">the inputs</param>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            var keyboardState = input.CurrentKeyboardStates[playerIndex];
            var gamePadState  = input.CurrentGamePadStates[playerIndex];

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex];

            PlayerIndex player;

            if (_pauseAction.Occurred(input, ControllingPlayer, out player) || gamePadDisconnected)
            {
                ScreenManager.AddScreen(new PauseMenuScreen(_game), ControllingPlayer);
            }
            else
            {
                // Otherwise move the player position.
                var movement = Vector2.Zero;

                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    movement.X--;
                }

                if (keyboardState.IsKeyDown(Keys.Right))
                {
                    movement.X++;
                }

                if (keyboardState.IsKeyDown(Keys.Up))
                {
                    movement.Y--;
                }

                if (keyboardState.IsKeyDown(Keys.Down))
                {
                    movement.Y++;
                }

                var thumbstick = gamePadState.ThumbSticks.Left;

                movement.X += thumbstick.X;
                movement.Y -= thumbstick.Y;

                if (movement.Length() > 1)
                {
                    movement.Normalize();
                }

                _playerPosition += movement * 8f;
            }
        }
Example #50
0
 protected override void OnHoverLost(InputState state)
 {
     solidBackground.FadeTo(alpha_normal, transition_time, Easing.OutQuint);
     gradientBackground.FadeOut(transition_time, Easing.OutQuint);
 }
Example #51
0
 protected override void OnAfterUpdate(SAMTime gameTime, InputState state)
 {
     // NOP
 }
Example #52
0
 protected override void OnProgress(Bullet entity, float progress, SAMTime gameTime, InputState istate)
 {
     entity.BulletExtraScale = progress;
 }
Example #53
0
 protected new void OnNextUpdate()
 {
     base.OnNextUpdate();
     InputState.Change(scroll, Vector2.zero);
 }
 protected override void OnPress(InputState istate)
 {
     MainGame.Inst.GDBridge.OpenURL(GDConstants.URL_BLACKFORESTBYTES);
 }
 protected override void OnPress(InputState istate)
 {
     MainGame.Inst.Profile.ColorblindMode = !MainGame.Inst.Profile.ColorblindMode;
     MainGame.Inst.SaveProfile();
 }
Example #56
0
 protected override bool OnHover(InputState state)
 {
     solidBackground.FadeTo(alpha_hovering, transition_time, Easing.OutQuint);
     gradientBackground.FadeIn(transition_time, Easing.OutQuint);
     return(true);
 }
Example #57
0
 protected override void OnFocusLost(InputState state)
 {
     finalise();
     base.OnFocusLost(state);
 }
Example #58
0
 protected override bool OnHover(InputState state)
 {
     updateHoverState();
     return(base.OnHover(state));
 }
Example #59
0
 protected override bool OnClick(InputState state) => true;
 protected override void OnPress(InputState istate)
 {
     MainGame.Inst.GDBridge.OpenURL(GDConstants.URL_REDDIT);
 }