Exemplo n.º 1
0
    void Update()
    {
        //for if the controller was off when the game started
        if (!device.isValid)
        {
            SetHand(isRightHand);
        }

        /*bool triggerValue;
         * if(triggerDown && device.TryGetFeatureValue(UnityEngine.XR.CommonUsages.triggerButton, out triggerValue) && !triggerValue)
         * {
         *  triggerDown = false;
         * }*/
        if (!triggerDown && triggerValue > triggerDownThreshold)
        {
            triggerDown = true;
        }
        else if (triggerDown && triggerValue < triggerUpThreshold)
        {
            triggerDown = false;
        }
        Vector2 axisValue;

        device.TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxis, out axisValue);
        float xAxis = axisValue[0];

        if (xAxis > flickThreshold)
        {
            currentStickPosition = StickPosition.RIGHT;
        }
        else if (xAxis < -flickThreshold)
        {
            currentStickPosition = StickPosition.LEFT;
        }
        else
        {
            currentStickPosition = StickPosition.CENTER;
        }
    }
    private void UpgradeRobotFromJoystick(StickPosition _currentStickPosition)
    {
        if (TurnManager.Instance.CurrentTurnState == TurnManager.TurnState.upgrade && GameManager.isSomeAnimationGoing == false && GameManager.isTutorialOn == false)
        {
            if (Input.GetKeyUp(KeyCode.Joystick1Button0) && TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
            {
                switch (_currentStickPosition)
                {
                case StickPosition.N:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 1, 2);
                    //am.Freccia_Nord_Curve.SetActive(false);
                    break;

                case StickPosition.NE:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 2, 2);
                    //am.Freccia_Nord_Est_Curve.SetActive(false);
                    break;

                case StickPosition.E:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 2, 1);
                    //am.Freccia_Est_Curve.SetActive(false);
                    break;

                case StickPosition.SE:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 2, 0);
                    //am.Freccia_Sud_Est_Curve.SetActive(false);
                    break;

                case StickPosition.S:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 1, 0);
                    //am.Freccia_Sud_Curve.SetActive(false);
                    break;

                case StickPosition.SW:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 0, 0);
                    //am.Freccia_Sud_Ovest_Curve.SetActive(false);
                    break;

                case StickPosition.W:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 0, 1);
                    //am.Freccia_Ovest_Curve.SetActive(false);
                    break;

                case StickPosition.NW:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotCurviInHand, 0, 2);
                    //am.Freccia_Nord_Ovest_Curve.SetActive(false);
                    break;

                default:
                    break;
                }
            }
            else if (Input.GetKeyUp(KeyCode.Joystick2Button0) && TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
            {
                switch (_currentStickPosition)
                {
                case StickPosition.N:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 1, 6);
                    //am.Freccia_Nord_Quad.SetActive(false);
                    break;

                case StickPosition.NE:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 2, 6);
                    //am.Freccia_Nord_Est_Quad.SetActive(false);
                    break;

                case StickPosition.E:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 2, 5);
                    //am.Freccia_Est_Quad.SetActive(false);
                    break;

                case StickPosition.SE:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 2, 4);
                    //am.Freccia_Sud_Est_Quad.SetActive(false);
                    break;

                case StickPosition.S:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 1, 4);
                    //am.Freccia_Sud_Quad.SetActive(false);
                    break;

                case StickPosition.SW:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 0, 4);
                    //am.Freccia_Sud_Ovest_Quad.SetActive(false);
                    break;

                case StickPosition.W:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 0, 5);
                    //am.Freccia_Ovest_Quad.SetActive(false);
                    break;

                case StickPosition.NW:
                    RobotManager.Instance.JoystickRobotUpgrade(RobotManager.Instance.RobotQuadratiInHand, 0, 6);
                    //am.Freccia_Nord_Ovest_Quad.SetActive(false);
                    break;

                default:
                    break;
                }
            }
        }
    }
 public void StickOrientation(string xAxis, string yAxis)
 {
     if (GameManager.isSomeAnimationGoing == false && GameManager.isTutorialOn == false)
     {
         if ((Input.GetAxis(xAxis) > -0.2f && Input.GetAxis(xAxis) < 0.2f) && (Input.GetAxis(yAxis) > -0.2f && Input.GetAxis(yAxis) < 0.2f))
         {
             CurrentStickPosition = StickPosition.C;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
             }
         }
         else if ((Input.GetAxis(xAxis) > 0.3f && Input.GetAxis(xAxis) < 1f) && (Input.GetAxis(yAxis) > 0.3f && Input.GetAxis(yAxis) < 1f))
         {
             CurrentStickPosition = StickPosition.NE;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Nord_Est_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Nord_Est_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if ((Input.GetAxis(xAxis) > 0.3f && Input.GetAxis(xAxis) < 1f) && (Input.GetAxis(yAxis) < -0.3f && Input.GetAxis(yAxis) > -1f))
         {
             CurrentStickPosition = StickPosition.SE;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Sud_Est_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Sud_Est_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if ((Input.GetAxis(xAxis) < -0.3f && Input.GetAxis(xAxis) > -1f) && (Input.GetAxis(yAxis) > 0.3f && Input.GetAxis(yAxis) < 1f))
         {
             CurrentStickPosition = StickPosition.NW;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Nord_Ovest_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Nord_Ovest_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if ((Input.GetAxis(xAxis) < -0.3f && Input.GetAxis(xAxis) > -1f) && (Input.GetAxis(yAxis) < -0.3f && Input.GetAxis(yAxis) > -1f))
         {
             CurrentStickPosition = StickPosition.SW;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Sud_Ovest_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Sud_Ovest_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if (Input.GetAxis(xAxis) < -0.5f)
         {
             CurrentStickPosition = StickPosition.W;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Ovest_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Ovest_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if (Input.GetAxis(xAxis) > 0.5f)
         {
             CurrentStickPosition = StickPosition.E;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Est_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Est_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if (Input.GetAxis(yAxis) < -0.5f)
         {
             CurrentStickPosition = StickPosition.S;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Sud_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Sud_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
         else if (Input.GetAxis(yAxis) > 0.5f)
         {
             CurrentStickPosition = StickPosition.N;
             if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Curve_Turn)
             {
                 am.ResetAllCurveMaterials();
                 am.Freccia_Nord_Curve.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             else if (TurnManager.Instance.CurrentPlayerTurn == PlayerTurn.Quad_Turn)
             {
                 am.ResetAllQuadMaterials();
                 am.Freccia_Nord_Quad.GetComponent <Renderer>().material = am.HighlightMaterial;
             }
             PlayRobotFromJoystick(CurrentStickPosition);
             UpgradeRobotFromJoystick(CurrentStickPosition);
         }
     }
 }
Exemplo n.º 4
0
 public void LiftReleased()
 {
     liftPushed = false;
       stickPosition = divePushed ? StickPosition.Dive : StickPosition.Neutral;
 }
Exemplo n.º 5
0
 public void LiftPushed()
 {
     liftPushed = true;
       stickPosition = StickPosition.Lift;
 }
Exemplo n.º 6
0
 public void DiveReleased()
 {
     divePushed = false;
       stickPosition = liftPushed ? StickPosition.Lift : StickPosition.Neutral;
 }
Exemplo n.º 7
0
 public void DivePushed()
 {
     divePushed = true;
       stickPosition = StickPosition.Dive;
 }
Exemplo n.º 8
0
 public bool IsRightStickInPosition(StickPosition position)
 {
     return(ConvertVectorDirectionToStickPosition(_currentGamePadState[(int)_activePlayerIndex].ThumbSticks.Left) == position);
 }
Exemplo n.º 9
0
 public bool IsRightStickInPosition(StickPosition position)
 {
     return ConvertVectorDirectionToStickPosition(_currentGamePadState[(int)_activePlayerIndex].ThumbSticks.Left) == position;
 }