Пример #1
0
        public override void Draw(DrawBatch drawBatch)
        {
            drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, new Rectangle((int)PositionXY.X - 3, (int)(position.Y - position.Z) - 3, 6, 6), Color.Purple, DrawBatch.CalculateDepth(PositionXY));
            drawBatch.Draw(DrawBatch.DrawCall.Tag.Light, Game1.fader, new Vector2(PositionXY.X, PositionXY.Y), .2f, 0f, new Vector2(Game1.fader.Width * .5f), Color.Purple, DrawBatch.CalculateDepth(PositionXY));

            base.Draw(drawBatch);
        }
Пример #2
0
            public override void Draw(DrawBatch drawBatch)
            {
                Color newColor = Color.Lerp(color, Color.Transparent, MathTransformations.Transform(MathTransformations.Type.NormalizedSmoothStart2, timeAlive / (float)timeToLive) + .4f);

                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, new Rectangle((int)(PositionXY.X - 1 * scale), (int)((position.Y - position.Z) - 1 * scale), (int)(2 * scale), (int)(2 * scale)), new Rectangle(0, 0, 1, 1), newColor, DrawBatch.CalculateDepth(PositionXY), (short)2, 1);
                drawBatch.Draw(DrawBatch.DrawCall.Tag.Light, Game1.fader, new Vector2(PositionXY.X, PositionXY.Y - position.Z), .35f * scale, 0f, new Vector2(Game1.fader.Width * .5f), Color.Lerp(newColor, Color.DarkGray, .05f), DrawBatch.CalculateDepth(PositionXY));

                base.Draw(drawBatch);
            }
Пример #3
0
        public void Draw(bool drawLines, Vector2 offset, RigLimb rigLimb, DrawBatch drawBatch, float depth, float orientation)
        {
            Vector4 line       = rigLimb.Get2DLine(orientation);
            Vector3 scaleAngle = Texture.GetScaleAndAngle(line);
            int     index      = Texture.GetIndex(GetAngleToDisplay(rigLimb.rotation, orientation));

            Color color = Color.White;

            //if (rigLimb.name == Game1.selectedLimb)
            //{
            //    color = Color.Green;
            //}
            //else
            //    color = Color.White;

            //spriteBatch.Draw(Texture.Texture, new Vector2(line.X + offset.X, line.Y + offset.Y), Texture.GetSourceRectangle(index), color, scaleAngle.Z, new Vector2(8, 8), new Vector2(scaleAngle.X, scaleAngle.Y), SpriteEffects.None, depth);
            if (Game1.rigDrawTextures && rigLimb.drawTexture)
            {
                Rectangle rectangleToDraw = new Rectangle(new Vector2(line.X + offset.X, line.Y + offset.Y).ToPoint(), new Vector2(Texture.Width * scaleAngle.X + Texture.Origin.X * 2, Texture.Height * scaleAngle.Y).ToPoint());

                //float fuckScale = (((rectangleToDraw.Width * 2 - Texture.Origin.X * 2))) / (Texture.Width * 2 + Texture.Origin.X * 2);
                //float fuckOrigin = (Texture.Width / 2) * (1-fuckScale) + ((fuckScale) * Texture.Origin.X);

                float fuckOrigin;
                if (scaleAngle.X < .5f)
                {
                    fuckOrigin = ((Texture.Width / 2f) - (Texture.Width / 4f) * scaleAngle.X) * (1 - scaleAngle.X);// + 8 * (scaleAngle.X);
                }
                else
                {
                    fuckOrigin = Texture.Origin.X + (Texture.Origin.X / 2) * ((1 - scaleAngle.X) * 2);
                }

                if (scaleAngle.X > 1)
                {
                    drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Texture.Texture, rectangleToDraw, Texture.GetSourceRectangle(index), scaleAngle.Z, new Vector2(Texture.Origin.X / scaleAngle.X, Texture.Origin.Y), color, depth, SpriteEffects.None);
                }
                else
                {
                    drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Texture.Texture, rectangleToDraw, Texture.GetSourceRectangle(index), scaleAngle.Z, new Vector2(fuckOrigin, Texture.Origin.Y), color, depth, SpriteEffects.None);
                }
            }
            //Game1.DrawLine(spriteBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.X + offset.X, line.Y + offset.Y) + Extensions.GetVector2(Texture.Texture.Width * scaleAngle.X, scaleAngle.Z), 2, Color.Lerp(Color.Blue, Color.Transparent, .5f), 0f);

            if (drawLines)
            {
                if (rigLimb.name == Game1.selectedLimb)
                {
                    Game1.DrawLine(drawBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.Z + offset.X, line.W + offset.Y), 2, Color.Lerp(Color.Red, Color.Transparent, 0f), depth);
                }
                else
                {
                    Game1.DrawLine(drawBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.Z + offset.X, line.W + offset.Y), 2, Color.Lerp(Color.Black, Color.Transparent, 0f), depth);
                }
            }
        }
