示例#1
0
        //Metod för utritning av Items på kartan samt sättande spelarens Itemtarget
        private void DrawItems(float a_elapsedTime)
        {
            List <Model.Item> items = m_gameModel.m_itemSystem.m_items;

            Model.Player player = m_gameModel.m_playerSystem.m_player;

            foreach (Model.Item item in items)
            {
                if (m_inputHandler.MouseIsOver(m_camera.VisualizeRectangle(item.ThisItem.Bounds)))
                {
                    m_inputHandler.MouseIsOverLoot = true;
                }

                //Kontrollerar om spelaren har targetat ett item.
                if (m_inputHandler.DidGetTargetedByLeftClick(m_camera.VisualizeRectangle(item.ThisItem.Bounds)))
                {
                    player.ItemTarget = item;
                }

                if (player.ItemTarget == item)
                {
                    if (m_inputHandler.DidGetTargetedByLeftClick(m_camera.VisualizeRectangle(item.ThisItem.Bounds)) &&
                        player.ItemTarget.ThisItem.Bounds.Intersects(player.CollisionArea) && !m_lootWatch.IsRunning)
                    {
                        item.WasLooted = true;
                    }
                    else
                    {
                        item.WasLooted = false;
                    }
                }

                if (item.GetType() == Model.GameModel.ARMOR)
                {
                    Model.Armor Armor = item as Model.Armor;

                    if (Armor.Type == Model.Armor.HEAD_ARMOR)
                    {
                        Vector2 position      = m_camera.VisualizeCordinates(Armor.ThisItem.Bounds.Location.X, Armor.ThisItem.Bounds.Location.Y);
                        int     itemAnimation = 0;

                        itemAnimation = AnimationSystem.FACING_CAMERA;

                        m_animationSystem.UpdateAndDraw(a_elapsedTime, Color.White, position, itemAnimation, AnimationSystem.ITEM_PURPLE_CHEST);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Method for drawing of map Items as well as setting the players item targets
        /// </summary>
        /// <param name="elapsedTime">Elapsed time in milleseconds</param>
        private void DrawItems(float elapsedTime, Model.Player player)
        {
            List <Model.Item> items = _gameModel.ItemSystem._items;

            foreach (Model.Item item in items)
            {
                if (_inputHandler.MouseIsOver(_camera.VisualizeRectangle(item.ThisItem.Bounds)))
                {
                    _inputHandler.MouseIsOverLoot = true;
                }

                //Checks if the player targeted an item
                if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(item.ThisItem.Bounds)))
                {
                    player.ItemTarget = item;
                }

                if (player.ItemTarget == item)
                {
                    if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(item.ThisItem.Bounds)) &&
                        player.ItemTarget.ThisItem.Bounds.Intersects(player.CollisionArea) && !_lootWatch.IsRunning)
                    {
                        item.WasLooted = true;
                    }
                    else
                    {
                        item.WasLooted = false;
                    }
                }

                if (item.GetType() == Model.GameModel.ARMOR)
                {
                    Model.Armor Armor = item as Model.Armor;

                    if (Armor.Type == Model.Armor.HEAD_ARMOR)
                    {
                        Vector2     position      = _camera.VisualizeCordinates(Armor.ThisItem.Bounds.Location.X, Armor.ThisItem.Bounds.Location.Y);
                        Model.State itemAnimation = 0;

                        itemAnimation = Model.State.FACING_CAMERA;

                        _animationSystem.UpdateAndDraw(elapsedTime, Color.White, position, itemAnimation, AnimationSystem.Texture.ITEM_PURPLE_CHEST);
                    }
                }
            }
        }
        //Huvud metod för uppdatering och utritning av user interface
        internal void DrawAndUpdate(float a_elapsedTime)
        {
            m_inputHandler.MouseIsOverInterface = false;

            DrawTargetAvatars();

            DrawActionBar();

            DrawBackpack();

            DrawDamageAndHealing(a_elapsedTime);

            DrawCharacterPanel();

            DrawWorldMap();

            if (m_questSystem.IsWatchingQuestLog)
            {
                DrawQuestLog();
            }
            if (m_player.IsCastingSpell)
            {
                DrawCastBar();
            }
            if (m_player.LootTarget != null)
            {
                DrawLootBox(m_player.LootTarget);
            }

            //Kollar om musen befinner sig över actionbarsen
            foreach (Vector2 actionBarPos in m_keyPositions)
            {
                if (m_inputHandler.MouseIsOver(new Rectangle((int)actionBarPos.X, (int)actionBarPos.Y, 48, 48)))
                {
                    m_inputHandler.MouseIsOverInterface = true;
                }
            }

            DrawMoveToCross();

            DrawMouse();
        }
