示例#1
0
        public static void Position(CPos pos, bool ignoreLock = false, bool tinyMove = false)
        {
            if (!ignoreLock && Locked || LookAt == pos)
            {
                return;
            }

            var oldLookAt = LookAt;

            LookAt = pos;

            calculatePosition();
            updateView();

            WorldRenderer.CheckVisibility(oldLookAt, LookAt, tinyMove);
        }
示例#2
0
        public static void Move(CPos add, bool ignoreLock = false)
        {
            if (!ignoreLock && Locked || add == CPos.Zero)
            {
                return;
            }

            var oldLookAt = LookAt;

            LookAt = new CPos(LookAt.X + (int)(Settings.ScrollSpeed * 20 * add.X), LookAt.Y + (int)(Settings.ScrollSpeed * 20 * add.Y), 0);

            if (bounds != CPos.Zero)
            {
                if (LookAt.X < -512)
                {
                    LookAt = new CPos(-512, LookAt.Y, 0);
                }

                if (LookAt.Y < -512)
                {
                    LookAt = new CPos(LookAt.X, -512, 0);
                }

                if (LookAt.X > bounds.X + 512)
                {
                    LookAt = new CPos(bounds.X + 512, LookAt.Y, 0);
                }

                if (LookAt.Y > bounds.Y + 512)
                {
                    LookAt = new CPos(LookAt.X, bounds.Y + 512, 0);
                }
            }

            calculatePosition();
            updateView();

            WorldRenderer.CheckVisibility(oldLookAt, LookAt);
        }
示例#3
0
        public static void Zoom(float add, bool ignoreLock = false)
        {
            if (!ignoreLock && Locked || add == 0)
            {
                return;
            }

            var oldZoom = CurrentZoom;

            CurrentZoom += add;
            if (CurrentZoom < DefaultZoom)
            {
                CurrentZoom = DefaultZoom;
            }
            else if (CurrentZoom > MaxZoom)
            {
                CurrentZoom = MaxZoom;
            }

            calculateScale();
            updateView();

            WorldRenderer.CheckVisibility(oldZoom, CurrentZoom);
        }
示例#4
0
        public void RevealShroudCircular(World world, byte team, CPos position, int height, int radius, bool ignoreLock = false)
        {
            if (RevealAll)
            {
                return;
            }

            if (!UsedTeams.Contains(team))
            {
                initShroudLayer(team);
            }

            var isPlayerTeam = team == Actor.PlayerTeam;

            var shroudPos = (position * new CPos(2, 2, 0)).ToMPos();

            var radiusSquared = radius * radius;

            var triangles = getTriangles(world, position, height, shroudPos, radius);

            for (int x = shroudPos.X - radius; x < shroudPos.X + radius; x++)
            {
                if (x >= 0 && x < Bounds.X)
                {
                    var dx = x - shroudPos.X;
                    dx *= dx;

                    for (int y = shroudPos.Y - radius; y < shroudPos.Y + radius; y++)
                    {
                        if (y >= 0 && y < Bounds.Y)
                        {
                            var dy = y - shroudPos.Y;
                            dy *= dy;

                            if (shroudRevealed[team][x, y])
                            {
                                continue;
                            }

                            if (dx + dy > radiusSquared)
                            {
                                continue;
                            }

                            bool isInTriangle = false;
                            var  p            = new CPos(x * 512 - 256, y * 512 - 256, 0);
                            foreach (var triangle in triangles)
                            {
                                if (triangle.IsInTriangle(p))
                                {
                                    isInTriangle = true;
                                    break;
                                }
                            }

                            var result = !isInTriangle;

                            shroudRevealed[team][x, y] = result;

                            if (isPlayerTeam)
                            {
                                changeState(x, y, result);
                            }
                        }
                    }
                }
            }

            // Camera automatically updates shroud, so we don't want to do that if we move anyways
            if (!Camera.LockedToPlayer || ignoreLock)
            {
                WorldRenderer.CheckVisibility(Camera.LookAt, Camera.DefaultZoom);
            }
        }