public override void Draw(GameTime gameTime, Point mousePos)
        {
            Text.Draw(Font, textPoint.ToVector2(), 1,
                      HitBox.Contains(mousePos));

            base.Draw(gameTime, mousePos);
        }
Beispiel #2
0
 public Chunk(Point id, bool dontLoad = false)
 {
     ChunkspacePosition = id.ToVector2();
     Position           = ChunkspacePosition * new Vector2(ChunkWidth, ChunkHeight);
     if (!dontLoad)
     {
         Dimension.LoadChunk(this);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Builds the flag inside the quarter.
        /// </summary>
        private void BuildFlag()
        {
            Microsoft.Xna.Framework.Point square = GetRandomSquare(m => m == MapFillType.Road);
            flagPoint = square;
            Model          flagModel = owner.Content.FlagModel;
            Vector3        flagSize  = flagModel.GetSize(game.Drawer.WorldTransformMatrix);
            PositionInTown pos       = new PositionInTown(this, ((square.ToVector2() + new Vector2(0.5f, 0.5f)) * SquareWidth) - (flagSize.XZToVector2() * 0.5f));

            flag = new Flag(game, flagModel, pos, 0, game.Drawer.WorldTransformMatrix);
            solidObjects.AddLast(flag);
        }
 public ContainmentType Contains(Point point)
 {
     return Contains(point.ToVector2());
 }
        private void MouseText_DrawBuffString(ref int X, ref int Y, int buffNameHeight)
        {
            Microsoft.Xna.Framework.Point p = new Microsoft.Xna.Framework.Point(X, Y);
            int            num    = 220;
            int            num2   = -1;
            float          num3   = 1f / Main.UIScale;
            List <Vector2> list   = new List <Vector2>();
            Vector2        vector = Main.fontMouseText.MeasureString(Main.buffString);

            list.Add(vector);
            int num4 = (int)((float)(Main.screenHeight - 250) * num3) / 20;

            if (num4 < 1)
            {
                num4 = 1;
            }
            if (Main.bannerMouseOver)
            {
                int num5 = 0;
                for (int i = 0; i < NPCLoader.NPCCount; i++)
                {
                    if (Item.BannerToNPC(i) != 0 && Main.player[Main.myPlayer].NPCBannerBuff[i])
                    {
                        num5++;
                        string  npcnameValue = Lang.GetNPCNameValue(Item.BannerToNPC(i));
                        Vector2 vector2      = Main.fontMouseText.MeasureString(npcnameValue);
                        int     num6         = X;
                        int     num7         = Y + (int)vector2.Y + num5 * 20 + 10;
                        int     num8         = 0;
                        int     num9         = (num5 - 1) / num4;
                        for (int j = 0; j < num9; j++)
                        {
                            num8++;
                            num6 += num;
                            num7 -= num4 * 20;
                        }
                        if ((float)num6 + vector2.X > (float)Main.screenWidth * num3 && num2 == -1)
                        {
                            num2 = num5;
                        }
                        list.Add(new Vector2((float)(num6 - num * num8), (float)num7) + vector2 - p.ToVector2());
                    }
                }
            }
            BuffLoader.CustomBuffTipSize(Main.buffString, list);
            Vector2 zero = Vector2.Zero;

            foreach (Vector2 vector3 in list)
            {
                if (zero.X < vector3.X)
                {
                    zero.X = vector3.X;
                }
                if (zero.Y < vector3.Y)
                {
                    zero.Y = vector3.Y;
                }
            }
            if ((float)X + zero.X + 24f > (float)Main.screenWidth * num3)
            {
                X = (int)((float)Main.screenWidth * num3 - zero.X - 24f);
            }
            if ((float)Y + zero.Y + 4f > (float)Main.screenHeight * num3)
            {
                Y = (int)((float)Main.screenHeight * num3 - zero.Y - 4f);
            }
            if (num2 != -1)
            {
                num2--;
            }
            for (int k = 0; k < 5; k++)
            {
                int num10 = X;
                int num11 = Y + buffNameHeight;
                Microsoft.Xna.Framework.Color black = Microsoft.Xna.Framework.Color.Black;
                if (k == 0)
                {
                    num10 -= 2;
                }
                else if (k == 1)
                {
                    num10 += 2;
                }
                else if (k == 2)
                {
                    num11 -= 2;
                }
                else if (k == 3)
                {
                    num11 += 2;
                }
                else
                {
                    black = new Microsoft.Xna.Framework.Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor);
                }
                DynamicSpriteFontExtensionMethods.DrawString(Main.spriteBatch, Main.fontMouseText, Main.buffString, new Vector2((float)num10, (float)num11), black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
            }
            if (Main.bannerMouseOver)
            {
                int num12 = 0;
                for (int l = 0; l < NPCLoader.NPCCount; l++)
                {
                    if (Item.BannerToNPC(l) != 0 && Main.player[Main.myPlayer].NPCBannerBuff[l])
                    {
                        num12++;
                        bool flag = false;
                        for (int m = 0; m < 5; m++)
                        {
                            int num13 = X;
                            int num14 = Y + (int)vector.Y + num12 * 20 + 10;
                            int num15 = (num12 - 1) / num4;
                            num13 += num * num15;
                            num14 -= num4 * 20 * num15;
                            string text = Lang.GetNPCNameValue(Item.BannerToNPC(l));
                            if (num2 == num12)
                            {
                                text = Language.GetTextValue("UI.Ellipsis");
                                flag = true;
                            }
                            Microsoft.Xna.Framework.Color black2 = Microsoft.Xna.Framework.Color.Black;
                            if (m == 0)
                            {
                                num13 -= 2;
                            }
                            else if (m == 1)
                            {
                                num13 += 2;
                            }
                            else if (m == 2)
                            {
                                num14 -= 2;
                            }
                            else if (m == 3)
                            {
                                num14 += 2;
                            }
                            else
                            {
                                float num16 = (float)Main.mouseTextColor / 255f;
                                black2 = new Microsoft.Xna.Framework.Color((int)((byte)(80f * num16)), (int)((byte)(255f * num16)), (int)((byte)(120f * num16)), (int)Main.mouseTextColor);
                            }
                            DynamicSpriteFontExtensionMethods.DrawString(Main.spriteBatch, Main.fontMouseText, text, new Vector2((float)num13, (float)num14), black2, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                        }
                        if (flag)
                        {
                            return;
                        }
                    }
                }
            }
            BuffLoader.DrawCustomBuffTip(Main.buffString, Main.spriteBatch, X, Y + (int)Main.fontMouseText.MeasureString(Main.buffString).Y);
        }
Beispiel #6
0
 public Vector2 ChunkToWorld(Point position)
 {
     return(position.ToVector2() + Position);
 }
Beispiel #7
0
 public Vector2 MousePick(Point mousePos)
 {
     Vector2 mouseVector = mousePos.ToVector2();
     Matrix reverseCamera = Matrix.Invert(transformation);
     Vector2 worldPos;
     Vector2.Transform(ref mouseVector, ref reverseCamera, out worldPos);
     return worldPos;
 }
Beispiel #8
0
 public static Point Transform(this Point value, Matrix matrix)
 {
     return(value.ToVector2().Transform(matrix).ToPoint());
 }
Beispiel #9
0
 /// <summary>
 /// Obtém a área de um triângulo onde a, b e c são as coordenadas do triângulo.
 /// </summary>
 public static float FindArea(Point a, Point b, Point c)
 {
     return(FindArea(a.ToVector2(), b.ToVector2(), c.ToVector2()));
 }
Beispiel #10
0
 /// <summary>
 /// Cria uma novo objeto Triangle.
 /// </summary>
 /// <param name="a">Coordenadas A.</param>
 /// <param name="b">Coordenadas B.</param>
 /// <param name="c">Coordenadas C.</param>
 public Triangle(Point a, Point b, Point c)
 {
     A = a.ToVector2();
     B = b.ToVector2();
     C = c.ToVector2();
 }
Beispiel #11
0
        /// <summary>
        /// Generates a List of randomly sized and placed Rooms that do not overlap.
        /// </summary>
        /// <returns></returns>
        private List <Room> GenerateRooms()
        {
            //For every possible room size multiply the area by the likelihood of their inclusion and add it to the total.
            double averageTotalArea = 0;

            for (int x = minDim; x <= maxDim; x++)
            {
                for (int y = minDim; y <= maxDim; y++)
                {
                    averageTotalArea += GaussianDistribution(new Vector2(x, y)) * x * y;
                }
            }

            double multiplier = 100 * CircleArea / averageTotalArea;

            //Make a list in which the possible room sizes occur as often as specified by the Gaussian distribution.
            List <Room> allRooms = new List <Room>();

            for (int x = minDim; x <= maxDim; x++)
            {
                for (int y = minDim; y <= maxDim; y++)
                {
                    XNAPoint p = new XNAPoint(x, y);
                    double   gaussianDistribution = GaussianDistribution(p.ToVector2());
                    int      roomAmount           = (int)(multiplier * gaussianDistribution);
                    for (int i = 0; i < roomAmount; i++)
                    {
                        allRooms.Add(new Room(new Vector2(), p));
                    }
                }
            }

            //Select the rooms that are going to be used, by randomly selecting from the list until the target surface area is reached.
            List <Room> roomSelection = new List <Room>();
            int         totalRoomArea = 0;

            while (totalRoomArea < TargetSurfaceArea)
            {
                int     randomIndex   = Random.Next(allRooms.Count);
                Room    toAdd         = allRooms[randomIndex].Clone() as Room;
                Vector2 pointInCircle = GetRandomPointInCircle();
                toAdd.Location = pointInCircle - toAdd.Size.ToVector2() / 2;
                roomSelection.Add(toAdd);

                totalRoomArea += toAdd.Size.X * toAdd.Size.Y;
            }

            //A simple physics simulation that pushes rooms apart.
            int      collisions = int.MaxValue;
            XNAPoint buffer     = new XNAPoint(2, 2);

            while (collisions > 0)
            {
                collisions = 0;
                for (int i = 0; i < roomSelection.Count; i++)
                {
                    Room      room1 = roomSelection[i];
                    Rectangle r1    = new Rectangle(room1.BoundingBox.Location + buffer, room1.BoundingBox.Size + buffer + buffer);
                    for (int j = i + 1; j < roomSelection.Count; j++)
                    {
                        Room      room2 = roomSelection[j];
                        Rectangle r2    = new Rectangle(room2.BoundingBox.Location + buffer, room2.BoundingBox.Size + buffer + buffer);
                        if (room1 != room2 && r1.Intersects(r2))
                        {
                            Rectangle intersection = Rectangle.Intersect(r1, r2);
                            room1.Location += new Vector2((float)Random.NextDouble() / 10) + (r1.Center.ToVector2() - intersection.Center.ToVector2()) / 8;
                            room2.Location += new Vector2((float)Random.NextDouble() / 10) + (r2.Center.ToVector2() - intersection.Center.ToVector2()) / 8;
                            collisions++;
                        }
                    }
                }
            }

            //Get the lowest coordinates so we can adjust and bring everything into the positive.
            float lowestX = float.MaxValue;
            float lowestY = float.MaxValue;

            foreach (Room r in roomSelection)
            {
                if (r.Location.X < lowestX)
                {
                    lowestX = r.Location.X;
                }
                if (r.Location.Y < lowestY)
                {
                    lowestY = r.Location.Y;
                }
            }
            foreach (Room r in roomSelection)
            {
                r.Location -= new Vector2(lowestX - 1, lowestY - 2);
            }

            return(roomSelection);
        }