示例#4
0
        /// <summary>
        /// Main method for updating and rendering of the game UI
        /// </summary>
        /// <param name="elapsedTime">Elapsed time in milleseconds</param>
        internal void DrawAndUpdate(float elapsedTime)
        {
            _inputHandler.MouseIsOverInterface = false;

            _avatar.DrawTargetAvatars();

            _actionBar.DrawActionBar();

            DrawBackpack();

            DrawDamageAndHealing(elapsedTime);

            DrawCharacterPanel();

            _worldMap.DrawWorldMap();

            if (_questSystem.IsWatchingQuestLog)
            {
                DrawQuestLog();
            }
            if (_player.IsCastingSpell)
            {
                DrawCastBar();
            }
            if (_player.LootTarget != null)
            {
                DrawLootBox(_player.LootTarget);
            }

            //Checks if the cursor is hovering the actionbars
            foreach (Vector2 actionBarPos in _actionBar.BarPositions)
            {
                if (_inputHandler.MouseIsOver(new Rectangle((int)actionBarPos.X, (int)actionBarPos.Y, 48, 48)))
                {
                    _inputHandler.MouseIsOverInterface = true;
                }
            }

            DrawMoveToCross();

            DrawMouse();
        }
示例#5
0
        /// <summary>
        /// Method for rendering of the world map and the player position
        /// </summary>
        internal void DrawWorldMap()
        {
            if (_player.IsLookingAtMap)
            {
                Vector2   position = new Vector2(_camera.GetScreenRectangle.Width / 2 - _textures[Convert.ToInt32(Texture.WORLD_MAP_BG)].Bounds.Width / 2, _camera.GetScreenRectangle.Height - (_textures[Convert.ToInt32(Texture.WORLD_MAP_BG)].Bounds.Height * 1.25f));
                Rectangle mapRect  = new Rectangle((int)position.X + 15, (int)position.Y + 30, 500, 500);
                _spriteBatch.Draw(_textures[Convert.ToInt32(Texture.WORLD_MAP_BG)], position, Color.White);
                _spriteBatch.Draw(_textures[Convert.ToInt32(Texture.WORLD_MAP)], mapRect, Color.White);
                _spriteBatch.Draw(_textures[Convert.ToInt32(Texture.PLAYER_POSITION)], new Vector2(mapRect.X + _player.ThisUnit.Bounds.X / 20, mapRect.Y + _player.ThisUnit.Bounds.Y / 20), Color.White);

                //Fixa med anrop till GeatCloseRec
                Rectangle closeCross = new Rectangle((int)position.X + _textures[Convert.ToInt32(Texture.WORLD_MAP_BG)].Width - 25, (int)position.Y, 25, 25);

                if (_inputHandler.MouseIsOver(new Rectangle((int)position.X, (int)position.Y, _textures[Convert.ToInt32(Texture.WORLD_MAP_BG)].Bounds.Width, _textures[Convert.ToInt32(Texture.WORLD_MAP_BG)].Bounds.Height)))
                {
                    _inputHandler.MouseIsOverInterface = true;
                }
                if (_inputHandler.DidGetTargetedByLeftClick(closeCross))
                {
                    _player.IsLookingAtMap = false;
                }
            }
        }