Пример #4
0
            public override void Draw(DrawBatch drawBatch)
            {
                float flack = (float)Math.Cos(timeAlive / 4.3f);

                //sprite.Draw(drawBatch, DrawBatch.DrawCall.Tag.GameObject, PositionXY + new Vector2(0), MovementXY.GetAngle(), new Vector2(56, 16), new Vector2(.5f), Color.Lerp(Color.Black, Color.Transparent, .5f), DrawBatch.CalculateDepth(PositionXY));
                sprite.Draw(drawBatch, DrawBatch.DrawCall.Tag.GameObject, PositionXY + new Vector2(0, -position.Z), MovementXY.GetAngle(), new Vector2(56, 16), DrawBatch.CalculateDepth(PositionXY));

                drawBatch.Draw(DrawBatch.DrawCall.Tag.Light, Game1.fader, PositionXY + new Vector2(0, -position.Z), Extensions.LerpFloat(.3f, .6f, flack * flack), 0f, new Vector2(Game1.fader.Width / 2, Game1.fader.Height / 2), Color.Lerp(Color.OrangeRed, new Color(240, 220, 0), .1f + flack * .8f), DrawBatch.CalculateDepth(PositionXY) + .0001f);
                drawBatch.Draw(DrawBatch.DrawCall.Tag.Light, Game1.fader, PositionXY + new Vector2(0, -position.Z), .6f, 0f, new Vector2(Game1.fader.Width / 2, Game1.fader.Height / 2), Color.Lerp(Color.LightGoldenrodYellow, Color.Black, .4f), DrawBatch.CalculateDepth(PositionXY) + .0001f);
            }
Пример #5
0
        public override void Draw(DrawBatch drawBatch)
        {
            if (SelectionHandler.TileObjectsContains(Position))
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, texture, (hitBox.Location.ScaleRet(World.tileSize) + new Point(World.tileSize / 2) - origin).ToVector2(), Color.Red, DrawBatch.CalculateDepth(new Vector2(Position.X * 16 + 8, Position.Y * 16 + 8)));
            }
            else
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, texture, (hitBox.Location.ScaleRet(World.tileSize) + new Point(World.tileSize / 2) - origin).ToVector2(), Color.White, DrawBatch.CalculateDepth(new Vector2(Position.X * 16 + 8, Position.Y * 16 + 8)));
            }

            base.Draw(drawBatch);
        }
Пример #6
0
            public override void Draw(DrawBatch drawBatch, float orientation, string selectedLimb, Vector2 offset, float depth)
            {
                drawPos = new Vector2(position.X, position.Y);

                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, new Rectangle((int)position.X, (int)position.Y, 4, 4), Color.AliceBlue, DrawBatch.CalculateDepth(new Vector2(position.X, position.Y)));

                Dictionary <string, Vector4> lines = Get2DLines(orientation);
                Vector4 value;

                foreach (KeyValuePair <string, Vector4> pair in lines)
                {
                    value = new Vector4(pair.Value.X + drawPos.X + offset.X, pair.Value.Y + drawPos.Y + offset.Y, pair.Value.Z + drawPos.X + offset.X, pair.Value.W + drawPos.Y + offset.Y);
                    if ("X" == pair.Key)
                    {
                        Game1.DrawLine(drawBatch, value, 3f, Color.Blue, 0f);
                    }
                    else if ("Y" == pair.Key)
                    {
                        Game1.DrawLine(drawBatch, value, 3f, Color.Red, 0f);
                    }
                    else if ("Z" == pair.Key)
                    {
                        Game1.DrawLine(drawBatch, value, 3f, Color.Green, 0f);
                    }
                }
            }
