Пример #1
0
    }    //awake

    IEnumerator ChangePlayerColorInSeconds()
    {
        yield return(new WaitForSeconds(1f));

        colorChooserTimer--;
        if (colorChooserTimer <= 0)
        {
            if (GamePreferences.GetSoundSetting() == 1)
            {
                AudioSource.PlayClipAtPoint(boxChangeSound, gameObject.transform.position);
            }
            string prevColor = playerBoxColorString;
            playerBoxColorString = AllColors.GET_RANDOM_COLOR_STRING();
            //more randmized
            if (prevColor == playerBoxColorString)
            {
                playerBoxColorString = AllColors.GET_RANDOM_COLOR_STRING();
            }
            Debug.Log("New COlor " + playerBoxColorString);
            colorChooserTimer = 10;
        }        //timer is at 10

        if (Player.isAlive)
        {
            StartCoroutine("ChangePlayerColorInSeconds");
        }
        else
        {
            StopCoroutine("ChangePlayerColorInSeconds");
        }
    }    //ChangePlayerColor
Пример #2
0
    }    //generateCircleObjects

    void Explode()
    {
        Box.colorCode = AllColors.GET_RANDOM_COLOR_STRING();
        var trans = gameObject.transform;

        for (int i = 0; i < 12; i++)
        {
            var temp = trans.position;
            temp.x += (10f * Random.Range(-10, 10));
            temp.y += (5f * Random.Range(-10, 10));
            CircleBoxPieces clone = Instantiate(circleBoxPiece, temp, Quaternion.identity) as CircleBoxPieces;
            // adding force to sideways
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.right * Random.Range(-10, 10) * 500);
            //adding force to up
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.up * Random.Range(-10, -1) * 600);
        } //loop of explode
    }     //explode
Пример #3
0
    void Awake()
    {
        Time.timeScale       = 1f;
        isAlive              = true;
        direction            = 0;
        score                = 0;
        indicatorHeight      = 0.15f;
        playerBoxColorString = AllColors.GET_RANDOM_COLOR_STRING();

        indicatorObject = gameObject.transform.GetChild(0).gameObject;
        boundaryX       = CameraProp.GetCameraWidth(Camera.main) / 2 - 55f;

        //default
        indicatorObject.transform.localScale = new Vector3(1f, indicatorHeight, 1f);
        colorChooserTimer = 10;

        StopAllCoroutines();
        StopCoroutine("ChangePlayerColorInSeconds");
        StartCoroutine("ChangePlayerColorInSeconds");
    }    //awake