示例#6
0
        //Metod för utritning av interaktionsknappar
        private void DrawQuestButtons()
        {
            //Knappmått
            int    buttonWidth  = (int)(270f * 0.27f);
            int    buttonHeight = (int)(100f * 0.26f); //Minskar storleken på en vanlig pratbubbla
            int    textMargin   = 7;
            Color  colorOne     = Color.White;
            Color  colorTwo     = Color.White;
            string buttonOneText;
            string buttonTwoText;

            //Knapprektanglar
            Rectangle buttonOne = new Rectangle(m_textRect.Right - (buttonWidth * 2), m_textRect.Bottom, buttonWidth, buttonHeight);
            Rectangle buttonTwo = new Rectangle(m_textRect.Right - buttonWidth, m_textRect.Bottom, buttonWidth, buttonHeight);

            if (m_questSystem.QuestStatus == Model.QuestSystem.PRE)
            {
                buttonOneText = "Accept";
                buttonTwoText = "Decline";
                m_spriteBatch.Draw(m_dialogueWindow, new Vector2(m_textRect.Right - buttonWidth, m_textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);
                m_spriteBatch.Draw(m_dialogueWindow, new Vector2(m_textRect.Right - (buttonWidth * 2), m_textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);

                if (m_inputHandler.MouseIsOver(buttonOne))
                {
                    colorOne = Color.Green;
                    if (m_inputHandler.DidGetTargetedByLeftClick(buttonOne))
                    {
                        m_questSystem.QuestStatus = Model.QuestSystem.MID;
                    }
                }

                if (m_inputHandler.MouseIsOver(buttonTwo))
                {
                    colorTwo = Color.Red;
                    if (m_inputHandler.DidGetTargetedByLeftClick(buttonTwo))
                    {
                        m_drawDialog = false;
                    }
                }

                m_spriteBatch.DrawString(m_spriteFont, buttonOneText, new Vector2(buttonOne.X + 7, buttonOne.Y + 4), colorOne);
            }
            else
            {
                if ((m_questSystem.QuestStatus == Model.QuestSystem.MID))
                {
                    buttonTwoText = "Okey";
                }
                else
                {
                    buttonTwoText = "Complete";
                    textMargin    = 4;
                }

                if (m_inputHandler.MouseIsOver(buttonTwo))
                {
                    colorTwo = Color.Green;
                    if (m_inputHandler.DidGetTargetedByLeftClick(buttonTwo))
                    {
                        m_drawDialog = false;
                        if (buttonTwoText == "Complete")
                        {
                            m_questSystem.ActivateNextQuest();
                        }
                    }
                }

                m_spriteBatch.Draw(m_dialogueWindow, new Vector2(m_textRect.Right - buttonWidth, m_textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);
            }

            m_spriteBatch.DrawString(m_spriteFont, buttonTwoText, new Vector2(buttonTwo.X + textMargin, buttonTwo.Y + 4), colorTwo);
        }
示例#7
0
        /// <summary>
        /// Method for rendering of interaction buttons
        /// </summary>
        private void DrawQuestButtons()
        {
            //Button properties
            int    buttonWidth  = (int)(270f * 0.27f);
            int    buttonHeight = (int)(100f * 0.26f); //Reduce dialog box size
            int    textMargin   = 7;
            Color  colorOne     = Color.White;
            Color  colorTwo     = Color.White;
            string buttonOneText;
            string buttonTwoText;

            //Button rectangles
            Rectangle buttonOne = new Rectangle(_textRect.Right - (buttonWidth * 2), _textRect.Bottom, buttonWidth, buttonHeight);
            Rectangle buttonTwo = new Rectangle(_textRect.Right - buttonWidth, _textRect.Bottom, buttonWidth, buttonHeight);

            if (_questSystem.QuestStatus == Model.QuestSystem.PRE)
            {
                buttonOneText = "Accept";
                buttonTwoText = "Decline";
                _spriteBatch.Draw(_dialogueWindow, new Vector2(_textRect.Right - buttonWidth, _textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);
                _spriteBatch.Draw(_dialogueWindow, new Vector2(_textRect.Right - (buttonWidth * 2), _textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);

                if (_inputHandler.MouseIsOver(buttonOne))
                {
                    colorOne = Color.Green;
                    if (_inputHandler.DidGetTargetedByLeftClick(buttonOne))
                    {
                        _questSystem.QuestStatus = Model.QuestSystem.MID;
                    }
                }

                if (_inputHandler.MouseIsOver(buttonTwo))
                {
                    colorTwo = Color.Red;
                    if (_inputHandler.DidGetTargetedByLeftClick(buttonTwo))
                    {
                        _drawDialog = false;
                    }
                }

                _spriteBatch.DrawString(_spriteFont, buttonOneText, new Vector2(buttonOne.X + 7, buttonOne.Y + 4), colorOne);
            }
            else
            {
                if ((_questSystem.QuestStatus == Model.QuestSystem.MID))
                {
                    buttonTwoText = "Okey";
                }
                else
                {
                    buttonTwoText = "Complete";
                }
                textMargin = 4;

                if (_inputHandler.MouseIsOver(buttonTwo))
                {
                    colorTwo = Color.Green;
                    if (_inputHandler.DidGetTargetedByLeftClick(buttonTwo))
                    {
                        _drawDialog = false;

                        if (buttonTwoText == "Complete")
                        {
                            _questSystem.ActivateNextQuest();
                        }
                    }
                }

                _spriteBatch.Draw(_dialogueWindow, new Vector2(_textRect.Right - buttonWidth, _textRect.Bottom), new Rectangle(0, 0, 270, 100), Color.White, 0f, Vector2.Zero, 0.26f, SpriteEffects.None, 0f);
            }

            _spriteBatch.DrawString(_spriteFont, buttonTwoText, new Vector2(buttonTwo.X + textMargin, buttonTwo.Y + 4), colorTwo);
        }
示例#8
0
        /// <summary>
        /// Method for drawing enemies
        /// </summary>
        /// <param name="elapsedTime">Elapsed time in milleseconds</param>
        private void DrawEnemies(float elapsedTime)
        {
            float mageTime    = elapsedTime;
            float warriorTime = elapsedTime;
            float swordTime   = elapsedTime;
            float goblinTime  = elapsedTime;
            float bossATime   = elapsedTime;

            _inputHandler.MouseIsOverEnemy = false;

            //Drawing dead enemies
            foreach (Model.Enemy deadEnemy in _deadEnemies)
            {
                Vector2 enemyPosition = _camera.VisualizeCordinates(deadEnemy.ThisUnit.Bounds.X + 8, deadEnemy.ThisUnit.Bounds.Y + 8);

                if (_inputHandler.MouseIsOver(new Rectangle((int)enemyPosition.X - 8, (int)enemyPosition.Y - 8, deadEnemy.ThisUnit.Bounds.Width, deadEnemy.ThisUnit.Bounds.Height)) &&
                    !_inputHandler.MouseIsOverInterface)
                {
                    _inputHandler.MouseIsOverLoot = true;
                }

                if (deadEnemy.Type == Model.Enemy.BOSS_A)
                {
                    _animationSystem.UpdateAndDraw(bossATime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.Texture.BOSS_A);
                }

                else if (deadEnemy.Type == Model.Enemy.CLASS_GOBLIN)
                {
                    _animationSystem.UpdateAndDraw(goblinTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.Texture.ENEMY_GOBLIN);
                }

                else if (deadEnemy.Type == Model.Enemy.CLASS_MAGE)
                {
                    _animationSystem.UpdateAndDraw(mageTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.Texture.ENEMY_MAGE);
                }

                else if (deadEnemy.Type == Model.Enemy.CLASS_WARRIOR)
                {
                    _animationSystem.UpdateAndDraw(warriorTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.Texture.ENEMY_KNIGHT);
                }

                if (_inputHandler.DidGetTargetedByLeftClick(new Rectangle((int)enemyPosition.X, (int)enemyPosition.Y, deadEnemy.ThisUnit.Bounds.Width, deadEnemy.ThisUnit.Bounds.Height)) & !_inputHandler.MouseIsOverInterface)
                {
                    //Checks if the player is in loot range
                    if (_player.ThisUnit.Bounds.Intersects(deadEnemy.ThisUnit.Bounds))
                    {
                        _player.LootTarget = deadEnemy;
                    }
                }
            }

            //m_enemies.OrderByDescending(Enemy => Enemy.ThisUnit.Bounds.Y);
            //Drawing all enemies
            foreach (Model.Enemy enemy in _enemies)
            {
                Vector2 enemyPosition = _camera.VisualizeCordinates(enemy.ThisUnit.Bounds.X + 8, enemy.ThisUnit.Bounds.Y + 8);

                //If mouse is hovering an enemiy
                if (_inputHandler.MouseIsOver(new Rectangle((int)enemyPosition.X - 8, (int)enemyPosition.Y - 8, enemy.ThisUnit.Bounds.Width, enemy.ThisUnit.Bounds.Height)) &&
                    !_inputHandler.MouseIsOverInterface)
                {
                    _inputHandler.MouseIsOverEnemy = true;
                }

                if (_player.Target == enemy)
                {
                    DrawTargetCircle(_player, enemy);
                }

                if (enemy.IsAttacking && (enemy.Type == Model.Enemy.CLASS_WARRIOR)) //|| enemy.Type == Model.Enemy.BOSS_A))
                {
                    DrawWeapon(swordTime, enemy.UnitState, enemy.WeaponState, enemy);
                    //BUGFIX.
                    swordTime = 0;
                }
                if (enemy.ThisUnit.Bounds.Intersects(_camera.GetScreenRectangle))
                {
                    //If the enemy occurs on the screen it is active
                    enemy.IsActive = true;

                    //If the enemy is targeted
                    if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(enemy.ThisUnit.Bounds)) && !_inputHandler.MouseIsOverInterface)
                    {
                        _player.Target      = enemy;
                        _player.IsAttacking = true;
                    }

                    //Drawing enemies that is alive
                    if (enemy.IsAlive())
                    {
                        if (enemy.Type == Model.Enemy.CLASS_WARRIOR)
                        {
                            _animationSystem.UpdateAndDraw(warriorTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.Texture.ENEMY_KNIGHT);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                warriorTime = 0;
                            }
                        }
                        else if (enemy.Type == Model.Enemy.CLASS_MAGE)
                        {
                            _animationSystem.UpdateAndDraw(mageTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.Texture.ENEMY_MAGE);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                mageTime = 0;
                            }
                        }
                        else if (enemy.Type == Model.Enemy.CLASS_GOBLIN)
                        {
                            _animationSystem.UpdateAndDraw(goblinTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.Texture.ENEMY_GOBLIN);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                goblinTime = 0;
                            }
                        }
                        else if (enemy.Type == Model.Enemy.BOSS_A)
                        {
                            _animationSystem.UpdateAndDraw(bossATime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.Texture.BOSS_A);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                bossATime = 0;
                            }
                        }
                    }
                }
                else
                {
                    enemy.IsActive = false;
                }
            }
        }
        //Metod för utritning av startskärm
        internal void DrawStartScreen()
        {
            m_stopWatch.Start();

            PlayStartTheme();

            //Ritar start BG
            DrawImage(SCREEN_START, Vector2.Zero, new Point(1280, 720), 1.0f);

            #region Animation
            int y = 0;
            int x = 10;

            if (m_stopWatch.ElapsedMilliseconds > 400)
            {
                y = 59;
                x = 192;
            }
            if (m_stopWatch.ElapsedMilliseconds > 800)
            {
                y = 118;
                x = 374;
            }
            if (m_stopWatch.ElapsedMilliseconds > 1200)
            {
                m_stopWatch.Stop();
                m_stopWatch.Reset();
            }
            #endregion

            //Ritar animation bilder
            m_spriteBatch.Draw(m_screenTextures[SCREEN_ANIMATION_A], new Vector2(23, 260), new Rectangle(0, y, 265, 59), Color.White);
            m_spriteBatch.Draw(m_screenTextures[SCREEN_ANIMATION_B], new Vector2(154, 352), new Rectangle(x, 0, 170, 247), Color.White);

            if (!m_showOptions && !m_showCredits)
            {
                //Ritar starmeny
                DrawImage(SCREEN_BORDER_BG, new Vector2(727, 0), new Point(300, 720), 1.0f);
                DrawButton(BUTTONS_START_MENU, new Vector2(750, 325), new Point(512, 512), 0.5f);

                //Skapar knapp area för startmeny
                Rectangle newGameArea = new Rectangle(750, 325, 250, 40);
                Rectangle optionsArea = new Rectangle(750, 404, 250, 40);
                Rectangle creditsArea = new Rectangle(750, 450, 250, 30);
                Rectangle exitArea    = new Rectangle(750, 485, 250, 30);

                #region Inputhantering för startmeny
                if (m_inputHandler.MouseIsOver(newGameArea))
                {
                    DrawButton(BUTTONS_NEWGAME_SELECTED, new Vector2(750, 319), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.MENU_BUTTON_HOVER);

                    if (m_inputHandler.DidGetTargetedByLeftClick(newGameArea))
                    {
                        PlayMenuSound(SoundHandler.MENU_BUTTON_SELECT_B);
                        m_didPressNewGame = true;
                    }
                }
                else if (m_inputHandler.MouseIsOver(optionsArea))
                {
                    DrawButton(BUTTONS_OPTIONS_SELECTED, new Vector2(750, 396), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.MENU_BUTTON_HOVER);

                    if (m_inputHandler.DidGetTargetedByLeftClick(optionsArea))
                    {
                        PlayMenuSound(SoundHandler.MENU_BUTTON_SELECT);
                        m_showOptions = true;
                    }
                }
                else if (m_inputHandler.MouseIsOver(creditsArea))
                {
                    DrawButton(BUTTONS_CREDITS_SELECTED, new Vector2(750, 434), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.MENU_BUTTON_HOVER);

                    if (m_inputHandler.DidGetTargetedByLeftClick(creditsArea))
                    {
                        PlayMenuSound(SoundHandler.MENU_BUTTON_SELECT);
                        m_showCredits = true;
                    }
                }
                else if (m_inputHandler.MouseIsOver(exitArea))
                {
                    DrawButton(BUTTONS_EXIT_SELECTED, new Vector2(750, 473), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.MENU_BUTTON_HOVER);

                    if (m_inputHandler.DidGetTargetedByLeftClick(exitArea))
                    {
                        m_didPressExit = true;
                    }
                }
                else
                {
                    m_didHover = false;
                }

                #endregion
            }
            else if (m_showOptions)
            {
                DrawOptionScreen(new Vector2(727, 0));
            }
            else
            {
                DrawCreditsScreen();
            }
        }
