示例#1
0
        public virtual void DrawGrid(Vector2 a_offset, string a_layer)
        {
            Globals.NormalEffect.Parameters["filterColor"].SetValue(Color.White.ToVector4());
            Globals.NormalEffect.CurrentTechnique.Passes[0].Apply();

            if (_showGrid && a_layer == "BackgroundLayer")
            {
                //Vector2 topLeft = GetLocationFromPixel((new Vector2(0, 0)) / Globals.zoom  - a_offset, Vector2.Zero);
                //Vector2 botRight = GetLocationFromPixel((new Vector2(Globals.screenWidth, Globals.screenHeight)) / Globals.zoom  - a_offset, Vector2.Zero);
                //Vector2 topLeft = GetLocationFromPixel(new Vector2(0, 0), Vector2.Zero);
                //Vector2 botRight = GetLocationFromPixel(new Vector2(Globals.ScreenWidth, Globals.ScreenHeight), Vector2.Zero);

                for (int j = (int)_topLeft.X; j <= _botRight.X && j < _slots.Count; j++)
                {
                    for (int k = (int)_topLeft.Y; k <= _botRight.Y && k < _slots[0].Count; k++)
                    {
                        if (_currentHoverSlot.X == j && _currentHoverSlot.Y == k)
                        {
                            Globals.NormalEffect.Parameters["filterColor"].SetValue(Color.Red.ToVector4());
                            Globals.NormalEffect.CurrentTechnique.Passes[0].Apply();
                        }
                        else if (_slots[j][k].Filled)
                        {
                            Globals.NormalEffect.Parameters["filterColor"].SetValue(Color.DarkGreen.ToVector4());
                            Globals.NormalEffect.CurrentTechnique.Passes[0].Apply();
                        }
                        else
                        {
                            Globals.NormalEffect.Parameters["filterColor"].SetValue(Color.White.ToVector4());
                            Globals.NormalEffect.CurrentTechnique.Passes[0].Apply();
                        }

                        _gridImg.Draw(a_offset + _physicalStartPos + new Vector2(j * _slotDims.X, k * _slotDims.Y));
                    }
                }
            }
            foreach (GridItem item in _gridItems.Where(gItem => (string)gItem.Layer == a_layer))
            {
                item.Draw(a_offset);
            }
        }
示例#2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            Source.Engine.Globals.MySpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);


            if (Source.Engine.Globals.GameState == 0)
            {
                _mainMenu.Draw();
            }
            else if (Source.Engine.Globals.GameState == 1)
            {
                _gameplay.Draw();
            }


            _cursor.Draw(Source.Engine.Globals.NewVector(Source.Engine.Globals.MyMouse.NewMousePos), Vector2.Zero, Color.White);
            Source.Engine.Globals.MySpriteBatch.End();

            base.Draw(gameTime);
        }