예제 #1
0
        public SpriteBox()
        {
            this.content        = Global.game.Content;
            this.graphicsDevice = Global.game.GraphicsDevice;
            Sprites             = new Dictionary <string, Sprite>();

            // Variables for constructions.
            int     width;
            int     height;
            string  name;
            Vector2 origin;

            // !--- All Sprite Consturctions need to be declared here ---!

            #region Player Sprites
            width = 64; height = 64; origin = new Vector2(31, 58);
            List <Texture2D> playerTextures =
                Toolbox.SplitSpriteSheet(content.Load <Texture2D>("Player"), width * 4, height);

            name          = "PlayerNoLantern_Down";
            Sprites[name] = new Sprite(playerTextures[0], width, height, origin, animating: false, interval: 10);
            name          = "PlayerNoLantern_Up";
            Sprites[name] = new Sprite(playerTextures[1], width, height, origin, animating: false, interval: 10);
            name          = "PlayerNoLantern_Right";
            Sprites[name] = new Sprite(playerTextures[2], width, height, origin, animating: false, interval: 10);
            name          = "PlayerNoLantern_Left";
            Texture2D leftTexture = Toolbox.CopyTexture(playerTextures[2]);
            Toolbox.FlipTextureHorizontal(leftTexture);
            Sprites[name] = new Sprite(leftTexture, width, height, origin, animating: false, reverse: true, interval: 10);

            name          = "PlayerWithLantern_Down";
            Sprites[name] = new Sprite(playerTextures[3], width, height, origin, animating: false, interval: 10);
            name          = "PlayerWithLantern_Up";
            Sprites[name] = new Sprite(playerTextures[4], width, height, origin, animating: false, interval: 10);
            name          = "PlayerWithLantern_Right";
            Sprites[name] = new Sprite(playerTextures[5], width, height, origin, animating: false, interval: 10);
            name          = "PlayerWithLantern_Left";
            leftTexture   = Toolbox.CopyTexture(playerTextures[5]);
            Toolbox.FlipTextureHorizontal(leftTexture);
            Sprites[name] = new Sprite(leftTexture, width, height, origin, animating: false, reverse: true, interval: 10);
            #endregion

            #region Environments
            origin        = new Vector2(32, 40); name = "PlunckWithFlower";
            Sprites[name] = new Sprite(content.Load <Texture2D>("Plunck with Flower"), origin);
            origin        = new Vector2(16, 27); name = "Lantern";
            Sprites[name] = new Sprite(content.Load <Texture2D>("Lantern"), origin);
            #endregion

            #region GUIs
            origin        = new Vector2(0, 84); name = "Textbox";
            Sprites[name] = new Sprite(content.Load <Texture2D>(name), origin);
            origin        = Vector2.Zero; name = "ActionSelectPage";
            Sprites[name] = new Sprite(content.Load <Texture2D>(name), ActionSelect.WIDTH, ActionSelect.HEIGHT,
                                       origin, repeate: false, interval: 5);
            #endregion

            #region Heros
            List <Texture2D> heroSheet = Toolbox.SplitSpriteSheet(content.Load <Texture2D>("HeroSheet"), 64 * 2, 64);
            origin        = new Vector2(32, 40); name = "Hero1";
            Sprites[name] = new Sprite(heroSheet[0], 64, 64, origin, animating: false);
            origin        = new Vector2(32, 40); name = "Hero2";
            Sprites[name] = new Sprite(heroSheet[1], 64, 64, origin, animating: false);
            #endregion

            #region Enemies
            origin        = new Vector2(33, 60); name = "Goul";
            Sprites[name] = new Sprite(content.Load <Texture2D>("goul"), origin);
            #endregion

            #region Effects
            origin        = new Vector2(32, 32); name = "SlashEffect";
            Sprites[name] = new Sprite(content.Load <Texture2D>(name), 64, 64, origin, interval: 5, repeate: false);
            origin        = new Vector2(32, 40); name = "Frozen";
            Sprites[name] = new Sprite(content.Load <Texture2D>(name), origin);
            origin        = new Vector2(32, 40); name = "Auras";
            Sprites[name] = new Sprite(content.Load <Texture2D>(name), 64, 64, origin, animating: false);
            #endregion
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            if (!shown)
            {
            }
            else if (starting)
            {
                yScale += 0.1f;
                if (yScale >= 1.0f)
                {
                    yScale   = 1.0f;
                    starting = false;
                }
            }
            else if (wait)
            {
            }
            else if (isEnd)
            {
                yScale -= 0.1f;
                if (yScale <= 0.0f)
                {
                    yScale   = 0.0f;
                    Finished = true;
                }
            }
            else
            {
                timespan++;
                if (timespan >= interval) // Ticking
                {
                    bool skip = false;
                    timespan = 1; // Resets timespan.
                    while (!wordProcessing && characterIndex < textList[index].Length)
                    {
                        string characterBuffer = "";
                        characterBuffer += GetCharacter();

                        if (characterBuffer == " ") // White space
                        {
                            AddWordBuffer(characterBuffer);
                            characterIndex++;
                            wordProcessing = true;
                        }
                        else if (characterBuffer == "<") // Tag
                        {
                            characterIndex++;
                            skip = true;
                            switch (GetCharacter())
                            {
                            case 'n': characterIndex += 2; NextLine(); break;     // Next line.

                            case 'w': characterIndex += 2; wait = true; break;    // Wait.

                            case 'r': characterIndex += 2; characterBuffer = "";  // Rests for a while.
                                while (GetCharacter() != '>')
                                {
                                    characterBuffer += GetCharacter();
                                    characterIndex++;
                                }
                                timespan -= int.Parse(characterBuffer);
                                characterIndex++; break;

                            case 'f':                                               // Sets interval.
                                characterIndex += 2; characterBuffer = "";
                                while (GetCharacter() != '>')
                                {
                                    characterBuffer += GetCharacter();
                                    characterIndex++;
                                }
                                interval = int.Parse(characterBuffer);
                                characterIndex++; break;

                            case 'c':                                               // Sets color.
                                characterIndex += 2; characterBuffer = "";
                                while (GetCharacter() != '>')
                                {
                                    characterBuffer += GetCharacter();
                                    characterIndex++;
                                }
                                fontColor = Toolbox.ParseColor(characterBuffer);
                                characterIndex++; break;
                            }
                        }
                        else // Normal word
                        {
                            characterIndex++;
                            if (characterIndex < textList[index].Length)
                            {
                                while (GetCharacter() != ' ' &&
                                       GetCharacter() != '<')
                                {
                                    characterBuffer += GetCharacter();
                                    characterIndex++;
                                    if (characterIndex >= textList[index].Length)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (lineWidth + font.MeasureString(characterBuffer).X >= WIDTH)
                            {
                                NextLine();
                            }
                            AddWordBuffer(characterBuffer);
                            wordProcessing = true;
                        }
                    }
                    if (wordProcessing && !skip)
                    {
                        if (wordBuffer[wordBuffer.Count - 1].Process())
                        {
                            wordProcessing = false;
                        }
                    }
                    if (characterIndex >= textList[index].Length && !wordProcessing)
                    {
                        // Increase index resets variables.
                        index++;
                        if (!wait)
                        {
                            Reset();
                        }
                        if (index >= textList.Count)
                        {
                            isEnd = true;
                        }
                    }
                }
            }

            // Update words.
            foreach (DynamicWord word in wordBuffer)
            {
                word.Update(gameTime);
            }
        }
예제 #3
0
 public bool IsInside(int x, int y)
 {
     return(Toolbox.IsPointInsideSquare(this.x, this.y, this.x + WIDTH, this.y + HEIGHT, x, y));
 }
예제 #4
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(texture, new Vector2(x, y), sourceRectangle: new Rectangle(0, 0, WIDTH, HEIGHT),
                             color: Color.White);
            if (page.animating)
            {
                page.Draw(gameTime, spriteBatch, x, y, Color.White);
            }
            else
            {
                Skill skill = skills[index];
                spriteBatch.Draw(skill.icon, new Vector2(x + ICON_X, y + ICON_Y), Color.White);
                spriteBatch.Draw(texture, new Vector2(x + ICON_X - 2, y + ICON_Y - 2),
                                 sourceRectangle: new Rectangle(0, HEIGHT, FRAME_WIDTH, FRAME_HEIGHT), color: Color.White);
                // Draw name
                Toolbox.DrawAlignedString(spriteBatch, skill.name, x + NAME_X, y + NAME_Y, font24, Toolbox.ParseColor("#5e3643ff"), PAGE_WIDTH,
                                          AlignType.Center, AlignType.Center);
                // Draw Consumption
                Toolbox.DrawAlignedString(spriteBatch, "SP " + skill.manaUsage, x + CONSUMPTION_X, y + CONSUMPTION_Y,
                                          font12, Toolbox.ParseColor("#3978a8ff"), PAGE_WIDTH, AlignType.Center, AlignType.Center);
                // Draw Description
                Toolbox.DrawAlignedString(spriteBatch, skill.GetDescription(), x + DESCRIPTION_X, y + DESCRIPTION_Y,
                                          font12, Toolbox.ParseColor("#5e3643ff"), PAGE_WIDTH, AlignType.Center, AlignType.Left);
            }

            spriteBatch.End();
        }
예제 #5
0
 /// <summary>
 /// Draw player.
 /// </summary>
 /// <param name="gameTime">Game time.</param>
 /// <param name="spriteBatch">Sprite batch.</param>
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     Toolbox.DrawSquare(spriteBatch, x, y, COLLIDER_WIDTH, COLLIDER_HEIGTH,
                        new Vector2(COLLIDER_WIDTH / 2, COLLIDER_HEIGTH / 2), Color.Bisque);
     currentSprite.Draw(gameTime, spriteBatch, x, y, Color.White, depth: depth);
 }
예제 #6
0
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     Toolbox.DrawAlignedString(spriteBatch, damage.ToString(), x, y + animation[index], font, Color.White,
                               Global.Properties.GAME_WIDTH, AlignType.Center, AlignType.Center);
 }