示例#1
0
    void Start()
    {
        _instance = this;
        temp      = new UIItemsMatrix();
//		Debug.Log ("Start");
//		(temp.itemMatrix [0] as RowItems<UIButton>).items [1].state = UIButtonColor.State.Hover;
        temp.LightItem(UIItemsState.Hover);
        TargetCamera = GameObject.Find("FPSController/Main Camera").transform;

//		Debug.Log (HighestAngle + " " + LowestAngle);
    }
示例#2
0
    void Update()
    {
        preState = state;
        state    = GamePad.GetState(playerIndex);
        if (!playerIndexSet || !preState.IsConnected)
        {
            for (int i = 0; i < 4; ++i)
            {
                PlayerIndex  testPlayerIndex = (PlayerIndex)i;
                GamePadState testState       = GamePad.GetState(testPlayerIndex);
                if (testState.IsConnected)
                {
                    Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                    playerIndex    = testPlayerIndex;
                    playerIndexSet = true;
                }
            }
        }
        if (!ShowMainPanel)
        {
            if ((preState.DPad.Up == ButtonState.Released && state.DPad.Up == ButtonState.Pressed) || Input.GetKeyDown(KeyCode.I))
            {
                temp.Up();
//			Debug.Log("Up");
            }
            if ((preState.DPad.Down == ButtonState.Released && state.DPad.Down == ButtonState.Pressed) || Input.GetKeyDown(KeyCode.K))
            {
                temp.Down();
//			Debug.Log("Down");
            }
            if ((preState.DPad.Left == ButtonState.Released && state.DPad.Left == ButtonState.Pressed) || Input.GetKeyDown(KeyCode.J))
            {
                temp.Left();
//			Debug.Log("Left");
            }
            if ((preState.DPad.Right == ButtonState.Released && state.DPad.Right == ButtonState.Pressed) || Input.GetKeyDown(KeyCode.L))
            {
                temp.Right();
//			Debug.Log("Right");
            }

            if ((preState.Buttons.A == ButtonState.Released && state.Buttons.A == ButtonState.Pressed) || Input.GetMouseButtonDown(0))
            {
                temp.LightItem(UIItemsState.Pressed);
                if (temp.itemMatrix [temp.x] is RowItems <UIButton> )
                {
                    RowItems <UIButton> button = temp.itemMatrix [temp.x] as RowItems <UIButton>;
//				Debug.Log(temp.x + " " + temp.ob.y);
                    button.items [button.y].gameObject.GetComponent <MyUIEventIndex> ().Invoke();
                }
            }
            if ((preState.Buttons.A == ButtonState.Pressed && state.Buttons.A == ButtonState.Released) || Input.GetMouseButtonUp(0))
            {
                if (Time.frameCount > 1)
                {
                    temp.LightItem(UIItemsState.Hover);
                }
            }
        }
        if ((preState.Buttons.Y == ButtonState.Released && state.Buttons.Y == ButtonState.Pressed) || Input.GetKeyDown(KeyCode.Y))
        {
            if (Time.frameCount > 1)
            {
                if (ShowMainPanel)
                {
                    ShowMainPanel = !ShowMainPanel;
                    MainPanel.PlayForward();
                    //MainPanelTwist.enabled = false;
                }
                else
                {
                    ShowMainPanel = !ShowMainPanel;
                    MainPanel.PlayReverse();
                    //MainPanelTwist.enabled = true;
                }
            }
        }
        if (!VRDevice.isPresent)
        {
            if (state.ThumbSticks.Right.X != 0 || state.ThumbSticks.Right.Y != 0)
            {
                if (TargetCamera != null)
                {
                    if ((TargetCamera.localEulerAngles.x > HighestAngle || TargetCamera.localEulerAngles.x < LowestAngle) ||
                        (TargetCamera.eulerAngles.x < HighestAngle && state.ThumbSticks.Right.Y < 0 && TargetCamera.eulerAngles.x > HighestAngle - 10) ||
                        (TargetCamera.eulerAngles.x > LowestAngle && state.ThumbSticks.Right.Y > 0 && TargetCamera.eulerAngles.x < LowestAngle + 10))
                    {
                        TargetCamera.Rotate(Vector3.right, -state.ThumbSticks.Right.Y * YSencitive * Time.deltaTime);
                    }
                    TargetCamera.parent.Rotate(Vector3.up, state.ThumbSticks.Right.X * XSencitive * Time.deltaTime);
                    TargetCamera.rotation = Quaternion.Euler(new Vector3(TargetCamera.eulerAngles.x, TargetCamera.eulerAngles.y, 0));
                }
                else
                {
                    Debug.Log("TargetCamera is null, please check.");
                }
            }
        }
    }