Exemplo n.º 1
0
    public IEnumerator ActivateCompanion(Enemy e, int i)
    {
        // random delay before starting routine
        yield return(new WaitForSeconds(Random.Range(0f, 0.5f)));

        // randomize the orientation of the sprite a bit (flip, position)
        SpriteRenderer sr       = companions[i].GetComponent <SpriteRenderer> ();
        float          f        = UtilMethods.RandSign();
        Vector3        position = e.transform.position + new Vector3(f * 0.5f, 0);      // offset sprite

        sr.flipX = f > 0;

        TempObject            tempObj = companions[i].GetComponent <TempObject> ();
        SimpleAnimationPlayer anim    = companions[i].GetComponent <SimpleAnimationPlayer> ();

        anim.anim = companionAnimations [Random.Range(0, companionAnimations.Length)];
        tempObj.Init(Quaternion.identity,
                     position,
                     anim.anim.frames [0]);
        anim.Play();

        yield return(new WaitForSeconds(0.2f));

        DamageEnemy(e, 1);
    }
Exemplo n.º 2
0
        // [Header("Effects")]
        // public SimpleAnimation onShootAnim, inFlightAnim, onCollideAnim;
        // public TempObjectInfo onShootEffect, onCollideEffect;

        void Awake()
        {
            rb2d     = GetComponent <Rigidbody2D>();
            sr       = GetComponent <SpriteRenderer>();
            box      = GetComponent <BoxCollider2D>();
            animator = GetComponent <SimpleAnimationPlayer>();
            // set the collider size to match the sprite
            box.size = size;
        }
Exemplo n.º 3
0
    public static void PlayEffect(SimpleAnimation toPlay, Vector3 position, TempObjectInfo info)
    {
        GameObject            o       = instance.GetPooledObject();
        SimpleAnimationPlayer anim    = o.GetComponent <SimpleAnimationPlayer>();
        TempObject            tempObj = o.GetComponent <TempObject>();

        tempObj.info = info;
        anim.anim    = toPlay;
        tempObj.Init(Quaternion.identity,
                     position,
                     toPlay.frames[0]);
        anim.Play();
    }
Exemplo n.º 4
0
    private void PlayDeathEffect(Vector3 position, SimpleAnimation effect)
    {
        GameObject            o          = EffectPooler.instance.GetPooledObject();
        SimpleAnimationPlayer animPlayer = o.GetComponent <SimpleAnimationPlayer>();
        TempObject            tempObj    = o.GetComponent <TempObject>();

        tempObj.GetComponent <SpriteRenderer>().sortingLayerName = "UI";
        tempObj.info    = new TempObjectInfo(true, 0f, effect.TimeLength - 2f, 1f);
        animPlayer.anim = effect;
        tempObj.Init(Quaternion.identity,
                     position,
                     effect.frames[0]);
        animPlayer.ignoreTimeScaling = true;
        animPlayer.Play();
    }
Exemplo n.º 5
0
    void OnEnable()
    {
        timeAlive = 0;
        SimpleAnimationPlayer anim = GetComponent <SimpleAnimationPlayer>();

        if (energyAmount > BIG_ENERGY_THRESHOLD)
        {
            anim.anim = bigAnim;
        }
        else
        {
            anim.anim = smallAnim;
        }
        anim.Play();
    }
Exemplo n.º 6
0
    private void SmokeEffect()
    {
        TempObject     smokeBomb = effectsPool.GetPooledObject().GetComponent <TempObject> ();
        TempObjectInfo info      = new TempObjectInfo(true,
                                                      0f,
                                                      smokeBombEffect.TimeLength * 0.9f,
                                                      smokeBombEffect.TimeLength * 0.1f,
                                                      new Color(1, 1, 1, 0.7f));
        SimpleAnimationPlayer animPlayer = smokeBomb.GetComponent <SimpleAnimationPlayer> ();

        animPlayer.anim = smokeBombEffect;
        smokeBomb.Init(
            Quaternion.identity,
            transform.position,
            smokeBombEffect.frames[0],
            info
            );
        animPlayer.Play();
    }
Exemplo n.º 7
0
    public static void PlayEffect(SimpleAnimation toPlay, Vector3 position, bool randRotation = false, float fadeOutTime = 0f)
    {
        GameObject            o       = instance.GetPooledObject();
        SimpleAnimationPlayer anim    = o.GetComponent <SimpleAnimationPlayer>();
        TempObject            tempObj = o.GetComponent <TempObject>();

        tempObj.info = new TempObjectInfo(true, 0f, toPlay.TimeLength - fadeOutTime, fadeOutTime, new Color(1, 1, 1, 0.8f));
        anim.anim    = toPlay;
        Quaternion rot;

        if (randRotation)
        {
            rot = Quaternion.Euler(0, 0, Random.Range(0, 360));
        }
        else
        {
            rot = Quaternion.identity;
        }
        tempObj.Init(rot,
                     position,
                     toPlay.frames[0]);
        anim.Play();
    }
Exemplo n.º 8
0
 void Awake()
 {
     anim = GetComponent <SimpleAnimationPlayer> ();
 }
Exemplo n.º 9
0
    //Events

    void Awake()
    {
        flasher    = GetComponent <FlashEffect>();
        animPlayer = GetComponent <SimpleAnimationPlayer>();
    }