Exemplo n.º 1
0
    private IEnumerator DoAnimation()
    {
        anim.anim    = initAnimation;
        anim.looping = false;
        anim.Play();

        while (anim.isPlaying)
        {
            yield return(null);
        }

        anim.anim    = loopAnimation;
        anim.looping = true;
        anim.Play();

        while (!animatingOut)
        {
            yield return(null);
        }

        anim.anim    = onDisableAnimation;
        anim.looping = false;
        anim.Play();

        while (anim.isPlaying)
        {
            yield return(null);
        }

        animatingOut = false;
        gameObject.SetActive(false);
    }
Exemplo n.º 2
0
 private IEnumerator PlayFinishCooldownEffect()
 {
     holder.anim    = holderCooledDownEffect;
     holder.looping = false;
     holder.Play();
     while (holder.isPlaying)
     {
         yield return(null);
     }
     // play new anim
     holder.anim    = holderAbilityAvailableEffect;
     holder.looping = true;
     holder.Play();
 }
Exemplo n.º 3
0
    private IEnumerator UpdatePortal()
    {
        anim.anim    = appearAnim;
        anim.looping = false;
        anim.Play();
        while (anim.isPlaying)
        {
            yield return(null);
        }

        anim.looping = true;
        anim.anim    = loop;
        anim.Play();
        activated = true;
    }
Exemplo n.º 4
0
        protected override void DoAction()
        {
            if (offsetMatchesFlipX)
            {
                int sign = offsetMatchesFlipX ? -1 : 1;                 // set the sign of the X position based on whether the player
                // sprite is flipped or not
                anim.transform.localPosition = new Vector2(anim.transform.localPosition.x * sign, anim.transform.localPosition.y);
            }
            // Set the rotation for the effect
            Quaternion rot = GetRotation();

            // Initialize the effect properties
            TempObjectInfo info = new TempObjectInfo();

            info.targetColor = color;
            if (duration < 0)
            {
                duration = anim.anim.TimeLength;
            }
            info.lifeTime    = duration;
            info.fadeOutTime = 0.1f;

            // Initialize the effect and play it
            anim.GetComponent <TempObject>().Init(
                rot,
                anim.transform.position,
                anim.anim.frames[0],
                info);
            anim.Play();
        }
Exemplo n.º 5
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.º 6
0
        public void Init(Vector3 pos, Vector2 dir)
        {
            gameObject.SetActive(true);

            transform.position = pos;
            SetVelocity(dir);
            // Set angle to be facing the direction of motion
            if (setAngle)
            {
                float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
                transform.eulerAngles = new Vector3(0, 0, angle);
            }

            animator.anim    = projectileAnim;
            animator.looping = true;
            animator.Play();

            // Event
            if (OnShoot != null)
            {
                OnShoot();
            }
            StartCoroutine(OnFlightRoutine());

            Invoke("DestroySelf", lifeTime);
        }
Exemplo n.º 7
0
 protected virtual void Start()
 {
     anim.anim = walk;
     anim.Play();
     lootPool        = ObjectPooler.GetObjectPooler("EnergyLoot");
     movementRoutine = StartCoroutine(Movement());
 }
 void OnEnable()
 {
     transform.localScale = Vector3.one * Random.Range(1f, 1.2f);
     anim.anim            = animations [Random.Range(0, animations.Length)];
     anim.anim.fps        = Random.Range(15, 30);
     anim.destroyOnFinish = true;
     anim.Play();
 }
Exemplo n.º 9
0
 private IEnumerator Shine()
 {
     for (;;)
     {
         animPlayer.Play();
         yield return(new WaitForSeconds(3.0f));
     }
 }
Exemplo n.º 10
0
 protected override IEnumerator Effect()
 {
     anim.Play();
     enemy.OnEnemyDamaged += AdditionalDamage;
     while (timer > 0)
     {
         yield return(null);
     }
     enemy.OnEnemyDamaged -= AdditionalDamage;
     Deactivate();
 }
Exemplo n.º 11
0
 protected override IEnumerator Effect()
 {
     anim.Play();
     enemy.body.AddRandomImpulse(3f);
     while (timer > 0)
     {
         enemy.Disable(0);
         enemy.action.Interrupt();
         yield return(null);
     }
     Deactivate();
 }
Exemplo n.º 12
0
 private IEnumerator SplitEffect()
 {
     enemy.invincible = true;
     enemy.Disable(1.0f);
     anim.Play();
     anim.transform.localScale = enemy.srSize;
     while (anim.isPlaying)
     {
         yield return(null);
     }
     enemy.invincible = false;
     Split();
 }
Exemplo n.º 13
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.º 14
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.º 15
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.º 16
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.º 17
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.º 18
0
 private void LightningArcEffect()
 {
     anim.anim = lightningArcAnimations [Random.Range(0, lightningArcAnimations.Length)];
     anim.Play();
 }
Exemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     StartCoroutine(ShootRoutine());
     anim.anim = walkD;
     anim.Play();
 }
 private void PlayKnightCharDialogue(int step)
 {
     CameraControl.instance.SetFocus(knightCharacter.transform);
     knightCharacter.Play();
     dialogueView.Init(dialogueSteps[step]);
 }