Teleport() публичный Метод

public Teleport ( Vector2 newPos, int Style, int extraInfo ) : void
newPos Vector2
Style int
extraInfo int
Результат void
Пример #1
0
        public void OnPlayerPreUpdate(Player player)
        {
            if (player.whoAmI != Main.myPlayer) return;

            if (player.inventory[player.selectedItem].type == ItemID.CellPhone)
            {
                if (Main.mouseItem.type == ItemID.CellPhone) return; // don't allow it to be on your cursor

                if (Main.mouseLeft && Main.mouseLeftRelease)
                {
                    if (mode == Mode.Home) return;

                    player.mouseInterface = true;
                    Main.mouseLeftRelease = false;
                    if (mode == Mode.LeftOcean)
                    {
                        // left ocean
                        player.Teleport(new Vector2(200 * 16, (float)(Main.worldSurface / 2f) * 16f), 3);
                        if (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 3].active())
                        {
                            while (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y += 16f;
                            }
                        }
                        else
                        {
                            while (Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y -= 16f;
                            }
                        }
                        player.fallStart = (int)(player.position.Y / 16f);
                        if (Main.netMode == 1) NetMessage.SendTileSquare(player.whoAmI, 200, (int)Main.worldSurface / 2, 10);
                    }
                    else if (mode == Mode.RightOcean)
                    {
                        // right ocean
                        player.Teleport(new Vector2((Main.maxTilesX - 200) * 16, (float)(Main.worldSurface / 2f) * 16f), 3);
                        if (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 3].active())
                        {
                            while (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y += 16f;
                            }
                        }
                        else
                        {
                            while (Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y -= 16f;
                            }
                        }
                        player.fallStart = (int)(player.position.Y / 16f);
                        if (Main.netMode == 1) NetMessage.SendTileSquare(player.whoAmI, Main.maxTilesX - 200, (int)Main.worldSurface / 2, 10);
                    }
                    else if (mode == Mode.Hell)
                    {
                        // hell
                        player.Teleport(new Vector2((Main.maxTilesX / 2) * 16, (float)(Main.maxTilesY - 180) * 16f), 3);
                        if (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 3].active())
                        {
                            while (!Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y += 16f;
                                if ((int)(player.position.Y / 16f) > Main.maxTilesY)
                                {
                                    player.position.Y = (float)(Main.maxTilesY * 16) - 130f;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            while (Main.tile[(int)(player.position.X / 16f), (int)(player.position.Y / 16f) + 4].active())
                            {
                                player.position.Y -= 16f;
                            }
                        }
                        player.fallStart = (int)(player.position.Y / 16f);
                        if (Main.netMode == 1) NetMessage.SendTileSquare(player.whoAmI, Main.maxTilesX / 2, (int)Main.maxTilesY - 180, 10);
                    }
                    else if (mode == Mode.Random)
                    {
                        if (Main.netMode == 0)
                        {
                            player.TeleportationPotion();
                        }
                        else if (Main.netMode == 1 && player.whoAmI == Main.myPlayer)
                        {
                            NetMessage.SendData(73, -1, -1, "", 0, 0f, 0f, 0f, 0);
                        }
                    }
                    for (int num91 = 0; num91 < 70; num91++)
                    {
                        Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f);
                    }
                }
            }
        }