Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Method for drawing the move-to cross
 /// </summary>
 private void DrawMoveToCross()
 {
     if (_inputHandler.DidRightClick() && !_inputHandler.MouseIsOverInterface)
     {
         _rightClickWatch.Reset();
         _rightClickWatch.Start();
         _moveToPos   = _player.MoveToPosition;
         _moveToColor = 1f;
     }
     if (_rightClickWatch.IsRunning && _rightClickWatch.ElapsedMilliseconds < 1000)
     {
         _moveToColor = _moveToColor - 0.015f;
         Color   color = new Color(_moveToColor, _moveToColor, _moveToColor, _moveToColor);
         Vector2 pos   = _camera.VisualizeCordinates((int)_moveToPos.X - 16, (int)_moveToPos.Y);
         _spriteBatch.Draw(GetTexture(Texture.MOVE_TO_CROSS), pos, color);
     }
     else
     {
         _rightClickWatch.Stop();
         _rightClickWatch.Reset();
     }
 }
        //Metod för utritning av Move-to krysset
        private void DrawMoveToCross()
        {
            if (m_inputHandler.DidRightClick() && !m_inputHandler.MouseIsOverInterface)
            {
                m_rightClickWatch.Reset();
                m_rightClickWatch.Start();
                m_moveToPos   = m_player.MoveToPosition;
                m_moveToColor = 1f;
            }
            if (m_rightClickWatch.IsRunning && m_rightClickWatch.ElapsedMilliseconds < 1000)
            {
                m_moveToColor = m_moveToColor - 0.015f;
                Color   color = new Color(m_moveToColor, m_moveToColor, m_moveToColor, m_moveToColor);
                Vector2 pos   = m_camera.VisualizeCordinates((int)m_moveToPos.X - 16, (int)m_moveToPos.Y);
                m_spriteBatch.Draw(m_textures[MOVE_TO_CROSS], pos, color);
            }

            else
            {
                m_rightClickWatch.Stop();
                m_rightClickWatch.Reset();
            }
        }