Ejemplo n.º 1
0
        /// <summary>
        /// Obtains the relative position of the tile map and draws all tiles within the screen using the corresponding tile array. Additionally, all tiles out of the map are drawn as tree foilage.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="v2fTileMapPosition"></param>
        public void Draw(RenderWindow window, Vector2f v2fTileMapPosition)
        {
            int tileMapPositionXNormalized = (int)((-v2fTileMapPosition.X) / tileArrayCreation.GetTileSize());
            int tileMapPositionYNormalized = (int)((-v2fTileMapPosition.Y) / tileArrayCreation.GetTileSize());
            int xLimit = (int)((GameLoop.GetWindowSize().X / tileArrayCreation.GetTileSize()));
            int yLimit = (int)((GameLoop.GetWindowSize().Y / tileArrayCreation.GetTileSize()) + 1);

            for (int xCoord = 0, yCoord = 0; yCoord <= yLimit; xCoord++)
            {
                if (tileMapPositionXNormalized + xCoord >= 0 && tileMapPositionXNormalized + xCoord < tileArrayCreation.GetNumberColumns() &&
                    tileMapPositionYNormalized + yCoord >= 0 && tileMapPositionYNormalized + yCoord < tileArrayCreation.GetNumberRows())
                {
                    spriteTileSheet.Position = new Vector2f(((int)((tileMapPositionXNormalized + xCoord) * tileArrayCreation.GetTileSize() + v2fTileMapPosition.X)),
                                                            (int)(((tileMapPositionYNormalized + yCoord) * tileArrayCreation.GetTileSize() + v2fTileMapPosition.Y)));
                    spriteTileSheet.TextureRect = TileSourceDeterminat0r(tileArrayCreation.GetTilezArray()[xCoord + tileMapPositionXNormalized, yCoord + tileMapPositionYNormalized]);

                    window.Draw(spriteTileSheet);
                }

                if (xCoord > xLimit)
                {
                    xCoord = -1;
                    yCoord++;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes Variables of the State
        /// </summary>
        public override void Initialize()
        {
            targetState = eGameState.gsGameOver;

            fFont = new Font(ContentLoader.fontArial);

            teGameOver          = new Text("GAME OVER", fFont, 50);
            teContinue          = new Text("Press ESC to continue", fFont, 15);
            teGameOver.Position = GameLoop.GetWindowSize() / 2 - new Vector2f(teGameOver.CharacterSize * 4.5f, teGameOver.CharacterSize / 2);
            teContinue.Position = teGameOver.Position + new Vector2f(77, 60);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows change of the displayed characters size.
        /// </summary>
        /// <param name="sInput"></param>
        /// <param name="color"></param>
        /// <param name="uiCharacterSize"></param>
        /// <returns></returns>
        public static Text TextForPlayer(string sInput, Color color, uint uiCharacterSize)
        {
            textColor = color;
            font      = ContentLoader.fontArial;
            uiSize    = uiCharacterSize;

            text = new Text(sInput, font, uiSize);
            text.CharacterSize = uiSize;
            text.Position      = new Vector2f((int)((GameLoop.GetWindowSize().X / 2) - ((sInput.Length / 2) * (text.CharacterSize / 2))), (int)((GameLoop.GetWindowSize().Y / 2) - (GameLoop.GetWindowSize().Y / 4) - (text.CharacterSize / 2)));
            text.Color         = textColor;

            return(text);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the Main Map Logic
        /// </summary>
        public override eMapState Update(RenderWindow window)
        {
            left  = false;
            right = false;
            up    = false;
            down  = false;

            vPastTileMapPosition       = vPresentTileMapPosition;
            vPresentTileMapPosition    = vTileMapPosition;
            vDifferenceTileMapPosition = vPastTileMapPosition - vPresentTileMapPosition;

            cCamera.Update(vPlayerVirtualPosition, ref vTileMapPosition);

            for (int x = 0; x < lEnemies.Count; x++)
            {
                Vector2f EnemyPosition = lEnemies[x].GetPosition();

                if (EnemyPosition.X > GameLoop.GetWindowSize().X || EnemyPosition.X < -50 ||
                    EnemyPosition.Y > GameLoop.GetWindowSize().Y || EnemyPosition.Y < -50)
                {
                    lEnemies[x].PassiveUpdate();
                    continue;
                }

                lEnemies[x].Update(ref vPlayerVirtualPosition, ref up, ref down, ref right, ref left);

                if (lEnemies[x].GetHealth() <= 0)
                {
                    if (lEnemies[x].GetIsBoss())
                    {
                        uiKillCount++;
                        Player.LevelUp();
                    }
                    SoundManager.PlaySpecificSound(Sounds.Death);

                    lEnemies.RemoveAt(x);
                }
            }

            pPlayer.Update(ref vPlayerVirtualPosition, ref up, ref down, ref right, ref left);

            textQuest = new Text(questTracker.Update(uiKillCount), fFont, 20);

            iInput.Update(ref vPlayerVirtualPosition, ref Player.fSpeed, up, right, down, left, window);

            return(eTargetMap);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes Variables of the State
        /// </summary>
        public override void Initialize()
        {
            targetState = eGameState.gsMainMenu;

            fFont = ContentLoader.fontArial;

            teMainMenu          = new Text("MAIN MENU", fFont, 30);
            teMainMenu.Position = GameLoop.GetWindowSize() / 2 - new Vector2f(teMainMenu.CharacterSize * 4.5f, 200);

            tePlay          = new Text("Play", fFont, 25);
            tePlay.Position = teMainMenu.Position + new Vector2f(0, 100);
            tePlay.Color    = Color.Red;

            teQuit          = new Text("Quit", fFont, 25);
            teQuit.Position = teMainMenu.Position + new Vector2f(0, 150);
            teQuit.Color    = Color.White;

            iSelected = 0;

            bKeyIsPressed = false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Destructor of the Projectile
        /// </summary>
        /// <returns>Bool whether Projectile has been destroyed or not</returns>
        public bool Destruct()
        {
            if (SimpleCollisionDetection(sEntity.Position - new Vector2f(tEntity.Size.X / 2, tEntity.Size.Y / 2), tEntity.Size.X, tEntity.Size.Y) || Utilities.DistanceBetweenVectors(StartPosition, sEntity.Position) > GameLoop.GetWindowSize().X / 2)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns a List of the Elements to be drawed
        /// Custom List is used to to add Lists rapidly
        /// </summary>
        public override CustomList Draw(RenderWindow window)
        {
            lDrawList = new CustomList();

            lDrawList.AddElement(textQuest);
            lDrawList.AddList(pPlayer.Draw());

            for (int x = 0; x < lEnemies.Count; x++)
            {
                Vector2f EnemyPosition = lEnemies[x].GetPosition();

                if (EnemyPosition.X > GameLoop.GetWindowSize().X || EnemyPosition.X < -50 ||
                    EnemyPosition.Y > GameLoop.GetWindowSize().Y || EnemyPosition.Y < -50)
                {
                    continue;
                }

                lDrawList.AddList(lEnemies[x].Draw());
            }

            if (cText != null)
            {
                tText = cText.ElapsedTime;
            }

            if (tText.AsSeconds() <= 5)
            {
                RectangleShape rShape = new RectangleShape(new Vector2f(20, 15));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(877, 490);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(30, 20));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(847, 470);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(50, 25));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(805, 450);

                lDrawList.AddElement(rShape);

                rShape                  = new RectangleShape(new Vector2f(200, 50));
                rShape.FillColor        = Color.White;
                rShape.OutlineThickness = 2;
                rShape.OutlineColor     = Color.Black;
                rShape.Position         = new Vector2f(702, 409);

                lDrawList.AddElement(rShape);
                lDrawList.AddElement(TextStreamer.TextForPlayer("Tod den Ecksisten!!", new Vector2f(710, 420)));
            }
            else
            {
                cText = null;
            }


            tTileUndHerrsche.Draw(window, vTileMapPosition);

            return(lDrawList);
        }