當前位置: 首頁>>代碼示例>>C#>>正文


C# Player.TeleportationPotion方法代碼示例

本文整理匯總了C#中Terraria.Player.TeleportationPotion方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.TeleportationPotion方法的具體用法?C# Player.TeleportationPotion怎麽用?C# Player.TeleportationPotion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Terraria.Player的用法示例。


在下文中一共展示了Player.TeleportationPotion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPlayerPreUpdate

        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);
                    }
                }
            }
        }
開發者ID:Reuged,項目名稱:TerrariaPatcher,代碼行數:100,代碼來源:EnhancedCellPhone.cs


注:本文中的Terraria.Player.TeleportationPotion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。