Exemplo n.º 1
0
    // Fields

    // Methods

    public override void Apply(MonoBehaviour toApplyTo)
    {
        base.Apply(toApplyTo);

        SpriteRenderer spriteRenderer = toApplyTo.GetComponent <SpriteRenderer>();

        // Safety.
        if (spriteRenderer == null)
        {
            NullSpriteRendererAlert(toApplyTo);
        }

        HandleSpriteFlipping(spriteRenderer);

        if (changeSprite)
        {
            spriteRenderer.sprite = newSprite;
        }

        if (changeDrawMode)
        {
            spriteRenderer.drawMode = newDrawMode;
        }

        if (changeMaterial)
        {
            spriteRenderer.material = newMaterial;
        }

        ApplyEnd.Invoke(toApplyTo);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Executes movement based on the movement type specified and input sequence required.
    /// </summary>
    protected virtual IEnumerator ApplyByCoroutine(MonoBehaviour client)
    {
        // Get the necessary components
        Animator animator = client.GetComponent <Animator>();

        // For pausing just before execution
        while (localTimeScale == 0 || !isActive)
        {
            yield return(null);
        }

        HandleMovement(client);

        // TODO: Have animation state changes be their own effect not intrinsically-tied to movement effects
        if (animator != null)
        {
            foreach (AnimatorStateChangeReference stateChange in animStateChanges)
            {
                stateChange.value.Execute(animator);
            }
        }

        // For pausing just after execution
        while (localTimeScale == 0 || !isActive)
        {
            yield return(null);
        }

        ApplyEnd.Invoke(client);
        clients.Remove(client);
    }
Exemplo n.º 3
0
    protected virtual IEnumerator GoThroughChain(MonoBehaviour client)
    {
        //Debug.Log("In GoThroughChain()");

        yield return(client.StartCoroutine(PauseIfNecessary()));

        // Decide how to apply the effects.
        IEnumerator applyEffects = null;

        if (simultaneous)
        {
            applyEffects = ApplySimultaneously(client);
        }
        else
        {
            applyEffects = ApplyOneByOne(client);
        }

        yield return(client.StartCoroutine(applyEffects));

        // The whole chain was executed by this point, so... job's done!
        clients.Remove(client);
        ApplyEnd.Invoke(client);
    }