Пример #1
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Greys out buttons if they are down.
    /// </summary>
    private void ChangeButtonColor()
    {
        if (gamepad.GetButton("B"))
        {
            for (int i = 0; i < ButtonImage.Count; i++)
            {
                ButtonImage[i].color = Color.grey;
            }
        }
        else if (!gamepad.GetButton("B"))
        {
            for (int i = 0; i < ButtonImage.Count; i++)
            {
                ButtonImage[i].color = Color.white;
            }
        }
    }
Пример #2
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // Update is called once per frame
    void Update()
    {
        NavigateSettingsMenu();
        SwitchSettings();
        ChangeControllerText();
        if (SchemeWrapper.activeInHierarchy)
        {
            if (gamepad.GetButton("B"))
            {
                SchemeWrapper.SetActive(false);
                SettingsBase.SetActive(true);
                StartCoroutine(DelayedSelect(SettingInfo.GamePadSchemes));
            }
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    private void DisplayButtonUI()
    {
        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
        RaycastHit hit;

        //Fire raycast from middle of the screen.
        if (Physics.Raycast(ray, out hit, 1000, _PlayerAttached._HUD.MaskBlock))
        {
            if (hit.transform.gameObject.tag != "Ground" && !GameManager.Instance.SelectionWheel.activeInHierarchy)
            {
                AButton.enabled = true;
                if (_Gamepad.GetButton("A"))
                {
                    AButton.color = Color.grey;
                }
                else
                {
                    AButton.color = Color.white;
                }
            }
            else
            {
                AButton.enabled = false;
            }

            if (hit.transform.gameObject.tag == "Ground" && _PlayerAttached.SelectedWorldObjects.Count > 0)
            {
                XButton.enabled = true;
                if (_Gamepad.GetButton("X"))
                {
                    XButton.color = Color.grey;
                }
                else
                {
                    XButton.color = Color.white;
                }
            }
            else
            {
                XButton.enabled = false;
            }
        }
    }
Пример #4
0
    ///////////////////////////////////////////////////////////////////

    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime * 100;

        if (Input.GetMouseButtonDown(1))
        {
            _PreviousTransform = _Camera.transform;
            _LineStartPoint    = GetMouseCameraPoint();
            StartGO            = hud.FindHitObject();
            LineStartPoint     = hud.FindHitPoint();
        }
        else if (Input.GetMouseButton(1))
        {
            LineEndPoint = GetMouseCameraPoint();
            if (newobject == null)
            {
                newobject    = new GameObject();
                lineRenderer = newobject.AddComponent <LineRenderer>();
            }

            if (lineRenderer != null)
            {
                lineRenderer.material = LineMaterial;

                lineRenderer.SetPositions(new Vector3[] { _LineStartPoint, LineEndPoint });
                lineRenderer.startWidth = LineWidth;
                lineRenderer.endWidth   = LineWidth;
            }
        }
        if (Input.GetMouseButtonUp(1))
        {
            Destroy(newobject);
            MouseEndPoint = hud.FindHitPoint();
            EndGO         = hud.FindHitObject();
        }

        if (GameManager.Instance.Players[0]._XboxGamepadInputManager.GetButtonXClicked())
        {
            _LineStartPoint = GetCentrePoint();
            LineEndPoint    = GetCentrePoint();
        }
        else if (gamepad.GetButton("X"))
        {
            if (newobject == null)
            {
                newobject    = new GameObject();
                lineRenderer = newobject.AddComponent <LineRenderer>();
            }
            lineRenderer.material = LineMaterial;
            _LineStartPoint       = GetCentrePoint((Screen.width / 2) - timer, Screen.height / 2);
            LineEndPoint          = GetCentrePoint((Screen.width / 2) + timer, Screen.height / 2);
            lineRenderer.SetPositions(new Vector3[] { _LineStartPoint, LineEndPoint });
            lineRenderer.startWidth = LineWidth;
            lineRenderer.endWidth   = LineWidth;
        }

        if (GameManager.Instance.Players[0]._XboxGamepadInputManager.GetButtonXReleased())
        {
            timer = 2;
            Destroy(newobject);
        }
    }