Example #1
0
    public void Initialize()
    {
        gameObject.SetActive(true);
        int tileIndex = (int)parentTile.tileType;

        // Reset stuff
        disappearing = false;
        cachedTrans.localPosition = new Vector3(cachedTrans.localPosition.x, defaultY, cachedTrans.localPosition.z);
        cachedTrans.localRotation = Quaternion.identity;

        InsectSettings.SpecialType specialType = GetRandomSpecialInsectType();

        if (specialType == InsectSettings.SpecialType.None)
        {
            SetNormalInsect(tileIndex);
        }
        else
        {
            SetSpecialInsect(specialType);
        }

        frameIndex = Random.Range(0f, frameCount);
        DisplayAnimationFrame(frameIndex);

        // Randomize insect rotation.
        int rotateAmount = Random.Range(0, 4);

        if (rotateAmount > 0)
        {
            cachedTrans.Rotate(0f, rotateAmount * 90f, 0f, Space.World);
        }
    }
Example #2
0
    private void SetSpecialInsect(InsectSettings.SpecialType type)
    {
        // Disable all regular insects.
        for (int i = 0; i < insectSettings.Length; i++)
        {
            UpdateInsectRenderer(insectSettings[i], false);
        }

        // Enable special insect.
        int index = (int)type - 1;

        for (int i = 0; i < specialInsects.Length; i++)
        {
            UpdateInsectRenderer(specialInsects[i], i == index);
        }
    }