示例#10
0
        /// <summary>
        /// Method for drawing the start screen
        /// </summary>
        internal void DrawStartScreen()
        {
            _stopWatch.Start();
            PlayStartTheme();

            //Startscreen background
            DrawImage(Screen.SCREEN_START, Vector2.Zero, new Point(1280, 720), 1.0f);

            #region Startscreen animation
            int y = 0;
            int x = 10;

            if (_stopWatch.ElapsedMilliseconds > 400)
            {
                y = 59;
                x = 192;
            }
            if (_stopWatch.ElapsedMilliseconds > 800)
            {
                y = 118;
                x = 374;
            }
            if (_stopWatch.ElapsedMilliseconds > 1200)
            {
                _stopWatch.Stop();
                _stopWatch.Reset();
            }

            _spriteBatch.Draw(_screenContent.Screens[Convert.ToInt32(Screen.SCREEN_ANIMATION_A)], new Vector2(23, 260), new Rectangle(0, y, 265, 59), Color.White);
            _spriteBatch.Draw(_screenContent.Screens[Convert.ToInt32(Screen.SCREEN_ANIMATION_B)], new Vector2(154, 352), new Rectangle(x, 0, 170, 247), Color.White);
            #endregion

            if (!DidPressOptions && !DidShowCredits)
            {
                //Drawing startmenu
                DrawImage(Screen.SCREEN_BORDER_BG, new Vector2(727, 0), new Point(300, 720), 1.0f);
                DrawButton(Button.BUTTONS_START_MENU, new Vector2(750, 325), new Point(512, 512), 0.5f);

                //Button areas for startmenu
                Rectangle newGameArea = new Rectangle(750, 325, 250, 40);
                Rectangle optionsArea = new Rectangle(750, 404, 250, 40);
                Rectangle creditsArea = new Rectangle(750, 450, 250, 30);
                Rectangle exitArea    = new Rectangle(750, 485, 250, 30);

                #region Inputhandling for startmenu
                if (_inputHandler.MouseIsOver(newGameArea))
                {
                    DrawButton(Button.BUTTONS_NEWGAME_SELECTED, new Vector2(750, 319), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_HOVER);

                    if (_inputHandler.DidGetTargetedByLeftClick(newGameArea))
                    {
                        PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_SELECT_B);
                        DidPressNewGame = true;
                    }
                }
                else if (_inputHandler.MouseIsOver(optionsArea))
                {
                    DrawButton(Button.BUTTONS_OPTIONS_SELECTED, new Vector2(750, 396), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_HOVER);

                    if (_inputHandler.DidGetTargetedByLeftClick(optionsArea))
                    {
                        PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_SELECT);
                        DidPressOptions = true;
                    }
                }
                else if (_inputHandler.MouseIsOver(creditsArea))
                {
                    DrawButton(Button.BUTTONS_CREDITS_SELECTED, new Vector2(750, 434), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_HOVER);

                    if (_inputHandler.DidGetTargetedByLeftClick(creditsArea))
                    {
                        PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_SELECT);
                        DidShowCredits = true;
                    }
                }
                else if (_inputHandler.MouseIsOver(exitArea))
                {
                    DrawButton(Button.BUTTONS_EXIT_SELECTED, new Vector2(750, 473), new Point(512, 100), 0.5f);
                    PlayMenuSound(SoundHandler.Effect.MENU_BUTTON_HOVER);

                    if (_inputHandler.DidGetTargetedByLeftClick(exitArea))
                    {
                        DidPressExit = true;
                    }
                }
                else
                {
                    _didHover = false;
                }
                #endregion
            }
            else if (DidPressOptions)
            {
                DrawOptionScreen(new Vector2(727, 0));
            }
            else
            {
                DrawCreditsScreen();
            }
        }
