Example #1
0
    // Use this for initialization
    void Start()
    {
        carMove      = GetComponent <CarMovement>();
        partsFlinger = GetComponentInChildren <PartsFlungOutOfCar> ();
        for (int i = 0; i < partsArray.Length; i++)
        {
            partsArray[i] = true;
        }
        nextBreakTime = Random.Range(minBreakTime, maxBreakTime);

        shellHealth = maxShellHealth;
        dmgUI       = FindObjectOfType <DamageIndicator>();
        dmgUI.UpdateIndicator();
    }
Example #2
0
    public void damageCar()
    {
        if (invincibilityCounter > 0.5)
        {
            invincibilityCounter = 0;
            ArrayList workingParts = new ArrayList();
            for (int i = 0; i < partsArray.Length; i++)
            {
                if (partsArray[i])
                {
                    workingParts.Add(i);
                }
            }

            if (workingParts.Count > 0)
            {
                float brokenPart = Random.Range(0, workingParts.Count);
                partsFlinger.throwParts((partsList)brokenPart);
                partsArray[(int)workingParts[(int)brokenPart]] = false;
                Debug.Log("Broke:" + (int)workingParts[(int)brokenPart]);
            }
        }
        dmgUI.UpdateIndicator();
    }