Пример #7
0
        public virtual void DrawName(DrawBatch drawBatch, float scale)
        {
            Vector2 measurements = (Game1.fontDebug.MeasureString(item.name) * scale);
            float   depth        = DrawBatch.CalculateDepth(PositionXY);

            drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, new Rectangle((int)(position.X - measurements.X / 2), (int)(position.Y + 20 - position.Z - measurements.Y / 2), (int)measurements.X, (int)measurements.Y), Color.DarkBlue, depth);
            drawBatch.DrawString(DrawBatch.DrawCall.Tag.GameObject, item.name, Game1.fontDebug, new Vector2(position.X, position.Y + 20 - position.Z), scale, 0f, measurements / 2, Color.White, depth);
        }
Пример #8
0
        public override void Draw(DrawBatch drawBatch)
        {
            if (SelectionHandler.selectedID == ID)
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, texture, SelectionHitBox, Color.Blue, DrawBatch.CalculateDepth(PositionXY));
            }
            else if (tag == Tag.Enemy)
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, texture, SelectionHitBox, Color.Red, DrawBatch.CalculateDepth(PositionXY));
            }
            else if (tag == Tag.Player)
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, texture, SelectionHitBox, Color.White, DrawBatch.CalculateDepth(PositionXY));
            }

            drawBatch.DrawString(DrawBatch.DrawCall.Tag.GameObject, GetCurrentHealth().ToString(), Game1.fontDebug, PositionXY - new Vector2(10), Color.Red, DrawBatch.CalculateDepth(PositionXY));

            healthBar.drawRectangle = new Rectangle((int)(position.X - 16), (int)(position.Y + 10), 32, 8);

            healthBar.Draw(DrawBatch.DrawCall.Tag.GameObject, drawBatch, DrawBatch.CalculateDepth(PositionXY), (short)2, 0f);

            //collider.Draw(spriteBatch, 2f, Color.Cyan);
        }
Пример #9
0
 public override void Draw(DrawBatch drawBatch, float thickness, Color color)
 {
     drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, Position, thickness, 0f, new Vector2(.5f), color, DrawBatch.CalculateDepth(Position));
 }
Пример #10
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="tag"></param>
            /// <param name="drawBatch"></param>
            /// <param name="depth"></param>
            /// <param name="affectedByLight">0 - always dark, 1 - dynamic, 2 - always bright</param>
            /// <param name="lightBleedThrough"></param>
            internal void Draw(DrawBatch.DrawCall.Tag tag, DrawBatch drawBatch, float depth, short affectedByLight, float lightBleedThrough)
            {
                Rectangle sourceOffsets = GetSourceRectangleOffsets();

                drawBatch.Draw(tag, texture, GetRectangleToDraw(drawRectangle), sourceOffsets, color, depth, affectedByLight, lightBleedThrough);
            }
Пример #11
0
        public static void DrawLine(DrawBatch drawBatch, Vector4 v, float thickness, Color color, float depth)
        {
            Vector2 delta = new Vector2(v.Z - v.X, v.W - v.Y);

            drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Vector2(v.X, v.Y), new Vector2(delta.Length(), thickness), Extensions.GetAngle(delta), Vector2.Zero, color, depth);
        }