示例#11
0
        //Metod för utritning av enemy NPCs
        private void DrawEnemies(float a_elapsedTime)
        {
            float mageTime    = a_elapsedTime;
            float warriorTime = a_elapsedTime;
            float swordTime   = a_elapsedTime;
            float goblinTime  = a_elapsedTime;
            float bossATime   = a_elapsedTime;

            m_inputHandler.MouseIsOverEnemy = false;

            //Riter ut döda fiender.
            foreach (Model.Enemy deadEnemy in m_deadEnemies)
            {
                Vector2 enemyPosition = m_camera.VisualizeCordinates(deadEnemy.ThisUnit.Bounds.X + 8, deadEnemy.ThisUnit.Bounds.Y + 8);

                if (m_inputHandler.MouseIsOver(new Rectangle((int)enemyPosition.X - 8, (int)enemyPosition.Y - 8, deadEnemy.ThisUnit.Bounds.Width, deadEnemy.ThisUnit.Bounds.Height)) &&
                    !m_inputHandler.MouseIsOverInterface)
                {
                    m_inputHandler.MouseIsOverLoot = true;
                }

                if (deadEnemy.Type == Model.Enemy.BOSS_A)
                {
                    m_animationSystem.UpdateAndDraw(bossATime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.BOSS_A);
                }
                else if (deadEnemy.Type == Model.Enemy.CLASS_GOBLIN)
                {
                    m_animationSystem.UpdateAndDraw(goblinTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.ENEMY_GOBLIN);
                }
                else if (deadEnemy.Type == Model.Enemy.CLASS_MAGE)
                {
                    m_animationSystem.UpdateAndDraw(mageTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.ENEMY_MAGE);
                }
                else if (deadEnemy.Type == Model.Enemy.CLASS_WARRIOR)
                {
                    m_animationSystem.UpdateAndDraw(warriorTime, Color.White, enemyPosition, deadEnemy.UnitState, AnimationSystem.ENEMY_KNIGHT);
                }

                if (m_inputHandler.DidGetTargetedByLeftClick(new Rectangle((int)enemyPosition.X, (int)enemyPosition.Y, deadEnemy.ThisUnit.Bounds.Width, deadEnemy.ThisUnit.Bounds.Height)) & !m_inputHandler.MouseIsOverInterface)
                {
                    //Kontrollerar så att man är tillräckligt nära för att loota en fiende.
                    if (m_player.ThisUnit.Bounds.Intersects(deadEnemy.ThisUnit.Bounds))
                    {
                        m_player.LootTarget = deadEnemy;
                    }
                }
            }

            // m_enemies.OrderByDescending(Enemy => Enemy.ThisUnit.Bounds.Y);
            //Försök på att måla ut fiender och tillbehör.
            foreach (Model.Enemy enemy in m_enemies)
            {
                //LAGT DEN HÄR UTE FÖR ATT HA DÖDS Animation också.
                //TODO: Klass för visualisering av position
                Vector2 enemyPosition = m_camera.VisualizeCordinates(enemy.ThisUnit.Bounds.X + 8, enemy.ThisUnit.Bounds.Y + 8);

                //Testar om musen är över en fiende.
                if (m_inputHandler.MouseIsOver(new Rectangle((int)enemyPosition.X - 8, (int)enemyPosition.Y - 8, enemy.ThisUnit.Bounds.Width, enemy.ThisUnit.Bounds.Height)) &&
                    !m_inputHandler.MouseIsOverInterface)
                {
                    m_inputHandler.MouseIsOverEnemy = true;
                }

                if (m_player.Target == enemy)
                {
                    //Ritar target ring
                    DrawTargetCircle(m_player, enemy);
                }

                if (enemy.IsAttacking && (enemy.Type == Model.Enemy.CLASS_WARRIOR)) //|| enemy.Type == Model.Enemy.BOSS_A))
                {
                    DrawWeapon(swordTime, enemy.UnitState, enemy.WeaponState, enemy);
                    //BUGGFIXXX.
                    swordTime = 0;
                }
                if (enemy.ThisUnit.Bounds.Intersects(m_camera.GetScreenRectangle))
                {
                    //Om fienden syns på skärmen är den aktiv
                    enemy.IsActive = true;

                    //Testar om spelaren har satt target på en fiende.
                    if (m_inputHandler.DidGetTargetedByLeftClick(m_camera.VisualizeRectangle(enemy.ThisUnit.Bounds)) && !m_inputHandler.MouseIsOverInterface)
                    {
                        //Sätter en fiende i form av mapobjekt som spelarens target.
                        m_player.Target      = enemy;
                        m_player.IsAttacking = true;
                    }

                    //Är inte fienden levande och aktiv ritas han ut.
                    if (enemy.IsAlive())
                    {
                        //Ritar Enemy animation
                        if (enemy.Type == Model.Enemy.CLASS_WARRIOR)
                        {
                            m_animationSystem.UpdateAndDraw(warriorTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.ENEMY_KNIGHT);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                warriorTime = 0;
                            }
                        }

                        else if (enemy.Type == Model.Enemy.CLASS_MAGE)
                        {
                            m_animationSystem.UpdateAndDraw(mageTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.ENEMY_MAGE);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                mageTime = 0;
                            }
                        }

                        else if (enemy.Type == Model.Enemy.CLASS_GOBLIN)
                        {
                            m_animationSystem.UpdateAndDraw(goblinTime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.ENEMY_GOBLIN);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                goblinTime = 0;
                            }
                        }

                        else if (enemy.Type == Model.Enemy.BOSS_A)
                        {
                            m_animationSystem.UpdateAndDraw(bossATime, Color.White, enemyPosition, enemy.UnitState, AnimationSystem.BOSS_A);

                            if (enemy.IsAttacking || enemy.IsEvading)
                            {
                                bossATime = 0;
                            }
                        }
                    }
                }
                else
                {
                    enemy.IsActive = false;
                }
            }
        }