Example #1
0
        IEnumerator SwimAttack()
        {
            curState = State.Swim;

            // Turn on lights
            softlight1.SetAlpha(0.6f);
            softlight1.FadeIn(4f);

            softlight2.SetAlpha(0.6f);
            softlight2.FadeIn(4f);

            float timeElapsed = 0.0f;

            while (timeElapsed < 5f)
            {
                if (Math.Abs(Y - 540) > 3)
                {
                    Float();
                }
                timeElapsed += Game.Instance.RealDeltaTime * 0.001f;
                yield return(0);
            }

            acceleration = new Vector2(0.5f, 0);
            X           += 0.5f;

            while (X > 960)
            {
                yield return(0);
            }

            while (X < 52)
            {
                yield return(0);
            }

            acceleration = new Vector2(-0.5f, 0);

            while (velocity.X > 0)
            {
                yield return(0);
            }

            acceleration = Vector2.Zero;

            softlight1.FadeOut(5f);
            softlight2.FadeOut(5f);

            var num = Rand.Int(2, 3);

            for (int i = 0; i < num; ++i)
            {
                EnemySpawner.Instance.SpawnRandomEnemy();
            }

            yield return(Coroutine.Instance.WaitForFrames(1));

            curState = State.Idle;
        }
Example #2
0
        IEnumerator DamageCooldown()
        {
            hurt         = true;
            sprite.Alpha = 0.8f;
            light.FadeOut(0.3f);
            yield return(Coroutine.Instance.WaitForFrames((int)(cooldownTimer * 60)));


            hurt         = false;
            sprite.Alpha = 1.0f;
            light.FadeIn(0.3f);
        }