public void Clear()
 {
     /*halmeida - no need to clear the particle controller because it will be done when clearing the
      * animator of the obstacle. Instead we just point away from it.*/
     /*if( particleController != null )
      * {
      *      particleController.Clear();
      *      particleController = null;
      * }*/
     particleController = null;
     if (debrisAnimators != null)
     {
         for (int i = 0; i < debrisAnimators.Length; i++)
         {
             debrisAnimators[i].Clear();
             debrisAnimators[i] = null;
             Destroy(debrisObjects[i]);
             debrisObjects[i] = null;
         }
         debrisAnimators = null;
         debrisObjects   = null;
     }
     obstacleCollider = null;
     if (obstacleAnimator != null)
     {
         obstacleAnimator.Clear();
         obstacleAnimator = null;
     }
     ClearAllSoundsFromResources();
     ClearAllSoundsFromAudioCenter();
 }
    void Awake()
    {
        obstacleCollider         = GetComponent <Collider2D>();
        obstacleAnimator         = GetComponent <ShortLifeAnimator>();
        maxHP                    = (obstacleHP > 0f) ? obstacleHP : 1f;
        currentHP                = maxHP;
        destroyed                = false;
        over                     = false;
        damageWaveLength         = (damageWaveLength < 0f) ? 0f : damageWaveLength;
        debrisDensityDamage      = (debrisDensityDamage < 0f) ? 0f : debrisDensityDamage;
        debrisDensityDestruction = (debrisDensityDestruction < 0f) ? 0f : debrisDensityDestruction;
        waveColorDamage          = Color.white;
        waveColorRecovery        = new Color(0.8f, 1f, 0.8f, 1f);
        waveFrontLimit           = 3f * damageWaveLength;
        waveLengths              = new Vector4(damageWaveLength, damageWaveLength / 4f, damageWaveLength / 8f, damageWaveLength / 12f);
        waveAlphas               = new Vector4(1f, 0.7f, 0.45f, 0.2f);
        waveSpeed                = 10f * damageWaveLength;
        debrisSlotDamage         = (debrisDensityDamage > 0f) ? (1f / debrisDensityDamage) : 0f;
        debrisSlotDestruction    = (debrisDensityDestruction > 0f) ? (1f / debrisDensityDestruction) : 0f;
        debrisObjects            = null;
        debrisAnimators          = null;
        debrisDepth              = DisplayDepthManager.ELEMENT_TO_ELEMENT_OFFSET / BaseAnimator.MAX_ANIMATORS_WITHIN_LAYER;
        colliderWidth            = 0f;
        colliderHeight           = 0f;
        if (obstacleCollider != null)
        {
            colliderWidth  = obstacleCollider.bounds.size.x;
            colliderHeight = obstacleCollider.bounds.size.y;
        }
        debrisExtraDelay   = (extraDebrisDelay > 0f) ? extraDebrisDelay : 0f;
        debrisExtraElapsed = 0f;
        particleController = GetComponent <VFXParticleController>();

        audioSourceDamage   = null;
        damageInSounds      = null;
        damageInSoundIDs    = null;
        destructionSounds   = null;
        destructionSoundIDs = null;

        /*halmeida - the AudioCenter is a plugin for reducing latency of sounds in Android devices. It also supports the sound
         * playback outside of the Android environment, but that support is really poor, with a single AudioSource. Because
         * of that, I don't wanna use it unless we are within the android environment.*/
                #if !UNITY_ANDROID || UNITY_EDITOR
        AddAudioSources();
        LoadAllSoundsFromResources();
                #else
        LoadAllSoundsIntoAudioCenter();
                #endif
    }
示例#3
0
    public override bool EvolveAppearance(float changeFactor)
    {
        VFXParticleController particleController = null;
        float valueOne = 0f;
        float valueTwo = 0f;

        if (base.EvolveAppearance(changeFactor) && (layersAnimator != null))
        {
            switch (appearanceLevel)
            {
            case APPEARANCE_LEVEL_SECOND:
                if (opaqueAlphasFirstUpgrade != null)
                {
                    for (int i = 0; i < opaqueAlphasFirstUpgrade.Length; i++)
                    {
                        layersAnimator.SetLayerOpaqueAlpha(i, opaqueAlphasFirstUpgrade[i]);
                        layersAnimator.StartLayerAlphaFading(i, fadeSpeed, false);
                    }
                }
                break;

            case APPEARANCE_LEVEL_LAST:
                if (opaqueAlphasSecondUpgrade != null)
                {
                    for (int i = 0; i < opaqueAlphasSecondUpgrade.Length; i++)
                    {
                        layersAnimator.SetLayerOpaqueAlpha(i, opaqueAlphasSecondUpgrade[i]);
                        layersAnimator.StartLayerAlphaFading(i, fadeSpeed, false);
                    }
                }
                particleController = layersAnimator.GetParticleController();
                if ((particleController != null) && (changeFactor > 1f))
                {
                    valueOne  = particleController.GetWindowDuration();
                    valueOne *= (2f - changeFactor);
                    particleController.SetWindowDuration(valueOne);
                    valueOne = particleController.GetFocusMaximumRadius() * changeFactor;
                    valueTwo = particleController.GetFocusMinimumRadius() * changeFactor;
                    particleController.SetFocusOffsetRadiusRange(valueOne, valueTwo);
                }
                break;
            }
            return(true);
        }
        return(false);
    }
