示例#1
0
        private void CheckIfShouldThrust()
        {
            if (fuel >= initialThrustFuelConsumption)
            {
                bool shouldThrust = false;

#if UNITY_STANDALONE || UNITY_WEBGL
                shouldThrust = !MathE.IsPointerOverUIObject(Input.mousePosition) && (Input.GetMouseButton(0) || Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow));
#elif UNITY_IOS || UNITY_ANDROID
                if (Input.touchCount > 0)
                {
                    Touch touch = Input.GetTouch(0);

                    shouldThrust = !MathE.IsPointerOverUIObject(touch.position);
                }
#endif

                if (shouldThrust && !isThrusting && !PlayerEffectsController.Singleton.HasPlayerEffect(PlayerEffect.InfiniteFuel))
                {
                    AddFuel(-initialThrustFuelConsumption);
                }

                isThrusting = shouldThrust;
            }
            else
            {
                isThrusting = false;
            }
        }
示例#2
0
        private void AimHyperdrive()
        {
            float direction = 0f;

#if UNITY_STANDALONE
            if (!MathE.IsPointerOverUIObject(Input.mousePosition) && Input.GetMouseButton(0))
            {
                Vector2 point = mainCamera.ScreenToWorldPoint(Input.mousePosition);

                direction = Mathf.Clamp(point.y - transform.position.y, -1f, 1f);
            }
            else
            {
                if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
                {
                    direction = 1f;
                }
                else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
                {
                    direction = -1f;
                }
            }
#elif UNITY_IOS || UNITY_ANDROID
            if (Input.touchCount > 0)
            {
                Touch touch = Input.GetTouch(0);

                if (!MathE.IsPointerOverUIObject(touch.position))
                {
                    Vector2 point = mainCamera.ScreenToWorldPoint(touch.position);

                    direction = Mathf.Clamp(point.y - transform.position.y, -1f, 1f);
                }
            }
#endif

            transform.position += Vector3.up * hyperdriveMoveSpeed * direction * Time.deltaTime;
            transform.position  = new Vector3(0f, Mathf.Clamp(transform.position.y, -MapController.Singleton.ScreenHeight / 2f, MapController.Singleton.ScreenHeight / 2f));
        }