Ejemplo n.º 1
0
        private void DrawFullMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  modworld       = this.GetModWorld <WormholesWorld>();
            WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer <WormholesPlayer>(this);

            if (!this.Config.DisableNaturalWormholes)
            {
                if (modworld.Wormholes != null)
                {
                    for (int i = 0; i < modworld.Wormholes.Links.Count; i++)
                    {
                        WormholeLink link = modworld.Wormholes.Links[i];
                        if (link == null)
                        {
                            break;
                        }

                        this.UI.DrawFullscreenMap(link, sb);
                    }
                }
            }

            if (curr_modplayer.MyPortal != null)
            {
                this.UI.DrawFullscreenMap(curr_modplayer.MyPortal, sb);
            }
        }
Ejemplo n.º 2
0
        private void DrawFullMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  myworld  = ModContent.GetInstance <WormholesWorld>();
            WormholesPlayer myplayer = Main.LocalPlayer.GetModPlayer <WormholesPlayer>();

            if (!WormholesConfig.Instance.DisableNaturalWormholes)
            {
                if (myworld.Wormholes != null)
                {
                    for (int i = 0; i < myworld.Wormholes.Links.Count; i++)
                    {
                        WormholeLink link = myworld.Wormholes.Links[i];
                        if (link == null)
                        {
                            break;
                        }

                        this.UI.DrawFullscreenMap(link, sb);
                    }
                }
            }

            if (myplayer.MyPortal != null)
            {
                this.UI.DrawFullscreenMap(myplayer.MyPortal, sb);
            }
        }
Ejemplo n.º 3
0
        ////////////////

        public WormholePortal(Vector2 worldPos, Color color)
        {
            (int minX, int maxX, int minY, int maxY)bounds = WormholesWorld.GetTileBoundsForWormholes();

            this.IsMisplaced = (worldPos.X / 16f) < 64f || (worldPos.X / 16f) > bounds.maxX ||
                               (worldPos.Y / 16f) < Main.worldSurface || (worldPos.Y / 16f) > bounds.maxY;

            if (Main.maxTilesX > 160)
            {
                worldPos.X = MathHelper.Clamp(worldPos.X, 160, (Main.maxTilesX - 10) * 16);
            }
            else
            {
                worldPos.X = MathHelper.Clamp(worldPos.X, 0, Main.maxTilesX * 16);
            }
            if (Main.maxTilesY > 160)
            {
                worldPos.Y = MathHelper.Clamp(worldPos.Y, 160, (Main.maxTilesY - 10) * 16);
            }
            else
            {
                worldPos.Y = MathHelper.Clamp(worldPos.Y, 0, Main.maxTilesY * 16);
            }
//DebugHelpers.Log( "wall of "+color.ToString()+": "+Main.tile[(int)(pos.X/16f)+2, (int)(pos.Y/16f)+4].wall );

            this.Pos       = worldPos;
            this.BaseColor = color;

            // Clients and single only
            if (Main.netMode != 2)
            {
                this.Rect     = new Rectangle((int)worldPos.X, (int)worldPos.Y, WormholePortal.Width, WormholePortal.Height);
                this.Animator = new SpriteAnimator(1, WormholePortal.FrameCount, WormholePortal.Tex, color);
            }
        }
Ejemplo n.º 4
0
        ////////////////

        public override void PreUpdate()
        {
            if (Main.netMode == 2)
            {
                return;
            }                                               // Not server

            var            mymod    = (WormholesMod)this.mod;
            WormholesWorld modworld = mymod.GetModWorld <WormholesWorld>();

            if (modworld.Wormholes == null)
            {
                return;
            }

            modworld.Wormholes.RunAll(this.player);
        }
Ejemplo n.º 5
0
        ////////////////

        private void DrawMiniMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  modworld       = this.GetModWorld <WormholesWorld>();
            WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer <WormholesPlayer>(this);

            if (!this.Config.Data.DisableNaturalWormholes)
            {
                if (modworld.Wormholes != null)
                {
                    for (int i = 0; i < modworld.Wormholes.Links.Count; i++)
                    {
                        WormholeLink link = modworld.Wormholes.Links[i];
                        if (link == null)
                        {
                            break;
                        }

                        if (Main.mapStyle == 1)
                        {
                            this.UI.DrawMiniMap(this.Context, link, sb);
                        }
                        else
                        {
                            this.UI.DrawOverlayMap(this.Context, link, sb);
                        }
                    }
                }
            }

            if (curr_modplayer.MyPortal != null)
            {
                if (Main.mapStyle == 1)
                {
                    this.UI.DrawMiniMap(this.Context, curr_modplayer.MyPortal, sb);
                }
                else
                {
                    this.UI.DrawOverlayMap(this.Context, curr_modplayer.MyPortal, sb);
                }
            }
        }
Ejemplo n.º 6
0
        /////////////////

        private Vector2 GetRandomClearMapPos()
        {
            Vector2 randPos;
            int     worldX, worldY;
            bool    found = false, isEmpty = false;
            int     minWldDistSqr = WormholesConfig.Instance.MinimumTileDistanceBetweenWormholes * 16;

            minWldDistSqr *= minWldDistSqr;

            (int minX, int maxX, int minY, int maxY)bounds = WormholesWorld.GetTileBoundsForWormholes();

            do
            {
                found = true;

                do
                {
                    worldX = Main.rand.Next(bounds.minX, bounds.maxX);
                    worldY = Main.rand.Next(bounds.minY, bounds.maxY);

                    isEmpty = true;
                    for (int i = worldX; i < worldX + 6; i++)
                    {
                        for (int j = worldY; j < worldY + 8; j++)
                        {
                            Tile tile = Framing.GetTileSafely(i, j);

                            bool _;
                            isEmpty = !TileHelpers.IsSolid(tile, true, true) && !tile.lava() && !TileWallGroupIdentityHelpers.IsDungeon(tile, out _);
                            if (!isEmpty)
                            {
                                break;
                            }
                        }
                        if (!isEmpty)
                        {
                            break;
                        }
                    }
                } while(!isEmpty);
                //} while( Collision.SolidCollision( new Vector2(world_x*16f, world_y*16f), WormholePortal.Width, WormholePortal.Height ) );

                randPos = new Vector2(worldX * 16f, worldY * 16f);

                // Not too close to other portals?
                for (int i = 0; i < this.Links.Count; i++)
                {
                    var link = this.Links[i];

                    float distSqr = Vector2.DistanceSquared(link.LeftPortal.Pos, randPos);
                    if (distSqr < minWldDistSqr)
                    {
                        found = false;
                        break;
                    }

                    distSqr = Vector2.DistanceSquared(link.RightPortal.Pos, randPos);
                    if (distSqr < minWldDistSqr)
                    {
                        found = false;
                        break;
                    }
                }
            } while(!found);

            return(randPos);
        }