Пример #1
0
 // Use this for initialization
 void Awake()
 {
     buttonKey           = EasyWiFiController.registerControl(EasyWiFiConstants.CONTROLLERTYPE_BUTTON, controlName);
     button              = (ButtonControllerType)EasyWiFiController.controllerDataDictionary[buttonKey];
     currentImage        = gameObject.GetComponent <Image>();
     buttonRegularSprite = currentImage.sprite;
 }
Пример #2
0
        // Use this for initialization
        void Awake()
        {
            buttonKey = EasyWiFiController.registerControl(EasyWiFiConstants.CONTROLLERTYPE_BUTTON, controlName);
            button    = (ButtonControllerType)EasyWiFiController.controllerDataDictionary[buttonKey];

            GetComponent <Button>().onClick.AddListener(OnButtonPressed);
        }
 protected override void Awake()
 {
     base.Awake();
     if (Application.isPlaying)
     {
         buttonKey = EasyWiFiController.registerControl(EasyWiFiConstants.CONTROLLERTYPE_BUTTON, controlName);
         button    = (ButtonControllerType)EasyWiFiController.controllerDataDictionary[buttonKey];
     }
 }
 public void startGame(ButtonControllerType button)
 {
     if (button.BUTTON_STATE_IS_PRESSED)
     {
         if (isLocked)
         {
             //we can only vote to start the game if we've already chosen
             cc.startGameScene();
         }
     }
 }
 public void setRed(ButtonControllerType redButton)
 {
     if (redButton.BUTTON_STATE_IS_PRESSED)
     {
         isRed = true;
     }
     else
     {
         isRed = false;
     }
 }
 public void setBlue(ButtonControllerType blueButton)
 {
     if (blueButton.BUTTON_STATE_IS_PRESSED)
     {
         isBlue = true;
     }
     else
     {
         isBlue = false;
     }
 }
 public void setGreen(ButtonControllerType greenButton)
 {
     if (greenButton.BUTTON_STATE_IS_PRESSED)
     {
         isGreen = true;
     }
     else
     {
         isGreen = false;
     }
 }
Пример #8
0
        void Awake()
        {
            buttonKey           = EasyWiFiController.registerControl(EasyWiFiConstants.CONTROLLERTYPE_BUTTON, controlName);
            button              = (ButtonControllerType)EasyWiFiController.controllerDataDictionary[buttonKey];
            currentImage        = gameObject.GetComponent <Image>();
            buttonRegularSprite = currentImage.sprite;

            lowPassFilterFactor      = accelerometerUpdateInterval / lowPassKernelWidthInSeconds;
            shakeDetectionThreshold *= shakeDetectionThreshold;
            lowPassValue             = Input.acceleration;
        }
    void changeColor(ButtonControllerType button)
    {
        isPressed = button.BUTTON_STATE_IS_PRESSED;

        if (isPressed)
        {
            myMaterial.color = Color.green;
        }
        else
        {
            myMaterial.color = originalColor;
        }
    }
 public void unAssignPlayer(ButtonControllerType button)
 {
     if (button.BUTTON_STATE_IS_PRESSED)
     {
         if (isLocked)
         {
             cc.unAssignPlayerIndex(currentLogicalPlayer, lockedArea);
             isLocked       = false;
             sprite.color   = Color.white;
             lockedPosition = Vector3.zero;
             lockedArea     = -1;
         }
     }
 }
 public void brakePedal(ButtonControllerType brakeButton)
 {
     if (brakeButton.BUTTON_STATE_IS_PRESSED)
     {
         if (myRigidbody.velocity.magnitude > 1f)
         {
             myRigidbody.AddForce(myRigidbody.velocity * -myRigidbody.velocity.magnitude);
         }
         else
         {
             myRigidbody.AddForce(myRigidbody.velocity * -myRigidbody.velocity.magnitude * 10f);
         }
     }
 }
 //human example scene methods (gaspedal, brakepedal, and steerball)
 public void gasPedal(ButtonControllerType gasButton)
 {
     if (gasButton.BUTTON_STATE_IS_PRESSED)
     {
         if (myRigidbody.velocity.magnitude > 1f)
         {
             myRigidbody.AddForce(myRigidbody.velocity * sensitivity * .5f);
         }
         else
         {
             myRigidbody.AddForce((this.transform.position - Camera.main.transform.position) * sensitivity * 5f);
         }
     }
 }
Пример #13
0
    void changeColor(ButtonControllerType button)
    {
        isPressed = button.BUTTON_STATE_IS_PRESSED;

        if (isPressed)
        {
            if ((GyroServer.isStartAverage == false) && (GyroServer.isEndAverage == false))
            {
                GyroServer.GetComponent <MatchOrientationGyroServerController>().StartCalculatePosition();
            }
        }
        else
        {
            myMaterial.color = originalColor;
        }
    }
    public void assignPlayer(ButtonControllerType button)
    {
        if (button.BUTTON_STATE_IS_PRESSED)
        {
            if (!isLocked)
            {
                bool result = false;

                //check to see if the position is in one of the player areas
                if (myRT.position.x >= (p1Center.x - 100) &&
                    myRT.position.x <= (p1Center.x + 100) &&
                    myRT.position.y >= (p1Center.y - 100) &&
                    myRT.position.y <= (p1Center.y + 100))
                {
                    //in player 1 area
                    lockedArea = 0;
                    result     = cc.assignPlayerIndex(currentLogicalPlayer, lockedArea);
                }
                else if (myRT.position.x >= (p2Center.x - 100) &&
                         myRT.position.x <= (p2Center.x + 100) &&
                         myRT.position.y >= (p2Center.y - 100) &&
                         myRT.position.y <= (p2Center.y + 100))
                {
                    //in player 2 area
                    lockedArea = 1;
                    result     = cc.assignPlayerIndex(currentLogicalPlayer, lockedArea);
                }
                else if (myRT.position.x >= (p3Center.x - 100) &&
                         myRT.position.x <= (p3Center.x + 100) &&
                         myRT.position.y >= (p3Center.y - 100) &&
                         myRT.position.y <= (p3Center.y + 100))
                {
                    //in player 3 area
                    lockedArea = 2;
                    result     = cc.assignPlayerIndex(currentLogicalPlayer, lockedArea);
                }
                else if (myRT.position.x >= (p4Center.x - 100) &&
                         myRT.position.x <= (p4Center.x + 100) &&
                         myRT.position.y >= (p4Center.y - 100) &&
                         myRT.position.y <= (p4Center.y + 100))
                {
                    //in player 4 area
                    lockedArea = 3;
                    result     = cc.assignPlayerIndex(currentLogicalPlayer, lockedArea);
                }

                //check to see if we've successfully locked
                if (result == true)
                {
                    isLocked       = true;
                    sprite.color   = Color.gray;
                    lockedPosition = this.transform.position;
                }
                else
                {
                    //unsuccessful lock (means occupied by another already so reset locked area
                    lockedArea = -1;
                }
            }
        }
    }