Exemplo n.º 1
0
 public override void Update(GameTime gameTime)
 {
     switch (currentMode)
     {
         case adventureModes.textBox:
             if (stallCount > 0)
                 stallCount--;
             if (stallCount <= 0 &&  (Master.controls.A || Master.controls.B))
             {
                 currentMode = adventureModes.runMode;
                 stallCount = 20;
                 chooser(choice == 0);
             }
             else if (choice != -1 && Master.controls.Left)
             {
                 choice = 0;
             }
             else if (choice != -1 && Master.controls.Right)
             {
                 choice = 1;
             }
             break;
         case adventureModes.fadeOut:
             animCount = animCount - 2;
             if (animCount <= 0)
                 leaver(beaten);
                 //game.warpAdventure(beaten);
             break;
         case adventureModes.fadeIn:
             animCount = animCount - 8;
             if (animCount <= 0)
                 currentMode = adventureModes.runMode;
             //game.warpAdventure(beaten);
             break;
         case adventureModes.deathFade:
             animCount = animCount - 3;
             if (animCount <= 0)
             {
                 dead = true;
                 if (dieFunc != null)
                     dieFunc();
                 else
                     game.warpAdventure(beaten);
             }
             break;
         case adventureModes.runMode:
             UpdateRoom();
             break;
         default:
             break;
     }
 }
Exemplo n.º 2
0
 public void QuestionBox(string text, Action<bool> choose)
 {
     if (currentMode != adventureModes.textBox)
     {
         textString = text;
         choice = 1;
         chooser = delegate (bool b)
         {
             choose(b);
         };
         stallCount = 20;
         currentMode = adventureModes.textBox;
     }
     else
     {
         textStack.Enqueue(text);
         chooser = delegate (bool b)
         {
             if (textStack.Count == 1)
                 QuestionBox(textStack.Dequeue(), choose);
             else
                 TextBox(textStack.Dequeue(), false);
         };
      }
 }
Exemplo n.º 3
0
        public void TextBox(string text, bool replace)
        {
            if (currentMode != adventureModes.textBox)
            {
                textString = text;
                choice = -1;
                currentMode = adventureModes.textBox;
                stallCount = 20;
            }
            else
            {
                textStack.Enqueue(text);
            }

            if (replace)
            {
                chooser = delegate (bool b)
                {
                    if (textStack.Count != 0)
                        TextBox(textStack.Dequeue(), false);
                };
            }
        }
Exemplo n.º 4
0
 public void FadeIn()
 {
     animCount = 250;
     currentMode = adventureModes.fadeIn;
 }
Exemplo n.º 5
0
 public void leaveAdventure(int dest, int destx, int desty, int destroomX, int destroomY)
 {
     leaver = x => game.exitAdventure(x, dest, destroomX, destroomY, destx, desty);
     currentMode = adventureModes.fadeOut;
     animCount = 250;
     PlaySound.Play(PlaySound.SoundEffectName.Leave);
 }
Exemplo n.º 6
0
 public void EnterNewRoom(int room_x, int room_y, int x, int y)
 {
     LoadRoom(room_x, room_y);
     first_pos = new Vector2(x * 32 + 16, y * 32 + 16);
     player.location = new Vector2(x * 32 + 16, y * 32 + 16);
     player.faceDir = (y > 6 ? Master.Directions.Down : Master.Directions.Up);
     animCount = 250;
     currentMode = adventureModes.fadeIn;
 }
Exemplo n.º 7
0
 public void enterSpecialStage(int screen, int key)
 {
     PlaySound.Play(PlaySound.SoundEffectName.Special);
     leaver = x => game.enterSpecialStageFromAdventure(screen, key);
     currentMode = adventureModes.fadeOut;
     animCount = 250;
 }
Exemplo n.º 8
0
        public void Drown()
        {
            if (dead)
                return;

            animCount = 24;
            currentMode = adventureModes.drowning;
            PlaySound.Play(PlaySound.SoundEffectName.Drown);
            foreach(AdventureObject obj in objects)
            {
                if (obj is AdventureBoss7)
                {
                    AdventureBoss7 ab7 = (AdventureBoss7)obj;
                    ab7.location = new Vector2(Master.width / 2, 3 * 32);
                }
            }
        }
Exemplo n.º 9
0
        public void enterNewRoom(int del_x, int del_y)
        {
            int x = roomX + del_x;
            int y = roomY + del_y;

            if (x >= 0 && y >= 0 && x < 16 && y < 16)
                if (adventure.rooms[x, y] != null)
                {
                    if (del_x == -1)
                        player.location.X = 25 * 32 - 14 - 2;
                    else if (del_y == -1)
                        player.location.Y = 13 * 32 - 6 - 2;
                    else if (del_x == 1)
                        player.location.X = 14 + 2;
                    else if (del_y == 1)
                        player.location.Y = 6 + 2;
                    this.first_pos = player.location;

                    LoadRoom(x, y);

                    if (del_y != 0)
                    {
                        currentMode = adventureModes.scrollingY;
                        animCount = 12 * del_y;
                    }
                    else if (del_x != 0)
                    {
                        currentMode = adventureModes.scrollingX;
                        animCount = 24 * del_x;
                    }
                }
        }