Пример #12
0
        private void DrawGame()
        {
            //Draw stuff here
            terrain.Draw(drawBatch);


            for (int i = 0; i < agents.Count; i++)
            {
                agents[i].Draw(drawBatch);
                if (agents[i].state == Agent.State.Walking)
                {
                    for (int j = 0; j < agents[i].path.instructions.Length; j++)
                    {
                        drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle(agents[i].path.instructions[j].X * 16, agents[i].path.instructions[j].Y * 16, World.tileSize, World.tileSize), Color.Lerp(Color.Black, Color.Transparent, .5f), 1f);
                    }
                }
            }

            for (int i = 0; i < gameObjects.Count; i++)
            {
                gameObjects[i].Draw(drawBatch);
            }

            List <Point> intersectingTiles = new List <Point>();
            Point        p = new Point(-1);

            if (MouseButtonDownLeft(false))
            {
                /*
                 * if (terrain.RayCastObstacle(SelectionHandler.selectionPoint.ToVector2(), SelectionHandler.selectionPointSecond.ToVector2(), out p, out intersectingTiles))
                 * {
                 *  DrawLine(drawBatch, SelectionHandler.selectionPoint.ToVector2(), SelectionHandler.selectionPointSecond.ToVector2(), 2, Color.Red, 1f);
                 *  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle(p.X * World.tileSize, p.Y * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.Red, Color.Transparent, .5f), 1f);
                 * }
                 * else
                 *  DrawLine(drawBatch, SelectionHandler.selectionPoint.ToVector2(), SelectionHandler.selectionPointSecond.ToVector2(), 2, Color.Green, 1f);
                 *
                 * for (int i = 0; i < intersectingTiles.Count; i++)
                 * {
                 *  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle(intersectingTiles[i].X * World.tileSize, intersectingTiles[i].Y * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.Blue, Color.Transparent, .5f), 1f);
                 * }
                 */
            }

            drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle((int)mousePosInWorld.X - 2, (int)mousePosInWorld.Y - 2, 4, 4), Color.Green, 1f);

            if (SelectionHandler.CurrentTarget == SelectionHandler.Target.Tile)
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle(mouseTile.X * World.tileSize, mouseTile.Y * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.Lime, Color.Transparent, .5f), 1f);
            }

            if (SelectionHandler.CurrentTarget == SelectionHandler.Target.Tile)
            {
                for (int i = 0; i < SelectionHandler.TileRectangle.Width; i++)
                {
                    for (int j = 0; j < SelectionHandler.TileRectangle.Height; j++)
                    {
                        if ((SelectionHandler.TileRectangle.X + i) * World.tileSize > 0 && (SelectionHandler.TileRectangle.Y + i) * World.tileSize > 0)
                        {
                            drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, new Rectangle((SelectionHandler.TileRectangle.X + i) * World.tileSize, (SelectionHandler.TileRectangle.Y + j) * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.Purple, Color.Transparent, .5f), 1f);
                        }
                    }
                }
            }
            else
            {
                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, pixel, SelectionHandler.SelectionRectangle, Color.Lerp(Color.Olive, Color.Transparent, .5f), 1f);
            }


            for (int i = 0; i < effects.Count; i++)
            {
                if (effects[i].remove)
                {
                    effects.RemoveAt(i);
                    i--;
                }
                else
                {
                    effects[i].Draw(drawBatch);
                }
            }


            DrawLights();

            DrawRectangle(drawBatch, camera.Rectangle, 2f, Color.OrangeRed, 1f);

            //Draw GameWorld to the scene and rendertarget
            GraphicsDevice.SetRenderTarget(RTGameWorld);
            GraphicsDevice.Clear(Color.White);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation(GraphicsDevice));
            drawBatch.DrawSceneGameObjects(spriteBatch);
            spriteBatch.End();
        }
Пример #13
0
 internal void DrawIcon(DrawBatch drawBatch, Rectangle rectangle, float depth)
 {
     drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, iconSheet, rectangle, new Rectangle(new Point(iconSize.X * iconSheetPosition.X, iconSheetPosition.Y * iconSize.Y), iconSize), Color.White, depth);
 }
