Exemple #1
0
    void Awake()
    {
        if (PlayerPrefs.GetInt("FirstTime") == 1)
        {
            longInstruction.gameObject.SetActive(true);
            ShortInstruction.gameObject.SetActive(true);
        }
        SwipeScript.speedUpVal = 0;
        speed = 4;
        doublePointText.gameObject.SetActive(false);
        timeText.gameObject.SetActive(false);
        switch (UseBall.colour)
        {
        case UseBall.COLOURS.BLUE:
            gameObject.GetComponent <Renderer>().material = _BlueMaterial;
            PlayerPrefs.SetInt("SuckerPower", 1);
            int blueball = PlayerPrefs.GetInt("BlueBalls");
            blueball--;
            PlayerPrefs.SetInt("BlueBalls", blueball);
            startingPower = true;
            break;

        case UseBall.COLOURS.YELLOW:
            gameObject.GetComponent <Renderer>().material = _YellowMaterial;
            SwipeScript.IncreaseSpeed();
            int yellowBall = PlayerPrefs.GetInt("YellowBalls");
            yellowBall--;
            PlayerPrefs.SetInt("YellowBalls", yellowBall);
            startingPower = true;
            break;

        case UseBall.COLOURS.RED:
            gameObject.GetComponent <Renderer>().material     = _RedMaterial;
            gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionY;
            int redBall = PlayerPrefs.GetInt("RedBalls");
            redBall--;
            PlayerPrefs.SetInt("RedBalls", redBall);
            startingPower = true;
            break;

        case UseBall.COLOURS.GREEN:
            gameObject.GetComponent <Renderer>().material = _GreenMaterial;
            int greenBall = PlayerPrefs.GetInt("GreenBalls");
            greenBall--;
            PlayerPrefs.SetInt("GreenBalls", greenBall);
            startingPower = true;
            break;

        case UseBall.COLOURS.ORANGE:
            gameObject.GetComponent <Renderer> ().material = _OrangeMaterial;
            SwipeScript.DecreaseSpeed();
            int orangeBall = PlayerPrefs.GetInt("OrangeBalls");
            orangeBall--;
            PlayerPrefs.SetInt("OrangeBalls", orangeBall);
            startingPower = true;
            break;

        default:
            gameObject.GetComponent <Renderer>().material = _OriginalMaterial;
            break;
        }
    }
Exemple #2
0
    void DoubleTimeMaterial()
    {
        GameObject baller = GameObject.Find("Ball");

        //GameObject baller = GameObject.Find("Pokeball");
        if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _BlueMaterial || baller.gameObject.GetComponent <Renderer>().sharedMaterial == _RedMaterial ||
            baller.gameObject.GetComponent <Renderer>().sharedMaterial == _GreenMaterial || baller.gameObject.GetComponent <Renderer>().sharedMaterial == _YellowMaterial ||
            baller.gameObject.GetComponent <Renderer>().sharedMaterial == _OrangeMaterial)
        {
            powerUp = true;
            doublePointText.gameObject.SetActive(true);
            if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _GreenMaterial)
            {
                doublePointText.text = "DOUBLE POINTS";
            }
            if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _YellowMaterial)
            {
                doublePointText.text = "SONIC SPEED";
                SwipeScript.IncreaseSpeed();
            }
            if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _BlueMaterial)
            {
                doublePointText.text = "SONIC SUCTION";
            }
            if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _RedMaterial)
            {
                doublePointText.text = "ANTI-GRAVITY";
            }
            if (baller.gameObject.GetComponent <Renderer> ().sharedMaterial == _OrangeMaterial)
            {
                doublePointText.text = "SLOW MOTION";
                SwipeScript.DecreaseSpeed();
            }


            timeText.gameObject.SetActive(true);

            if (startTimer)
            {
                timer += Time.deltaTime;
            }

            if (startingPower)
            {
                timeText.text = Convert.ToString(Convert.ToInt32(60.0f - timer));
            }
            else
            {
                timeText.text = Convert.ToString(Convert.ToInt32(15.0f - timer));
            }

            if ((startingPower && timer > 60) || (!startingPower && timer > 15))
            {
                powerUp = false;
                timeText.gameObject.SetActive(false);
                doublePointText.gameObject.SetActive(false);
                if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _BlueMaterial)
                {
                    PlayerPrefs.SetInt("SuckerPower", 0);
                }
                if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _RedMaterial)
                {
                    baller.gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                }
                if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _YellowMaterial)
                {
                    SwipeScript.speed -= 2;
                }
                if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _OrangeMaterial)
                {
                    SwipeScript.speed += 2;
                }

                if (startingPower)
                {
                    baller.gameObject.GetComponent <Renderer>().material = _OriginalMaterial;
                    doublePointText.gameObject.SetActive(false);
                    startingPower = false;
                }

                baller.gameObject.GetComponent <Renderer>().material = _OriginalMaterial;
                UseBall.colour = UseBall.COLOURS.NONE;
                PlayerPrefs.SetInt("RedPickUp", 0);
                PlayerPrefs.SetInt("BluePickUp", 0);
                PlayerPrefs.SetInt("OrangePickUp", 0);
                PlayerPrefs.SetInt("YellowPickUp", 0);
                PlayerPrefs.SetInt("GreenPickUp", 0);
                timer = 0;
            }
        }
    }