Exemplo n.º 1
0
        public void germinateLive(GameLocation location, Vector2 center)
        {
            // Only germinate once.
            if (germinating)
            {
                return;
            }

            // Choose a random ID for sprites.
            int id = Game1.random.Next();

            // Play the fuse sound.
            location.netAudio.StartPlaying("fuse");

            // Render the stray particles.
            MP.broadcastSprites(location, new TemporaryAnimatedSprite("LooseSprites\\Cursors",
                                                                      new Rectangle(598, 1279, 3, 4), 53f, 5, 9, center * 64f + new Vector2(5f, 3f) * 4f,
                                                                      flicker: true, flipped: false, (center.Y * 64 + 7) / 10000f, 0f, Color.Brown, 4f, 0f, 0f, 0f)
            {
                id = id,
            });
            MP.broadcastSprites(location, new TemporaryAnimatedSprite("LooseSprites\\Cursors",
                                                                      new Rectangle(598, 1279, 3, 4), 53f, 5, 9, center * 64f + new Vector2(5f, 3f) * 4f,
                                                                      flicker: true, flipped: true, (center.Y * 64 + 7) / 10000f, 0f, Color.Green, 4f, 0f, 0f, 0f)
            {
                delayBeforeAnimationStart = 100,
                id = id,
            });
            MP.broadcastSprites(location, new TemporaryAnimatedSprite("LooseSprites\\Cursors",
                                                                      new Rectangle(598, 1279, 3, 4), 53f, 5, 9, center * 64f + new Vector2(5f, 3f) * 4f,
                                                                      flicker: true, flipped: false, (center.Y * 64 + 7) / 10000f, 0f, Color.Yellow, 3f, 0f, 0f, 0f)
            {
                delayBeforeAnimationStart = 200,
                id = id,
            });

            // Render the shaking bomb, timing the next stage.
            bool ending = false;

            Base.isTemporarilyInvisible = true;
            MP.broadcastSprites(location, new TemporaryAnimatedSprite(
                                    (seed != null) ? FullSaveIndex.Index : TileIndex,
                                    100f, 1, 12, center * 64f, flicker: true, flipped: false, location, null)
            {
                shakeIntensity       = 0.5f,
                shakeIntensityChange = 0.002f,
                endFunction          = (int _) =>
                {
                    // Only end once.
                    if (ending)
                    {
                        return;
                    }
                    ending = true;

                    // Remove the sprites.
                    location.removeTemporarySpritesWithID(id);

                    // Show a mild flash.
                    if (Game1.currentLocation == location)
                    {
                        Game1.flashAlpha = 0.5f;
                    }

                    if (Context.IsMainPlayer)
                    {
                        // Stop the fuse sound and play the thud.
                        location.netAudio.StopPlaying("fuse");
                        location.playSound("treethud");

                        // Actually germinate.
                        germinate(location, center);
                    }
                },
            });
        }