コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (!bug)
     {
         //Bouton A pressé, on essaie de passer au mode suivant : si cette action a un effet, on prévient l'objet Punching Ball.
         if (jd.GetButtonDown(Joycon.Button.DPAD_RIGHT))
         {
             if (switchMode())
             {
                 bInstance.setPlayerMode(currentMode.ToString());
             }
         }
         //Bouton B pressé, on essaie de passer au mode précédent : si cette action a un effet, on prévient l'objet Punching Ball.
         if (jd.GetButtonDown(Joycon.Button.DPAD_DOWN))
         {
             if (revertMode())
             {
                 bInstance.setPlayerMode(currentMode.ToString());
             }
         }
         //Tant qu'on est en mode orientation, on change l'angle de rotation.
         if (currentMode == MODE.ORIENTATION)
         {
             timeCounter += Time.deltaTime * speed;
         }
         modeAction();
     }
 }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     joycons = JoyconManager.Instance.j;
     bug     = false;
     if (joycons.Count == 2)
     {
         if (initJoycons())
         {
             aPressed    = false;
             timeCounter = 0;
             speed       = 1;
             //Initialisation des données pour la force d'impact.
             minForce    = 500f;
             force       = minForce;
             maxForce    = 1000f;
             forceIncr   = -5;
             currentMode = MODE.ORIENTATION;
             bInstance   = GameObject.Find("Punching Ball").GetComponent <MG_PBall_PBall>();
             bInstance.setPlayerMode(currentMode.ToString());
             gameObject.GetComponent <Renderer>().material.color = Color.black;
             gameObject.GetComponent <Rigidbody>().constraints   = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation;
         }
         else
         {
             Debug.Log("Absence du joycon droit ou gauche.");
             bug = true;
         }
     }
     else
     {
         Debug.Log("Pas assez ou trop de joycons détectés. Un joycon droit et un gauche nécessaires.");
         bug = true;
     }
 }