public bool update(GameTime time, Event e)
        {
            phaseTimer -= time.ElapsedGameTime.Milliseconds;
            steamTimer -= time.ElapsedGameTime.Milliseconds;
            cupTimer   -= time.ElapsedGameTime.Milliseconds;
            if (steamTimer <= 0)
            {
                if (e.aboveMapSprites == null)
                {
                    e.aboveMapSprites = new List <TemporaryAnimatedSprite>();
                }
                int randomX = Game1.random.Next(-48, 64);
                e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                {
                    texture                 = tempText,
                    local                   = true,
                    position                = new Vector2(topLeftX + width / 2, topLeftY + height / 2) + new Vector2(-64 + randomX, 64f),
                    initialPosition         = new Vector2(topLeftX + width / 2, topLeftY + height / 2) + new Vector2(-64 + randomX, 64f),
                    motion                  = new Vector2(-0.1f, -1f),
                    alphaFade               = -0.01f,
                    alphaFadeFade           = -0.0001f,
                    alpha                   = 0.1f,
                    rotationChange          = Utility.Lerp(-0.01f, 0.01f, (float)Game1.random.NextDouble()),
                    sourceRect              = new Rectangle(472, 450, 16, 14),
                    scale                   = 4f,
                    sourceRectStartingPos   = new Vector2(472f, 450f),
                    animationLength         = 1,
                    totalNumberOfLoops      = 1,
                    interval                = 50000f,
                    layerDepth              = 1f,
                    overrideLocationDestroy = true
                });
                steamTimer = 100;
            }
            if (phaseTimer <= 0)
            {
                currentPhase++;
                phaseTimer = 99999;
                switch (currentPhase)
                {
                case 1:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event1");
                    textColor = 6;
                    break;

                case 2:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event2");
                    textColor = 6;
                    break;

                case 3:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event3");
                    textColor = 6;
                    break;

                case 4:
                    buddy = new TemporaryAnimatedSprite
                    {
                        texture                 = tempText,
                        local                   = true,
                        position                = new Vector2(topLeftX, topLeftY) + new Vector2(213f, 170f) * 4f,
                        initialPosition         = new Vector2(topLeftX, topLeftY) + new Vector2(219f, 170f) * 4f,
                        motion                  = new Vector2(0f, -9f),
                        acceleration            = new Vector2(0f, 0.2f),
                        sourceRect              = new Rectangle(0, 242, 27, 32),
                        scale                   = 4f,
                        sourceRectStartingPos   = new Vector2(0f, 242f),
                        animationLength         = 1,
                        totalNumberOfLoops      = 1,
                        interval                = 950000f,
                        layerDepth              = 0.158f,
                        overrideLocationDestroy = true
                    };
                    setBuddyFrame(7);
                    Game1.playSound("pullItemFromWater");
                    buddyPhase = 0;
                    break;

                case 5:
                    phaseTimer = 3000;
                    break;

                default:
                    phaseTimer = 5000;
                    break;
                }
            }
            if (buddy != null)
            {
                float y = buddy.motion.Y;
                buddy.update(time);
                if (y <= 0f && buddy.motion.Y > 0f)
                {
                    buddy.layerDepth = 0.161f;
                }
                if (buddy.motion.Y > 0f && buddy.position.Y >= (float)(topLeftY + 608))
                {
                    buddy.motion.Y       = 0f;
                    buddy.acceleration.Y = 0f;
                    buddy.position.Y     = topLeftY + 608;
                    setBuddyFrame(0);
                    Game1.playSound("coin");
                    buddyPhase = 1;
                    buddyTimer = 2500;
                }
                if (buddyTimer >= 0)
                {
                    buddyTimer -= time.ElapsedGameTime.Milliseconds;
                }
                switch (buddyPhase)
                {
                case 1:
                    setBuddyFrame(buddyTimer % 1000 / 500);
                    if (buddyTimer <= 0)
                    {
                        buddyPhase = 2;
                        buddyTimer = 1500;
                        setBuddyFrame(5);
                        Game1.playSound("dwop");
                        e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                        {
                            texture               = tempText,
                            local                 = true,
                            position              = buddy.position + new Vector2(-7f, -7f) * 4f,
                            initialPosition       = buddy.position + new Vector2(-7f, -7f) * 4f,
                            sourceRect            = new Rectangle(0, 384, 16, 16),
                            scale                 = 4f,
                            sourceRectStartingPos = new Vector2(0f, 384f),
                            animationLength       = 8,
                            totalNumberOfLoops    = 4,
                            interval              = 100f,
                            layerDepth            = 1f,
                            id = 777f,
                            overrideLocationDestroy = true
                        });
                    }
                    break;

                case 2:
                {
                    if (buddyTimer > 0)
                    {
                        break;
                    }
                    setBuddyFrame(6);
                    buddyPhase = 3;
                    Game1.playSound("sipTea");
                    buddyTimer = 1000;
                    for (int i = 0; i < e.aboveMapSprites.Count; i++)
                    {
                        if (e.aboveMapSprites[i].id == 777f)
                        {
                            e.aboveMapSprites.RemoveAt(i);
                            break;
                        }
                    }
                    break;
                }

                case 3:
                    if (buddyTimer <= 0)
                    {
                        setBuddyFrame(8);
                        Game1.playSound("gulp");
                        buddyPhase = 4;
                        buddyTimer = 1500;
                    }
                    break;

                case 4:
                    if (buddyTimer < 1000)
                    {
                        setBuddyFrame(9);
                    }
                    if (buddyTimer <= 0)
                    {
                        buddyPhase = 5;
                        buddyTimer = 2400;
                        Game1.playSound("dustMeep");
                        DelayedAction.playSoundAfterDelay("dustMeep", 400);
                        DelayedAction.playSoundAfterDelay("dustMeep", 800);
                        DelayedAction.playSoundAfterDelay("dustMeep", 1200);
                    }
                    break;

                case 5:
                    if (buddyTimer > 1000)
                    {
                        setBuddyFrame(2 + buddyTimer % 400 / 200);
                    }
                    else
                    {
                        setBuddyFrame(4);
                    }
                    if (buddyTimer <= 0)
                    {
                        buddyTimer = 2000;
                        buddyPhase = 6;
                        for (int j = 0; j < 30; j++)
                        {
                            Vector2 randomPositionOffset = Utility.getRandomPositionInThisRectangle(new Rectangle(-8, -8, 27, 32), Game1.random) * 4f;
                            float   xMotion = Utility.Lerp(-2f, 2f, (float)Game1.random.NextDouble());
                            e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                            {
                                texture                 = tempText,
                                local                   = true,
                                position                = buddy.position + randomPositionOffset,
                                initialPosition         = buddy.position + randomPositionOffset,
                                motion                  = new Vector2(xMotion, -0.5f),
                                alphaFade               = -0.0125f,
                                alphaFadeFade           = -0.0002f,
                                alpha                   = 0.25f,
                                rotationChange          = Utility.Lerp(-0.01f, 0.01f, (float)Game1.random.NextDouble()),
                                sourceRect              = new Rectangle(472, 450, 16, 14),
                                scale                   = 4f,
                                sourceRectStartingPos   = new Vector2(472f, 450f),
                                animationLength         = 1,
                                totalNumberOfLoops      = 1,
                                interval                = 50000f,
                                layerDepth              = 1f,
                                overrideLocationDestroy = true
                            });
                        }
                        buddy      = null;
                        phaseTimer = 1;
                        Game1.playSound("fireball");
                    }
                    break;

                case 6:
                    if (buddyTimer <= 0)
                    {
                        phaseTimer = 1;
                    }
                    break;
                }
                Game1.InvalidateOldMouseMovement();
            }
            if (text != null)
            {
                e.int_useMeForAnything2   = textColor;
                e.float_useMeForAnything += time.ElapsedGameTime.Milliseconds;
                if (e.float_useMeForAnything > 80f)
                {
                    if (e.int_useMeForAnything >= text.Length)
                    {
                        if (e.float_useMeForAnything >= 2500f)
                        {
                            e.int_useMeForAnything   = 0;
                            e.float_useMeForAnything = 0f;
                            e.spriteTextToDraw       = "";
                            text       = null;
                            phaseTimer = 1;
                        }
                    }
                    else
                    {
                        e.int_useMeForAnything++;
                        e.float_useMeForAnything = 0f;
                    }
                }
                e.spriteTextToDraw = text;
            }
            if (currentPhase == 5 && phaseTimer <= 20)
            {
                e.aboveMapSprites.Clear();
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public void ResetLocalState()
        {
            int      x              = Position.X;
            int      y              = Position.Y;
            Location doorLocation   = new Location(x, y);
            Layer    buildingsLayer = Location.Map.GetLayer("Buildings");
            Layer    backLayer      = Location.Map.GetLayer("Back");

            if (Tile == null)
            {
                Tile = buildingsLayer.Tiles[doorLocation];
            }
            if (Tile == null)
            {
                return;
            }
            if (Tile.Properties.TryGetValue("Action", out var doorAction) && doorAction != null && doorAction.ToString().Contains("Door") && doorAction.ToString().Split(' ').Length > 1 && backLayer.Tiles[doorLocation] != null && !backLayer.Tiles[doorLocation].Properties.ContainsKey("TouchAction"))
            {
                backLayer.Tiles[doorLocation].Properties.Add("TouchAction", new PropertyValue("Door " + doorAction.ToString().Substring(doorAction.ToString().IndexOf(' ') + 1)));
            }
            Microsoft.Xna.Framework.Rectangle sourceRect = default(Microsoft.Xna.Framework.Rectangle);
            bool flip = false;

            switch (Tile.TileIndex)
            {
            case 824:
                sourceRect = new Microsoft.Xna.Framework.Rectangle(640, 144, 16, 48);
                break;

            case 825:
                sourceRect = new Microsoft.Xna.Framework.Rectangle(640, 144, 16, 48);
                flip       = true;
                break;

            case 838:
                sourceRect = new Microsoft.Xna.Framework.Rectangle(576, 144, 16, 48);
                if (x == 10 && y == 5)
                {
                    flip = true;
                }
                break;

            case 120:
                sourceRect = new Microsoft.Xna.Framework.Rectangle(512, 144, 16, 48);
                break;
            }
            Sprite = new TemporaryAnimatedSprite("LooseSprites\\Cursors", sourceRect, 100f, 4, 1, new Vector2(x, y - 2) * 64f, flicker: false, flip, (float)((y + 1) * 64 - 12) / 10000f, 0f, Color.White, 4f, 0f, 0f, 0f)
            {
                holdLastFrame = true,
                paused        = true
            };
            if (base.Value)
            {
                Sprite.paused = false;
                Sprite.resetEnd();
                openDoorTiles();
            }
            else
            {
                closeDoorTiles();
            }
        }