Exemplo n.º 10
0
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            switch (currentMode)
            {
                case adventureModes.textBox:
                    DrawRoom(spriteBatch, Color.White);
                    List<AdventureObject> sortList = objects.OrderBy(o => o.location.Y).ToList();
                    foreach (AdventureObject obj in sortList)
                    {
                        if (obj is AdventurePlayer)
                        {
                            if (!dead)
                                obj.Draw(spriteBatch, playerColor);
                        }
                        else
                        {
                            if (dead)
                            {
                                if (obj is AdventureEntity)
                                    obj.Draw(spriteBatch, Color.White);
                            }
                            else
                                obj.Draw(spriteBatch, Color.White);
                        }
                    }
                    DrawTextBox(spriteBatch, textString);
                    if (choice != -1)
                    {
                        WriteText(spriteBatch, "YES", new Vector2((Master.width / 2) - (16 * 11), 16 * 6), Color.White);
                        WriteText(spriteBatch, "NO", new Vector2((Master.width / 2) + (16 * 8), 16 * 6), Color.White);

                        spriteBatch.Begin();
                        Rectangle source = new Rectangle(128, 16, 16, 16);
                        Rectangle dest;

                        if (choice == 0)
                            dest = new Rectangle((Master.width / 2) - (16 * 13), 16 * 6, 16, 16);
                        else
                            dest = new Rectangle((Master.width / 2) + (16 * 6), 16 * 6, 16, 16);

                        spriteBatch.Draw(Master.texCollection.controls, dest, source, Color.White);
                        spriteBatch.End();
                    }
                    break;
                case adventureModes.drowning:
                    if (animCount == 0)
                    {
                        DrawRoom(spriteBatch, Color.White);
                        DrawStatus(spriteBatch);
                        if (game.life > 2)
                        {
                            game.life = game.life - 2;
                            player.location = first_pos;
                            player.Flicker();
                            currentMode = adventureModes.runMode;
                        }
                        else
                        {
                            game.life = 0;
                            Die();
                        }
                        return;
                    }

                    DrawRoom(spriteBatch, Color.White);
                    player.Drown(spriteBatch, animCount);

                    if (stallCount > 0)
                    {
                        stallCount = stallCount - 1;
                    }
                    else
                    {
                        stallCount = 3;
                        animCount--;
                    }
                    break;
                case adventureModes.deathFade:
                    Color mask = Color.White;
                    mask.G = (byte)(animCount / 2);
                    mask.B = (byte)(animCount / 2);
                    mask.R = (byte)(animCount);
                    DrawRoom(spriteBatch, mask);
                    break;
                case adventureModes.fadeOut:
                    Color mask2 = Color.White;
                    mask2.R = (byte)(animCount / 2);
                    mask2.G = (byte)(animCount / 2);
                    mask2.B = (byte)(animCount / 2);
                    DrawRoom(spriteBatch, mask2);
                    if (!dead)
                        player.Draw(spriteBatch, mask2);
                    else
                    {
                        foreach(AdventureObject obj in objects)
                        {
                            if (obj is AdventureEntity)
                                obj.Draw(spriteBatch, mask2);
                        }
                    }
                    break;
                case adventureModes.fadeIn:
                    Color mask3 = Color.White;
                    mask3.R = (byte)(255 - animCount / 2);
                    mask3.G = (byte)(255 - animCount / 2);
                    mask3.B = (byte)(255 - animCount / 2);
                    DrawRoom(spriteBatch, mask3);
                    player.Draw(spriteBatch, mask3);
                    break;
                case adventureModes.scrollingX:
                case adventureModes.scrollingY:
                    scroll(spriteBatch);
                    break;
                case adventureModes.runMode:
                    //Color roomColor = (!dark || lit) ? Color.White : Color.FromNonPremultiplied(15,15,15,255);
                    Color roomColor = overlayColor;
                    bool usePlayerColor = (playerColor != Color.White);
                    if (dark)
                    {
                        usePlayerColor = false;
                        if (lit) roomColor = Color.FromNonPremultiplied(200, 200, 200, 255);
                        else roomColor = Color.FromNonPremultiplied(15, 15, 15, 255);
                    }
                    DrawRoom(spriteBatch, roomColor);
                    List<AdventureObject> sortedList = objects.OrderBy(o => o.location.Y).ToList();
                    foreach (AdventureObject obj in sortedList)
                    {
                        if (obj is AdventurePlayer)
                            obj.Draw(spriteBatch, usePlayerColor ? playerColor : roomColor);
                        else if (obj.active)
                            obj.Draw(spriteBatch, roomColor);
                    }
                    break;
            }
            DrawStatus(spriteBatch);
        }
