Exemple #1
0
        protected void Update()
        {
            Vector2 look = PInput.GetLook();

            transform.Rotate(Vector3.up * look.x * _lookSpeed * Time.deltaTime, Space.World);

            Vector2 move   = PInput.GetMove();
            Vector3 offset = new Vector3(move.x, 0, move.y) * _moveSpeed * Time.deltaTime;

            transform.position += transform.rotation * offset;

            _device.text = PInput.IsUsingGamepad ? "Using Gamepad" : "Using Keyboard & Mouse";

            bool inputThisFrame = false;

            for (int i = 0; i < System.Enum.GetValues(typeof(PAction)).Length; i++)
            {
                if (PInput.GetInputDown((PAction)i))
                {
                    if (_reachedMaxHistory)
                    {
                        _historyStrings.RemoveAt(0);
                    }

                    if (inputThisFrame)
                    {
                        _historyStrings.Add(" (+) " + ((PAction)i).ToString() + "\n");
                    }
                    else
                    {
                        _historyStrings.Add(Time.frameCount + " " + ((PAction)i).ToString() + "\n");
                    }

                    inputThisFrame = true;

                    if (_reachedMaxHistory == false)
                    {
                        _reachedMaxHistory = _historyStrings.Count >= MAX_HISTORY_COUNT;
                    }
                }
            }

            if (inputThisFrame)
            {
                StringBuilder historyText = new StringBuilder();
                foreach (string str in _historyStrings)
                {
                    historyText.Append(str);
                }
                _history.text = historyText.ToString();
            }
        }