示例#4
0
    protected virtual void Awake()
    {
        particleController  = null;
        childAnimatorBack   = null;
        childAnimatorFront  = null;
        shadowObjects       = null;
        shadows             = null;
        pausedShadowObjects = null;
        pausedShadows       = null;
        Clear(false);
        if (ExtractRenderingComponent())
        {
            opaqueAlpha   = ExtractRenderingColor().a;
            currentAlpha  = opaqueAlpha;
            fadedToOpaque = true;
            FillSequencesArray();
            if ((sequenceObjects != null) && (totalSequences > 0))
            {
                firstIndexPerSequence = new int[totalSequences];
                lastIndexPerSequence  = new int[totalSequences];
                speedPerSequence      = new float[totalSequences];
                loopPerSequence       = new bool[totalSequences];
                fakeLightPerSequence  = new FakeLight[totalSequences];
                ExtractSpritesAndLights();
                Progress(0f);
            }
        }

        /*halmeida - I wil extract the associated particle controller but I will not yet set this animator
         * as that particle controller's focus provider, cause the awake on that particle controller may still
         * be called causing it to lose the reference to this script.*/
        particleController = gameObject.GetComponent <VFXParticleController>();

        /*halmeida - Every class derived from this BaseAnimator will inherit the childAnimator field as a
         * BaseAnimator instance which is severely limiting. To allow subclasses to have more complex child
         * animators, we allow the extraction and operations over the child to be customized.*/
        /*halmeida - if a certain child of the object should show in front of it or behind it is unknown.
         * To standardize, we  will assume the first animated child to be behind and ignore the rest.*/
        RecognizeBackChildAnimator();
    }
示例#5
0
    public virtual void Clear(bool renderingComponentInitialized = true)
    {
        FakeLight fakeLight = null;

        if (renderingComponentInitialized)
        {
            FeedRenderingComponent(null, null, false);
        }
        ClearRenderingComponent();
        sequenceObjects       = null;
        totalSequences        = 0;
        sequenceIndex         = -1;
        sprites               = null;
        sprite                = null;
        spriteNormals         = null;
        spriteNormal          = null;
        focusOffsetsOne       = null;
        focusOffsetsTwo       = null;
        focusOffsetOne        = Vector2.zero;
        focusOffsetTwo        = Vector2.zero;
        focusOneValidities    = null;
        focusTwoValidities    = null;
        focusOneValidity      = false;
        focusTwoValidity      = false;
        spriteIndex           = -1;
        spriteElapsed         = 0f;
        spriteFlip            = false;
        spriteWidth           = 0f;
        firstIndexPerSequence = null;
        lastIndexPerSequence  = null;
        speedPerSequence      = null;
        loopPerSequence       = null;
        if (fakeLightPerSequence != null)
        {
            for (int i = 0; i < fakeLightPerSequence.Length; i++)
            {
                fakeLight = fakeLightPerSequence[i];
                if (fakeLight != null)
                {
                    fakeLight.Clear();
                    fakeLightPerSequence[i] = null;
                }
            }
        }
        fakeLightPerSequence = null;
        firstIndex           = -1;
        lastIndex            = -1;
        spriteDuration       = 0f;
        loop = false;
        keepSequenceProgress = false;
        status             = INVALID_STATUS;
        previousStatus     = INVALID_STATUS;
        over               = false;
        forceSpriteFeeding = false;
        fadeSpeed          = 0f;
        fadeImmediately    = false;
        fadedToTransparent = false;
        fadedToOpaque      = false;
        opaqueAlpha        = 0f;
        currentAlpha       = 0f;
        paused             = false;
        ClearShadows();
        if (particleController != null)
        {
            particleController.Clear();
            particleController = null;
        }
        childSeparation     = DisplayDepthManager.ELEMENT_TO_ELEMENT_OFFSET / MAX_ANIMATORS_WITHIN_LAYER;
        childObjectBack     = null;
        childObjectFront    = null;
        childTransformBack  = null;
        childTransformFront = null;
        ClearChildAnimators();
    }