Exemple #1
0
    void updateBrick(float dt)
    {
        //Check if timer is at 5 seconds and block is Good before attempting to set to leaking
        if ((int)dt == timeToLeak && BC == brickCondition.Good)
        {
            //Random Chance to set block to leaking
            if (Random.Range(0, 2) != 0)
            {
                setBlockColor(Color.blue);
                BC = brickCondition.Leaking;

                Debug.Log("LEAKING");
                isLeaking = true;
                animator.SetBool("isLeaking", true);
                GetComponent <AudioSource>().PlayOneShot(leaking);
                Failures = 0;
            }
            else if (maxFailures == Failures)
            {
                setBlockColor(Color.blue);
                BC        = brickCondition.Leaking;
                isLeaking = true;
                animator.SetBool("isLeaking", true);
                GetComponent <AudioSource>().PlayOneShot(leaking);
                Debug.Log("MAX FAILURE LEAK");
            }
            else
            {
                Debug.Log("Didn't Leak");
                Failures++;
            }


            //Reset Timer to enable rechecking leaking if random failed
            timer = 0;
        }
        else if ((int)dt == timeToBreak && BC == brickCondition.Leaking)
        {
            BC = brickCondition.Broken;
            setBlockColor(Color.red);

            Debug.Log("BROKEN");

            //Reset timer after block breaks
            timer = 0;

            isLeaking = false;
            animator.SetBool("isBroken", true);
            GetComponent <AudioSource>().PlayOneShot(broken);
            //Block cannot be repaired therefore stop updating
            isBroken = true;
            BoxCollider BoC = GetComponent <BoxCollider>();
            BoC.isTrigger = false;
        }
    }
Exemple #2
0
 void setCondition(brickCondition state)
 {
     BC = state;
 }