Пример #1
0
    /*
     * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
     * SUMMARY: CheckIfMaxHealthChanged
     * If the current entity's max health changes, this function appropriately
     * resizes the heart list, destroying or instantitating heart prefabs
     * as necessary.
     * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
     */
    private void CheckIfMaxHealthChanged()
    {
        int currentHeartCount = heartList.GetCount();

        // Only modify the heart list if the size has changed.
        if (currentHeartCount != entityMaxHealth)
        {
            // If entity has new max number of hearts greater than current
            // number of hearts, resize and spawn new hearts.
            if (currentHeartCount < entityMaxHealth)
            {
                heartList.Resize(entityMaxHealth);

                int startIndex = (currentHeartCount == 0) ? 0 : currentHeartCount - 1; // NOTE: Handles case where current
                                                                                       // heartcount == 0 and changes to some
                                                                                       // positive value.
                for (int i = startIndex; i < entityMaxHealth; i++)
                {
                    SpawnHeartAtOffset(i);
                }
            }

            // If entity has new max number of hearts less than current
            // number of hearts, delete those hearts, and resize the list.
            else if (currentHeartCount > entityMaxHealth)
            {
                for (int i = entityMaxHealth; i < currentHeartCount; i++)
                {
                    Destroy((GameObject)heartList[i]);
                }

                heartList.Resize(entityMaxHealth);
            }
        }
    }
Пример #2
0
    // Cache

    // **********************************************************************
    //                 MONO BEHAVIOUR CLASS OVERLOAD METHODS
    // **********************************************************************

    void Start()
    {
        heartList = new EasyList <GameObject>(GlobalConfigs.ENTITY_MAX_HEALTH, heartPrefab);
        heartList.Resize(entityMaxHealth);

        // Spawn hearts at full health
        for (int i = 0; i < entityMaxHealth; i++)
        {
            SpawnHeartAtOffset(i);
        }
    }
Пример #3
0
    // *****************************************************
    //               MONO BEHAVIOUR OVERRIDE
    // *****************************************************

    // Start is called before the first frame update
    void Start()
    {
        // Cache
        audioSource = GetComponent <AudioSource>();
        userConfigs = FindObjectOfType <UserConfigs>();

        // State
        bins                  = new BinStereo(UserConfigs.MAX_FFT_SIZE);
        bands                 = new FreqBandStereo(userConfigs.numFreqBands);
        bandBufs              = new FreqBandStereo(userConfigs.numFreqBands);
        _bandBufLeftDecrease  = new EasyList <float>(100, userConfigs.bufDecreaseStart); // shouldn't ever be more than 100 freq bands
        _bandBufRightDecrease = new EasyList <float>(100, userConfigs.bufDecreaseStart); // shouldn't ever be more than 100 freq bands
        _bandBufLeftDecrease.Resize(userConfigs.numFreqBands);
        _bandBufRightDecrease.Resize(userConfigs.numFreqBands);

        // Set the audio clip to play
        audioSource.clip = userConfigs.audioClip;
        audioSource.Play();
    }