Exemplo n.º 1
0
        public static bool IsVisible(MPos position)
        {
            if (map == null)
            {
                return(false);
            }

            if (shroud.RevealAll)
            {
                return(true);
            }

            if (!position.InRange(lastCameraPosition, lastCameraPosition + lastCameraZoom))
            {
                return(false);
            }

            return(visible[position.X, position.Y]);
        }
Exemplo n.º 2
0
        public static bool IsVisibleIgnoringBounds(MPos position)
        {
            if (map == null)
            {
                return(false);
            }

            if (shroud.RevealAll)
            {
                return(true);
            }

            if (!position.InRange(lastCameraPosition, lastCameraPosition + lastCameraZoom))
            {
                return(false);
            }

            if (position.X < 0)
            {
                position = new MPos(0, position.Y);
            }
            else if (position.X >= mapBounds.X)
            {
                position = new MPos(mapBounds.X - 1, position.Y);
            }

            if (position.Y < 0)
            {
                position = new MPos(position.X, 0);
            }
            else if (position.Y >= mapBounds.Y)
            {
                position = new MPos(position.X, mapBounds.Y - 1);
            }

            return(visible[position.X, position.Y]);
        }
Exemplo n.º 3
0
        void generateSingle(MPos start, MPos end)
        {
            var currentPosition = start;

            while (currentPosition != end)
            {
                var angle = end.AngleTo(currentPosition);
                var optX  = MathF.Cos(angle);
                var x     = (Math.Abs(optX) > 0.25f ? 1 : 0) * Math.Sign(optX);

                var optY = MathF.Sin(angle);
                var y    = (Math.Abs(optY) > 0.25f ? 1 : 0) * Math.Sign(optY);

                // Maximal abeviation of +-45°
                if (info.Curvy)
                {
                    MPos a1 = MPos.Zero;
                    MPos a2 = MPos.Zero;
                    // Get the two other possibilities near the best tone
                    if (x != 0 && y != 0)
                    {
                        a1 = new MPos(x, 0) + currentPosition;
                        a2 = new MPos(0, y) + currentPosition;
                    }
                    if (x == 0)
                    {
                        a1 = new MPos(1, y) + currentPosition;
                        a2 = new MPos(-1, y) + currentPosition;
                    }
                    if (y == 0)
                    {
                        a1 = new MPos(x, 1) + currentPosition;
                        a2 = new MPos(x, -1) + currentPosition;
                    }
                    MPos preferred = new MPos(x, y) + currentPosition;

                    // If out of bounds, make the value high af so the field can't be taken
                    var val1 = preferred.InRange(MPos.Zero, Bounds) ? noise[preferred.X, preferred.Y] : 10f;
                    var val2 = a1.InRange(MPos.Zero, Bounds) ? noise[a1.X, a1.Y] : 10f;
                    var val3 = a2.InRange(MPos.Zero, Bounds) ? noise[a2.X, a2.Y] : 10f;

                    if (preferred != end)
                    {
                        if (val2 < val3 && val2 < val1 || a1 == end)
                        {
                            preferred = a1;
                        }
                        else if (val3 < val2 && val3 < val1 || a2 == end)
                        {
                            preferred = a2;
                        }
                    }

                    currentPosition = preferred;
                }
                else
                {
                    currentPosition += new MPos(x, y);
                }

                points.Add(currentPosition);
            }
        }