Exemplo n.º 11
0
 public void Die()
 {
     animCount = 250;
     currentMode = adventureModes.deathFade;
     PlaySound.Play(PlaySound.SoundEffectName.Die);
     PlaySong.Play(PlaySong.SongName.Silent);
 }
Exemplo n.º 12
0
 void tileStepAction(int i)
 {
     tileType tile = (tileType)key[tileMap[i]];
     if (tile == tileType.Warp && (player.z == 0 ||
         (tileMap.Length > i && (tileType)tileMap[i+1] == tileType.Warp) || (i > 0 && (tileType)tileMap[i-1] == tileType.Warp)))
     {
         PlaySound.Play(PlaySound.SoundEffectName.Leave);
         PlaySong.Play(PlaySong.SongName.None);
         leaver = x => game.warpAdventure(x);
         currentMode = adventureModes.fadeOut;
         animCount = 250;
     }
     else if (tile == tileType.Heal)
     {
         if (game.life != game.possibleLife)
         {
             game.life = game.possibleLife;
         }
         PlaySound.Play(PlaySound.SoundEffectName.Heal);
         tileMap[i] = 0;
     }
 }
Exemplo n.º 13
0
        void scroll(SpriteBatch spriteBatch)
        {
            bool scrollDown = true;
            if (Math.Sign(animCount) == -1)
                scrollDown = false;

            bool Xscroll = false;
            if (currentMode == adventureModes.scrollingX)
                Xscroll = true;

            Vector2 screenOffset;
            Rectangle source;
            Rectangle dest;
            Vector2 sourceTile, limitOffset;
            int x, y;
            spriteBatch.Begin();

            int width, height;

            if (Xscroll)
            {
                width = 50;
                height = 13;
                screenOffset.Y = 0;
                if (scrollDown)
                    screenOffset.X = ((width / 2) - animCount) * 32;
                else
                    screenOffset.X = -(animCount) * 32;
            }
            else
            {
                width = 25;
                height = 26;
                screenOffset.X = 0;
                if (scrollDown)
                    screenOffset.Y = ((height / 2) - animCount) * 32;
                else
                    screenOffset.Y = -(animCount) * 32;
            }

            int[] newroom;
            int[] oldroom;
            int[] room = new int[width * height];

            if (Xscroll)
            {
                newroom = adventure.rooms[roomX, roomY].tileMap;
                oldroom = adventure.rooms[roomX - Math.Sign(animCount), roomY].tileMap;
                if (scrollDown)
                {
                    room = Master.sumRooms(oldroom, newroom, 25, 13);
                }
                else
                {
                    room = Master.sumRooms(newroom, oldroom, 25, 13);
                }
            }
            else
            {
                newroom = adventure.rooms[roomX, roomY].tileMap;
                oldroom = adventure.rooms[roomX, roomY - Math.Sign(animCount)].tileMap;
                if (scrollDown)
                {
                    oldroom.CopyTo(room, 0);
                    newroom.CopyTo(room, 13 * 25);
                }
                else
                {
                    oldroom.CopyTo(room, 13 * 25);
                    newroom.CopyTo(room, 0);
                }
            }

            for (int i = 0; i < (width * height); i++)
            {
                x = i % width;
                y = i / width;
                limitOffset = new Vector2((float)Math.Floor(screenOffset.X / 32), (float)Math.Floor(screenOffset.Y / 32));
                if ((x >= limitOffset.X) && (x <= limitOffset.X + Master.width) &&
                    (y >= limitOffset.Y) && (y <= limitOffset.Y + (Master.height)))
                {
                    sourceTile = Master.getMapTile(room[i], Master.texCollection.adventureTiles[adventure.tileset]);
                    source = new Rectangle((int)sourceTile.X, (int)sourceTile.Y, 32, 32);
                    dest = new Rectangle(x * 32 - (int)screenOffset.X, y * 32 - (int)screenOffset.Y, 32, 32);
                    if (y - (int)limitOffset.Y < 13)
                        spriteBatch.Draw(Master.texCollection.adventureTiles[adventure.tileset], dest, source, overlayColor);
                }
            }
            spriteBatch.End();

            if (animCount == 0)
            {
                currentMode = adventureModes.runMode;
                stallCount = 0;
                return;
            }

            if (stallCount > 0)
            {
                stallCount = stallCount - 1;
            }
            else
            {
                if (Xscroll)
                    stallCount = 2;
                else
                    stallCount = 3;
                animCount = (Math.Abs(animCount) - 1) * Math.Sign(animCount);
            }
        }
Exemplo n.º 14
0
 void EnterCredits()
 {
     leaver = x => game.enterCredits();
     currentMode = adventureModes.fadeOut;
     animCount = 250;
 }