Ejemplo n.º 1
0
        public JellyfishRenderer(Actor actor) : base(actor)
        {
            this.jellyfish     = RequireComponent <Jellyfish>();
            this.fish          = RequireComponent <Fish>();
            this.bubbleSpawner = RequireComponent <BubbleSpawner>();

            this.strands = new HairStrand[this.follicleCount];
            for (int i = 0; i < this.follicleCount; i++)
            {
                this.strands[i] = new HairStrand(transform);
            }
        }
Ejemplo n.º 2
0
        public Harness(Actor actor) : base(actor)
        {
            this.bubbleSpawner   = RequireComponent <BubbleSpawner>();
            this.levelTransition = RequireComponent <LevelTransition>();
            wires = new Wire[7];

            this.disconnectTween = new TweenChain();

            var rand = MachinaGame.Random.DirtyRandom;

            wires[0] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-47, -100));
            wires[1] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-60, -110));
            wires[2] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-25, -115));
            wires[3] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(0, -120));
            wires[4] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(70, -130));
            wires[5] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(45, -90));
            wires[6] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(55, -120));
        }
Ejemplo n.º 3
0
        public LureRenderer(Actor actor, Player player, EyeRenderer eye, Level currentLevel) : base(actor)
        {
            MachinaGame.Assets.GetSoundEffectInstance("frog_bass").Play();

            this.eye           = eye;
            this.player        = player;
            this.bubbleSpawner = RequireComponent <BubbleSpawner>();
            var targetLocalPos = transform.LocalPosition;

            this.lureTween = new TweenChain();
            var accessors = new TweenAccessors <float>(() => this.progress, val => this.progress = val);

            lureTween.AppendFloatTween(1f, 0.25f, EaseFuncs.QuadraticEaseOut, accessors);
            lureTween.AppendCallback(() =>
            {
                var caughtFish = false;

                if (currentLevel.HarnessVulnerable)
                {
                    foreach (var targetActor in actor.scene.GetAllActors())
                    {
                        var harness = targetActor.GetComponent <Harness>();
                        if (harness != null && harness.HarnessRect.Contains(EndPos))
                        {
                            harness.TakeDamage();
                        }
                    }
                }

                foreach (var targetActor in actor.scene.GetAllActors())
                {
                    var jellyfish = targetActor.GetComponent <Jellyfish>();
                    if (jellyfish != null)
                    {
                        if (jellyfish.IsHit(transform.Position, lureSize))
                        {
                            this.wasStunned = true;
                            jellyfish.Hit();
                        }
                    }
                }

                if (!wasStunned)
                {
                    foreach (var targetActor in actor.scene.GetAllActors())
                    {
                        var eatable = targetActor.GetComponent <Eatable>();
                        if (eatable != null)
                        {
                            if ((targetActor.transform.Position - transform.Position).Length() < this.lureSize + eatable.fish.HitRadius)
                            {
                                caughtFish          = true;
                                this.caughtFishSize = eatable.fish.Size;
                                eatable.actor.Destroy();
                                break;
                            }
                        }
                    }
                }


                if (!caughtFish)
                {
                    foreach (var targetActor in actor.scene.GetAllActors())
                    {
                        var plant = targetActor.GetComponent <Seaweed>();

                        if (plant != null)
                        {
                            var node = plant.NodeAt(transform.Position, this.lureSize);
                            if (node != null)
                            {
                                this.wasStunned = true;
                                plant.Hit();
                            }
                        }
                    }
                }

                if (caughtFish)
                {
                    MachinaGame.Assets.GetSoundEffectInstance("bass").Play();

                    bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.1f);
                    bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.2f);
                    bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.3f);
                    bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.4f);

                    this.currentPhase = Phase.Caught;
                    lureTween.AppendFloatTween(0f, 0.2f, EaseFuncs.QuadraticEaseOut, accessors);
                    lureTween.AppendCallback(() =>
                    {
                        this.currentPhase       = Phase.Feeding;
                        transform.LocalPosition = new Vector2(0, 0);
                    });
                    lureTween.AppendWaitTween(0.25f);
                    lureTween.AppendCallback(() =>
                    {
                        this.currentPhase = Phase.Retracting;
                        this.eye.ClearTween();
                        this.eye.TweenOpenAmountTo(2f, 0.1f);
                        this.eye.TweenPlaySound("cthulu-wins");
                        this.eye.TweenOpenAmountTo(0f, 0.15f);
                        this.eye.TweenOpenAmountTo(0f, 0.2f); // Stay closed
                        this.eye.TweenOpenAmountTo(1f, 0.25f);
                    });
                    lureTween.AppendCallback(() =>
                    {
                        var rand = MachinaGame.Random.DirtyRandom;
                        for (int i = 0; i < 10; i++)
                        {
                            bubbleSpawner.SpawnBubble(EndPos, new Vector2(rand.Next(-5, 5), rand.Next(5, 10)), 0f);
                        }
                    });
                    lureTween.AppendWaitTween(0.5f);
                    lureTween.AppendFloatTween(0f, 1f, EaseFuncs.QuadraticEaseOut, accessors);
                }
                else
                {
                    lureTween.AppendCallback(() =>
                    {
                        if (wasStunned)
                        {
                            var s   = MachinaGame.Assets.GetSoundEffectInstance("snare");
                            s.Pitch = -1f;
                            s.Play();
                        }
                        else
                        {
                            var s   = MachinaGame.Assets.GetSoundEffectInstance("snare");
                            s.Pitch = 1f;
                            s.Play();
                        }

                        this.currentPhase = Phase.Retracting;
                        var rand          = MachinaGame.Random.DirtyRandom;
                        for (int i = 0; i < 3; i++)
                        {
                            bubbleSpawner.SpawnBubble(EndPos, new Vector2(rand.Next(-5, 5), rand.Next(-5, 5)), 0f);
                        }
                    });

                    var retractDuration = 0.5f;
                    if (this.wasStunned)
                    {
                        retractDuration = 2.5f;
                    }

                    lureTween.AppendFloatTween(0f, retractDuration, EaseFuncs.QuadraticEaseOut, accessors);
                }
            });
        }
Ejemplo n.º 4
0
 public SpawnBubblesRandomly(Actor actor) : base(actor)
 {
     this.bubbleSpawner = RequireComponent <BubbleSpawner>();
     this.fish          = RequireComponent <Fish>();
 }