Пример #14
0
        public void Draw(DrawBatch drawBatch)
        {
            Point edgeOffset = Point.Zero;
            float rotation   = 0f;

            //Draw Materials
            for (int i = 0; i < size.X; i++)
            {
                for (int j = 0; j < size.Y; j++)
                {
                    if (Game1.camera.Rectangle.Contains(new Rectangle(i * World.tileSize, j * World.tileSize, size.X, size.Y)))
                    {
                        drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, sheet, new Rectangle(i * World.tileSize, j * World.tileSize, World.tileSize, World.tileSize), GetMaterialTextureSrcRect(materials[i, j]), 0, Vector2.Zero, Color.White, 0f, SpriteEffects.None, 1, 0f);

                        /*
                         * //Draw edges
                         * if (i > 0 && j > 0 && i < size.X - 1 && j < size.Y - 1)
                         * {
                         *  for (int k = 0; k < 4; k++)
                         *  {
                         *      switch (k)
                         *      {
                         *          case 0:
                         *              edgeOffset = new Point(1, 0);
                         *              break;
                         *          case 1:
                         *              edgeOffset = new Point(0, -1);
                         *              break;
                         *          case 2:
                         *              edgeOffset = new Point(-1, 0);
                         *              break;
                         *          case 3:
                         *              edgeOffset = new Point(0, 1);
                         *              break;
                         *          default:
                         *              break;
                         *      }
                         *
                         *      if (materialEdgePriority[(int)materials[i, j]] > materialEdgePriority[(int)materials[i + edgeOffset.X, j + edgeOffset.Y]])
                         *          switch (k)
                         *          {
                         *              case 0:
                         *                  rotation = 0f;
                         *                  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, sheetEdges, new Rectangle(i * World.tileSize + World.tileSize, j * World.tileSize, 4, World.tileSize), GetMaterialEdgeTextureSrcRect(materials[i, j]), rotation, Vector2.Zero, Color.White, 0f, SpriteEffects.None, 1, 0f);
                         *                  break;
                         *              case 1:
                         *                  rotation = 4.71f;
                         *                  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, sheetEdges, new Rectangle(i * World.tileSize, j * World.tileSize, 4, World.tileSize), GetMaterialEdgeTextureSrcRect(materials[i, j]), rotation, Vector2.Zero, Color.White, 0f, SpriteEffects.None, 1, 0f);
                         *                  break;
                         *              case 2:
                         *                  rotation = 0f;
                         *                  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, sheetEdges, new Rectangle(i * World.tileSize - 4, j * World.tileSize, 4, World.tileSize), GetMaterialEdgeTextureSrcRect(materials[i, j]), rotation, Vector2.Zero, Color.White, 0f, SpriteEffects.FlipHorizontally, 1, 0f);
                         *                  break;
                         *              case 3:
                         *                  rotation = 4.71f;
                         *                  drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, sheetEdges, new Rectangle(i * World.tileSize, j * World.tileSize + World.tileSize + 4, 4, World.tileSize), GetMaterialEdgeTextureSrcRect(materials[i, j]), rotation, Vector2.Zero, Color.White, 0f, SpriteEffects.FlipHorizontally, 1, 0f);
                         *                  break;
                         *              default:
                         *                  break;
                         *          }
                         *  }
                         * }
                         */
                    }
                }
            }

            /*
             * for (int i = 0; i < tileReferences.GetLength(0); i++)
             * {
             *  for (int j = 0; j < tileReferences.GetLength(1); j++)
             *  {
             *      if (tileReferences[i, j] != null && tileReferences[i, j] != new Point(-1, -1))
             *      {
             *          if (tileReferences[i, j] == new Point(i, j))
             *              spriteBatch.Draw(Game1.pixel, new Rectangle(i * World.tileSize, j * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.Cyan, Color.Transparent, .5f));
             *          else
             *              spriteBatch.Draw(Game1.pixel, new Rectangle(i * World.tileSize, j * World.tileSize, World.tileSize, World.tileSize), Color.Lerp(Color.ForestGreen, Color.Transparent, .5f));
             *      }
             *  }
             * }
             */

            //Draw TileObjects
            for (int i = 0; i < tileObjects.GetLength(0); i++)
            {
                for (int j = 0; j < tileObjects.GetLength(1); j++)
                {
                    if (tileObjects[i, j] != null)
                    {
                        tileObjects[i, j].Draw(drawBatch);
                    }
                }
            }
        }
Пример #15
0
 public void Draw(DrawBatch drawBatch, DrawBatch.DrawCall.Tag tag, Vector2 position, float rotation, Vector2 origin, Vector2 scale, Color color, float depth)
 {
     drawBatch.Draw(tag, texture, position, GetSourceRectangle(), scale, rotation, origin, color, depth, SpriteEffects.None, affectedByLight, lightBleedThrough);
     Increment();
 }
Пример #16
0
 public void Draw(DrawBatch drawBatch, DrawBatch.DrawCall.Tag tag, Vector2 position, float depth)
 {
     drawBatch.Draw(tag, texture, position, GetSourceRectangle(), new Vector2(1), 0f, Vector2.Zero, Color.White, depth, SpriteEffects.None, affectedByLight, lightBleedThrough);
     Increment();
 }