当前位置: 首页>>代码示例>>C#>>正文


C# NPC.SetDefaults方法代码示例

本文整理汇总了C#中Terraria.NPC.SetDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# NPC.SetDefaults方法的具体用法?C# NPC.SetDefaults怎么用?C# NPC.SetDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Terraria.NPC的用法示例。


在下文中一共展示了NPC.SetDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChooseNPC

 public static void ChooseNPC()
 {
     var npc = new NPC();
     Random r = new Random();
     int type = r.Next(ApocalypseMonsters.Monsters.Count);
     npc.SetDefaults(ApocalypseMonsters.Monsters[type]);
     CurMonster = npc;
 }
开发者ID:RogerPaladin,项目名称:TwitchysPlugins,代码行数:8,代码来源:Apocalypse.cs

示例2: DedServ

        public void DedServ()
        {
            ServerApi.Hooks.InvokeGameInitialize();
            string str;
            Main.rand = new Random();
            Console.Title = string.Concat("Terraria Server ", Main.versionNumber2);
            Main.dedServ = true;
            Main.showSplash = false;
            if (Main.autoGen)
            {
                Main.ActiveWorldFileData = new WorldFileData();
                Main.ActiveWorldFileData.Path = Main.WorldPathClassic;
            }
            this.Initialize();
            Lang.setLang(false);
            for (int i = 0; i < 540; i++)
            {
                NPC nPC = new NPC();
                nPC.SetDefaults(i, -1f);
                Main.npcName[i] = nPC.name;
            }

            if (Console.IsInputRedirected == true && string.IsNullOrEmpty(Main.WorldPathClassic) == true && !Main.autoGen)
            {
                throw new Exception("When running in the background, the world must be specified with -world <path>");
            }

            while (string.IsNullOrEmpty(Main.worldPathName))
            {
                bool flag = true;
                while (flag)
                {
                    Main.LoadWorlds();
                    Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                    Console.WriteLine("");
                    for (int j = 0; j < Main.WorldList.Count; j++)
                    {
                        object[] name = new object[]
                        {
                            j + 1,
                            '\t',
                            '\t', Main.WorldList[j].Name
                        };
                        Console.WriteLine("{0,-4}{1,-22}{2}, {3}, {4,-6}{5}",
                            j + 1,
                            Main.WorldList[j].Name,
                            Main.WorldList[j].IsHardMode ? "hard" : "norm",
                            Main.WorldList[j].HasCrimson ? "crim" : "corr",
                            Main.WorldList[j].IsExpertMode ? "exp" : "norm",
                            String.Format("Last used: {0}",
                                File.GetLastWriteTime(Main.WorldList[j].Path).ToString("g")));
                    }
                    Console.WriteLine();
                    Console.WriteLine("n           \tNew World");
                    Console.WriteLine("d   <number>\tDelete World");
                    Console.WriteLine("");
                    Console.Write("Choose World: ");
                    string str2 = Console.ReadLine() ?? "";
                    try
                    {
                        Console.Clear();
                    }
                    catch (Exception ex)
                    {
            #if DEBUG
                        Console.WriteLine(ex);
                        System.Diagnostics.Debugger.Break();

            #endif
                    }
                    if (str2.Length >= 2 && str2.Substring(0, 2).ToLower() == "d ")
                    {
                        try
                        {
                            int num = Convert.ToInt32(str2.Substring(2)) - 1;
                            if (num < Main.WorldList.Count)
                            {
                                Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                                Console.WriteLine("");
                                Console.WriteLine(string.Concat("Really delete ", Main.WorldList[num].Name, "?"));
                                Console.Write("(y/n): ");
                                if (Console.ReadLine().ToLower() == "y")
                                {
                                    Main.EraseWorld(num);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }
                        try
                        {
                            Console.Clear();
                        }
                        catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:101,代码来源:Main.cs

示例3: OnSetDefaults

        internal static void OnSetDefaults(NPC n, int type, float scaleOverride)
        {
            NpcBHandler h = null;

            n.SetDefaults(0, scaleOverride);

            if (DefFromType.ContainsKey(type))
            {
                var d = DefFromType[type];

                n.type = n.netID = type;
                n.width = n.height = 16;

                CopyDefToNpc(n, d);

                if (scaleOverride > -1f)
                    n.scale = scaleOverride;

                h = new NpcBHandler();
                if (d.CreateBehaviour != null)
                {
                    var b = d.CreateBehaviour();

                    if (b != null)
                        h.behaviours.Add(b);
                }

                n.BHandler = h;
            }

            //TODO: add global hooks here (and check for null)

            if (h != null)
            {
                h.Create();
                n.BHandler = h;

                foreach (var b in h.Behaviours)
                    b.Entity = n;

                h.OnInit();
            }
        }
开发者ID:chatrat12,项目名称:Prism,代码行数:43,代码来源:NpcDefHandler.cs

示例4: HandleSpawnBoss

        private static bool HandleSpawnBoss(GetDataHandlerArgs args)
        {
            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                return true;
            }

            var spawnboss = false;
            var invasion = false;
            var plr = args.Data.ReadInt16();
            var Type = args.Data.ReadInt16();
            NPC npc = new NPC();
            npc.SetDefaults(Type);
            spawnboss = npc.boss;
            if (!spawnboss)
            {
                switch (Type)
                {
                    case -1:
                    case -2:
                    case -3:
                    case -4:
                    case -5:
                    case -6:
                    case -7:
                        invasion = true;
                        break;
                    case 4:
                    case 13:
                    case 50:
                    case 126:
                    case 125:
                    case 134:
                    case 127:
                    case 128:
                    case 131:
                    case 129:
                    case 130:
                    case 222:
                    case 245:
                    case 266:
                    case 370:
                    case 75:
                    case 398:
                    case 439:
                    case 493:
                    case 507:
                    case 422:
                    case 517:
                        spawnboss = true;
                        break;
                }
            }
            if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss))
            {
                args.Player.SendErrorMessage("You don't have permission to summon a boss.");
                return true;
            }
            if (invasion && !args.Player.Group.HasPermission(Permissions.startinvasion))
            {
                args.Player.SendErrorMessage("You don't have permission to start an invasion.");
                return true;
            }
            if (!spawnboss && !invasion)
                return true;

            if (plr != args.Player.Index)
                return true;

            string boss;
            switch (Type)
            {
                case -5:
                    boss = "a frost moon";
                    break;
                case -4:
                    boss = "a pumpkin moon";
                    break;
                case -3:
                    boss = "the Pirates";
                    break;
                case -2:
                    boss = "the Snow Legion";
                    break;
                case -1:
                    boss = "a Goblin Invasion";
                    break;
                default:
                    boss = String.Format("the {0}", npc.name);
                    break;
            }
            if (TShock.Config.AnonymousBossInvasions)
                TShock.Utils.SendLogs(string.Format("{0} summoned {1}!", args.Player.Name, boss), Color.PaleVioletRed, args.Player);
            else
                TShock.Utils.Broadcast(String.Format("{0} summoned {1}!", args.Player.Name, boss), 175, 75, 255);
            return false;
        }
开发者ID:CXUtk,项目名称:TShock,代码行数:97,代码来源:GetDataHandlers.cs

示例5: SpawnBosses

        private void SpawnBosses(Dictionary<string, int> bosses, ScPlayer sPly)
        {
            var bossList = new List<string>();
            foreach (var pair in bosses)
            {
                var npc = new NPC();
                switch (pair.Key.ToLower())
                {
                    case "*":
                    case "all":
                        int[] npcIds = {4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370};
                        TSPlayer.Server.SetTime(false, 0.0);
                        foreach (var i in npcIds)
                        {
                            npc.SetDefaults(i);
                            TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        }

                        bossList.Add("all bosses (" + pair.Value + ")");
                        break;
                    case "brain":
                    case "brain of cthulhu":
                        npc.SetDefaults(266);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "destroyer":
                        npc.SetDefaults(134);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "duke":
                    case "duke fishron":
                    case "fishron":
                        npc.SetDefaults(370);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "eater":
                    case "eater of worlds":
                        npc.SetDefaults(13);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "eye":
                    case "eye of cthulhu":
                        npc.SetDefaults(4);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "golem":
                        npc.SetDefaults(245);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "king":
                    case "king slime":
                        npc.SetDefaults(50);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "plantera":
                        npc.SetDefaults(262);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "prime":
                    case "skeletron prime":
                        npc.SetDefaults(127);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "queen":
                    case "queen bee":
                        npc.SetDefaults(222);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "skeletron":
                        npc.SetDefaults(35);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "twins":
                        TSPlayer.Server.SetTime(false, 0.0);
                        npc.SetDefaults(125);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        npc.SetDefaults(126);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add("the Twins (" + pair.Value + ")");
                        break;
                    case "wof":
                    case "wall of flesh":
                        if (Main.wof >= 0)
//.........这里部分代码省略.........
开发者ID:Denwey,项目名称:SignCommands,代码行数:101,代码来源:scSign.cs

示例6: DedServ

        public void DedServ()
        {
            rand = new Random();
            if (autoShutdown)
            {
                string lpWindowName = "terraria" + rand.Next(0x7fffffff);
                Console.Title = lpWindowName;
                IntPtr hWnd = FindWindow(null, lpWindowName);
                if (hWnd != IntPtr.Zero)
                {
                    ShowWindow(hWnd, 0);
                }
            }
            else
            {
                Console.Title = "Terraria Server " + versionNumber2;
            }
            dedServ = true;
            showSplash = false;
            this.Initialize();
            for (int i = 0; i < 0x93; i++)
            {
                NPC npc = new NPC();
                npc.SetDefaults(i, -1f);
                npcName[i] = npc.name;
            }
            while ((worldPathName == null) || (worldPathName == ""))
            {
                LoadWorlds();
                bool flag = true;
                while (flag)
                {
                    Console.WriteLine("Terraria Server " + versionNumber2);
                    Console.WriteLine("");
                    for (int j = 0; j < numLoadWorlds; j++)
                    {
                        Console.WriteLine(string.Concat(new object[] { j + 1, '\t', '\t', loadWorld[j] }));
                    }
                    Console.WriteLine(string.Concat(new object[] { "n", '\t', '\t', "New World" }));
                    Console.WriteLine("d <number>" + '\t' + "Delete World");
                    Console.WriteLine("");
                    Console.Write("Choose World: ");
                    string str2 = Console.ReadLine();
                    try
                    {
                        Console.Clear();
                    }
                    catch
                    {
                    }
                    if ((str2.Length >= 2) && (str2.Substring(0, 2).ToLower() == "d "))
                    {
                        try
                        {
                            int index = Convert.ToInt32(str2.Substring(2)) - 1;
                            if (index < numLoadWorlds)
                            {
                                Console.WriteLine("Terraria Server " + versionNumber2);
                                Console.WriteLine("");
                                Console.WriteLine("Really delete " + loadWorld[index] + "?");
                                Console.Write("(y/n): ");
                                if (Console.ReadLine().ToLower() == "y")
                                {
                                    EraseWorld(index);
                                }
                            }
                        }
                        catch
                        {
                        }
                        try
                        {
                            Console.Clear();
                            continue;
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    if ((str2 == "n") || (str2 == "N"))
                    {
                        bool flag2 = true;
                        while (flag2)
                        {
                            Console.WriteLine("Terraria Server " + versionNumber2);
                            Console.WriteLine("");
                            Console.WriteLine("1" + '\t' + "Small");
                            Console.WriteLine("2" + '\t' + "Medium");
                            Console.WriteLine("3" + '\t' + "Large");
                            Console.WriteLine("");
                            Console.Write("Choose size: ");
                            string str4 = Console.ReadLine();
                            try
                            {
                                switch (Convert.ToInt32(str4))
                                {
                                    case 1:
                                        maxTilesX = 0x1068;
                                        maxTilesY = 0x4b0;
//.........这里部分代码省略.........
开发者ID:Heloo88,项目名称:ModTerraria_Heloo,代码行数:101,代码来源:Main.cs

示例7: DedServ

 public void DedServ()
 {
     Main.rand = new Random();
     if (Main.autoShutdown)
     {
         string text = "terraria" + Main.rand.Next(2147483647);
         Console.Title = text;
         IntPtr intPtr = Main.FindWindow(null, text);
         if (intPtr != IntPtr.Zero)
         {
             Main.ShowWindow(intPtr, 0);
         }
     }
     else
     {
         Console.Title = "Terraria Server " + Main.versionNumber2;
     }
     Main.dedServ = true;
     Main.showSplash = false;
     this.Initialize();
     Lang.setLang(false);
     for (int i = 0; i < 301; i++)
     {
         NPC nPC = new NPC();
         nPC.SetDefaults(i, -1f);
         Main.npcName[i] = nPC.name;
     }
     while (Main.worldPathName == null || Main.worldPathName == "")
     {
         Main.LoadWorlds();
         bool flag = true;
         while (flag)
         {
             Console.WriteLine("Terraria Server " + Main.versionNumber2);
             Console.WriteLine("");
             for (int j = 0; j < Main.numLoadWorlds; j++)
             {
                 Console.WriteLine(string.Concat(new object[]
                 {
                     j + 1,
                     '\t',
                     '\t',
                     Main.loadWorld[j]
                 }));
             }
             Console.WriteLine(string.Concat(new object[]
             {
                 "n",
                 '\t',
                 '\t',
                 "New World"
             }));
             Console.WriteLine("d <number>" + '\t' + "Delete World");
             Console.WriteLine("");
             Console.Write("Choose World: ");
             string text2 = Console.ReadLine();
             try
             {
                 Console.Clear();
             }
             catch
             {
             }
             if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
             {
                 try
                 {
                     int num = Convert.ToInt32(text2.Substring(2)) - 1;
                     if (num < Main.numLoadWorlds)
                     {
                         Console.WriteLine("Terraria Server " + Main.versionNumber2);
                         Console.WriteLine("");
                         Console.WriteLine("Really delete " + Main.loadWorld[num] + "?");
                         Console.Write("(y/n): ");
                         string text3 = Console.ReadLine();
                         if (text3.ToLower() == "y")
                         {
                             Main.EraseWorld(num);
                         }
                     }
                 }
                 catch
                 {
                 }
                 try
                 {
                     Console.Clear();
                     continue;
                 }
                 catch
                 {
                     continue;
                 }
             }
             if (text2 == "n" || text2 == "N")
             {
                 bool flag2 = true;
                 while (flag2)
                 {
                     Console.WriteLine("Terraria Server " + Main.versionNumber2);
//.........这里部分代码省略.........
开发者ID:brianmcmichael,项目名称:Terraria-Source-Code,代码行数:101,代码来源:Main.cs

示例8: HandleSpawnBoss

        private static bool HandleSpawnBoss(GetDataHandlerArgs args)
        {
            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                return true;
            }

            var spawnboss = false;
            var invasion = false;
            var plr = args.Data.ReadInt32();
            var Type = args.Data.ReadInt32();
            NPC npc = new NPC();
            npc.SetDefaults(Type);
            spawnboss = npc.boss;
            if (!spawnboss)
            {
                switch (Type)
                {
                    case -1:
                    case -2:
                    case -3:
                    case -4:
                    case -5:
                        invasion = true;
                        break;
                    case 4:
                    case 13:
                    case 35:
                    case 50:
                    case 113:
                    case 125:
                    case 126:
                    case 127:
                    case 128:
                    case 134:
                    case 222:
                    case 245:
                    case 262:
                    case 266:
                        spawnboss = true;
                        break;
                }
            }
            if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss))
            {
                args.Player.SendMessage("You don't have permission to summon a boss.", Color.Red);
                return true;
            }
            if (invasion && !args.Player.Group.HasPermission(Permissions.startinvasion))
            {
                args.Player.SendMessage("You don't have permission to start an invasion.", Color.Red);
                return true;
            }
            if (!spawnboss && !invasion)
                return true;

            if (plr != args.Player.Index)
                return true;

            string boss;
            switch (Type)
            {
                case -5:
                    boss = "a snow invasion";
                    break;
                case -4:
                    boss = "a pumpkin invasion";
                    break;
                case -3:
                    boss = "the pirates";
                    break;
                case -2:
                    boss = "the Snow Legion";
                    break;
                case -1:
                    boss = "a Goblin Invasion";
                    break;
                default:
                    boss = String.Format("the {0}", npc.name);
                    break;
            }

            TShock.Utils.SendLogs(string.Format("{0} summoned {1}.", args.Player.Name, boss), Color.PaleVioletRed, args.Player);
            return false;
        }
开发者ID:CoderCow,项目名称:TShock,代码行数:85,代码来源:GetDataHandlers.cs

示例9: SpawnBoss

        private static void SpawnBoss(CommandArgs args)
        {
            if (args.Parameters.Count < 1 || args.Parameters.Count > 2)
            {
                args.Player.SendErrorMessage("指令错误 使用{0}刷Boss BOSS名 数量 来召唤BOSS", Specifier);
                args.Player.SendErrorMessage("例如{0}刷Boss 克鲁苏之脑 1 表示召唤了1只克鲁苏之脑", Specifier);
                args.Player.SendErrorMessage("BOSS名如下 克鲁苏之脑 机械毁灭者 猪鲨公爵 世界吞噬者 克鲁苏之眼 石头人 史莱姆国王", Specifier);
                args.Player.SendErrorMessage("世纪之花 机械骷髅王 蜂后 骷髅王 魔眼双子 肉山大魔墙 月之领主", Specifier);
                return;
            }

            int amount = 1;
            if (args.Parameters.Count == 2 && (!int.TryParse(args.Parameters[1], out amount) || amount <= 0))
            {
                args.Player.SendErrorMessage("数量错误。");
                return;
            }

            NPC npc = new NPC();
            switch (args.Parameters[0].ToLower())
            {
                case "*":
                case "all":
                case "所有":
                    int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370, 398 };
                    TSPlayer.Server.SetTime(false, 0.0);
                    foreach (int i in npcIds)
                    {
                        npc.SetDefaults(i);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    }
                    TSPlayer.All.SendSuccessMessage("{0} 召唤了所有Boss{1}次。", args.Player.Name, amount);
                    return;
                case "brain":
                case "brain of cthulhu":
                case "克鲁苏之脑":
                    npc.SetDefaults(266);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只克鲁苏之脑", args.Player.Name, amount);
                    return;
                case "destroyer":
                case "机械毁灭者":
                    npc.SetDefaults(134);
                    TSPlayer.Server.SetTime(false, 0.0);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只机械毁灭者", args.Player.Name, amount);
                    return;
                case "duke":
                case "duke fishron":
                case "fishron":
                case "猪鲨公爵":
                case "猪鲨":
                    npc.SetDefaults(370);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只猪鲨公爵", args.Player.Name, amount);
                    return;
                case "eater":
                case "eater of worlds":
                case "世界吞噬者":
                    npc.SetDefaults(13);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只世界吞噬者", args.Player.Name, amount);
                    return;
                case "eye":
                case "eye of cthulhu":
                case "克鲁苏之眼":
                    npc.SetDefaults(4);
                    TSPlayer.Server.SetTime(false, 0.0);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0} 召唤了{1}个克苏鲁之眼。", args.Player.Name, amount);
                    return;
                case "golem":
                case "石头人":
                    npc.SetDefaults(245);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只石头人", args.Player.Name, amount);
                    return;
                case "king":
                case "king slime":
                case "史莱姆国王":
                case "史莱姆王":
                    npc.SetDefaults(50);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只史莱姆国王", args.Player.Name, amount);
                    return;
                case "plantera":
                case "世纪之花":
                    npc.SetDefaults(262);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只世纪之花", args.Player.Name, amount);
                    return;
                case "prime":
                case "skeletron prime":
                case "机械骷髅王":
                    npc.SetDefaults(127);
                    TSPlayer.Server.SetTime(false, 0.0);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
                    TSPlayer.All.SendSuccessMessage("{0}召唤了{1}只机械骷髅王", args.Player.Name, amount);
                    return;
                case "queen":
//.........这里部分代码省略.........
开发者ID:blambin,项目名称:TshockCN,代码行数:101,代码来源:Commands.cs

示例10: SpawnBoss

        public static void SpawnBoss(CommandArgs args)
        {
            if (args.Parameters.Count == 1 && args.Parameters[0] == "list")
            {
                args.Player.SendInfoMessage("Available bosses: {0}", string.Join(", ", bosses));
                return;

            }
            if (args.Parameters.Count < 1 || args.Parameters.Count > 4)
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}spawnboss <boss type> [amount] [XPos] [YPos]", TShock.Config.CommandSpecifier);
                return;
            }
            if (!args.Player.RealPlayer && args.Parameters.Count != 4)
            {
                args.Player.SendErrorMessage("You are required to set coordinates from console! ");
                args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}spawnmob <mob type> [amount] [XPos] [YPos]", TShock.Config.CommandSpecifier);
                return;
            }

            int amount = 1;
            if (args.Parameters.Count >= 2 && (!int.TryParse(args.Parameters[1], out amount) || amount <= 0))
            {
                args.Player.SendErrorMessage("Invalid boss amount!");
                return;
            }
            int x = -1;
            int y = -1;
            if (args.Parameters.Count >= 3 && !int.TryParse(args.Parameters[2], out x))
            {
                args.Player.SendErrorMessage("Invalid X coordinates!");
                return;
            }
            if (args.Parameters.Count == 3)
            {
                args.Player.SendErrorMessage("You must set both X and Y coordinates!");
                return;
            }
            if (args.Parameters.Count == 4)
            {
                if (args.Parameters.Count >= 4 && !int.TryParse(args.Parameters[3], out y))
                {
                    args.Player.SendErrorMessage("Invalid Y coordinates!");
                    return;
                }

                if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
                {
                    args.Player.SendErrorMessage("Given coordinates are invalid!");
                    return;
                }
            }
            int TileX = -1;
            int TileY = -1;
            if (args.Parameters.Count == 4)
            {
                TileX = x;
                TileY = y;
            }
            else
            {
                TileX = args.Player.TileX;
                TileY = args.Player.TileY;
            }

            NPC npc = new NPC();
            switch (args.Parameters[0].ToLower())
            {
                case "*":
                case "all":
                    int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370 };
                    TSPlayer.Server.SetTime(false, 0.0);
                    foreach (int i in npcIds)
                    {
                        npc.SetDefaults(i);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
                    }
                    if (!args.Silent)
                        TSPlayer.All.SendSuccessMessage("{0} has spawned all bosses {1} time(s).", args.Player.Name, amount);
                    else
                        args.Player.SendSuccessMessage("Spawned all bosses {0} time(s).", amount);
                    return;
                case "brain":
                case "brain of cthulhu":
                    npc.SetDefaults(266);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
                   if (!args.Silent)
                        TSPlayer.All.SendSuccessMessage("{0} has spawned the Brain of Cthulhu {1} time(s).", args.Player.Name, amount);
                    else
                        args.Player.SendSuccessMessage("Spawned the Brain of Cthulhu {0} time(s).", amount);
                        return;
                case "destroyer":
                    npc.SetDefaults(134);
                    TSPlayer.Server.SetTime(false, 0.0);
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
                    if (!args.Silent)
                        TSPlayer.All.SendSuccessMessage("{0} has spawned the Destroyer {1} time(s).", args.Player.Name, amount);
                    else
                        args.Player.SendSuccessMessage("Spawned the Destroyer {0} time(s).", amount);
                    return;
//.........这里部分代码省略.........
开发者ID:Tygra,项目名称:SpawnMobXY,代码行数:101,代码来源:Plugin.cs

示例11: GetNpcs

        public IEnumerable<Terraria.NPC> GetNpcs()
        {
            int[] friends = new int[]
            {
                17,
                18,
                19,
                20,
                22,
                54,
                38,
                107,
                108,
                124,
                160,
                178,
                207,
                208,
                209,
                227,
                228,
                229
            };
            foreach (int id in friends)
            {
                var npc = new NPC();
                npc.SetDefaults(id);

                yield return npc;
            }
        }
开发者ID:prototype464,项目名称:Terraria-Map-Editor,代码行数:31,代码来源:TerrariaWrapper.cs

示例12: OpenBossBag


//.........这里部分代码省略.........
     }
     if (type == 3322)
     {
         num14 = 222;
     }
     if (type == 3323)
     {
         num14 = 35;
     }
     if (type == 3324)
     {
         num14 = 113;
     }
     if (type == 3325)
     {
         num14 = 134;
     }
     if (type == 3326)
     {
         num14 = 125;
     }
     if (type == 3327)
     {
         num14 = 127;
     }
     if (type == 3328)
     {
         num14 = 262;
     }
     if (type == 3329)
     {
         num14 = 245;
     }
     if (type == 3330)
     {
         num14 = 370;
     }
     if (type == 3331)
     {
         num14 = 439;
     }
     if (type == 3332)
     {
         num14 = 398;
     }
     if (num14 > 0)
     {
         NPC nPC = new NPC();
         nPC.SetDefaults(num14, -1f);
         float num15 = nPC.value;
         num15 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
         if (Main.rand.Next(5) == 0)
         {
             num15 *= 1f + (float)Main.rand.Next(5, 11) * 0.01f;
         }
         if (Main.rand.Next(10) == 0)
         {
             num15 *= 1f + (float)Main.rand.Next(10, 21) * 0.01f;
         }
         if (Main.rand.Next(15) == 0)
         {
             num15 *= 1f + (float)Main.rand.Next(15, 31) * 0.01f;
         }
         if (Main.rand.Next(20) == 0)
         {
             num15 *= 1f + (float)Main.rand.Next(20, 41) * 0.01f;
         }
         while ((int)num15 > 0)
         {
             if (num15 > 1000000f)
             {
                 int num16 = (int)(num15 / 1000000f);
                 num15 -= (float)(1000000 * num16);
                 this.QuickSpawnItem(74, num16);
             }
             else if (num15 > 10000f)
             {
                 int num17 = (int)(num15 / 10000f);
                 num15 -= (float)(10000 * num17);
                 this.QuickSpawnItem(73, num17);
             }
             else if (num15 > 100f)
             {
                 int num18 = (int)(num15 / 100f);
                 num15 -= (float)(100 * num18);
                 this.QuickSpawnItem(72, num18);
             }
             else
             {
                 int num19 = (int)num15;
                 if (num19 < 1)
                 {
                     num19 = 1;
                 }
                 num15 -= (float)num19;
                 this.QuickSpawnItem(71, num19);
             }
         }
     }
 }
开发者ID:itamargreen,项目名称:ModLoader,代码行数:101,代码来源:Player.cs

示例13: DedServ

 public void DedServ()
 {
     GameHooks.OnInitialize(true);
     Main.rand = new Random();
     if (Main.autoShutdown)
     {
         string text = "terraria" + Main.rand.Next(2147483647);
         Console.Title = text;
         IntPtr intPtr = Main.FindWindow(null, text);
         if (intPtr != IntPtr.Zero)
         {
             Main.ShowWindow(intPtr, 0);
         }
     }
     else
     {
         Console.Title = "Terraria Server " + Main.versionNumber2;
     }
     Main.dedServ = true;
     Main.showSplash = false;
     this.Initialize();
     /*var npcstring = "";
     for (int i = -17; i < Terraria.Main.maxNPCTypes; i++)
     {
         var Npc = new Terraria.NPC();
         Npc.netDefaults(i);
         npcstring += string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\n",
             Npc.type, Npc.netID, Npc.name, Npc.life, Npc.damage, Npc.defense, Npc.knockBackResist, Npc.noGravity, Npc.value,
             Npc.friendly, Npc.noTileCollide, Npc.aiStyle, Npc.scale, Npc.boss, Npc.lavaImmune, Npc.townNPC,
             Npc.height, Npc.width);
     }
     File.WriteAllText("npc.txt", npcstring);
     var itemstring = "";
     for (int i = -24; i < Terraria.Main.maxItemTypes; i++)
     {
         var item = new Terraria.Item();
         item.netDefaults(i);
         itemstring += item.type + "\t" + item.name + "\n";
     }
     File.WriteAllText("item.txt", itemstring);
     var prefixstring = "";
     for (int i = 1; i < 84; i++)
     {
         Item item = new Item();
         item.SetDefaults(0);
         item.prefix = (byte)i;
         prefixstring += i + "\t" + item.AffixName() + "\n";
     }
     File.WriteAllText("prefix.txt", prefixstring);*/
     for (int i = 0; i < 142; i++)
     {
         NPC nPC = new NPC();
         nPC.SetDefaults(i, -1f);
         Main.npcName[i] = nPC.name;
     }
     while (Main.worldPathName == null || Main.worldPathName == "")
     {
         Main.LoadWorlds();
         bool flag = true;
         while (flag)
         {
             Console.WriteLine("Terraria Server " + Main.versionNumber2);
             Console.WriteLine("");
             for (int j = 0; j < Main.numLoadWorlds; j++)
             {
                 Console.WriteLine(string.Concat(new object[]
                                                     {
                                                         j + 1,
                                                         '\t',
                                                         '\t',
                                                         Main.loadWorld[j]
                                                     }));
             }
             Console.WriteLine(string.Concat(new object[]
                                                 {
                                                     "n",
                                                     '\t',
                                                     '\t',
                                                     "New World"
                                                 }));
             Console.WriteLine("d <number>" + '\t' + "Delete World");
             Console.WriteLine("");
             Console.Write("Choose World: ");
             string text2 = Console.ReadLine();
             try
             {
                 Console.Clear();
             }
             catch
             {
             }
             if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
             {
                 try
                 {
                     int num = Convert.ToInt32(text2.Substring(2)) - 1;
                     if (num < Main.numLoadWorlds)
                     {
                         Console.WriteLine("Terraria Server " + Main.versionNumber2);
                         Console.WriteLine("");
//.........这里部分代码省略.........
开发者ID:DaGamesta,项目名称:TerrariaAPI-Server,代码行数:101,代码来源:Main.cs

示例14: ReadV1


//.........这里部分代码省略.........
            }
            #endregion

            #region signs
            for (int i = 0; i < ret.signs.Length; i++)
            {
                if (!bb.ReadBool())
                    continue;

                ret.signs[i] = new Sign()
                {
                    text = PlayerPorter.ReadString(bb),
                    position = new Point(bb.ReadInt(), bb.ReadInt())
                };
            }
            #endregion

            #region town npcs
            while (bb.ReadBool())
            {
                TownNPC n = new TownNPC()
                {
                    occupation = PlayerPorter.ReadString(bb)
                };

                if (ver >= 83)
                    n.name = PlayerPorter.ReadString(bb);

                n.position = new Vector2(bb.ReadFloat(), bb.ReadFloat());
                n.homeless = bb.ReadBool();
                n.homeTile = new Point(bb.ReadInt(), bb.ReadInt());

                NPC npc = new NPC();
                npc.SetDefaults(n.occupation);
                n.type = npc.type;

                ret.townNPCs.Add(n);
            }

            if (ver >= 31 && ver <= 83)
            {
                string
                    merchantName = PlayerPorter.ReadString(bb),
                    nurseName = PlayerPorter.ReadString(bb),
                    armsDealerName = PlayerPorter.ReadString(bb),
                    dryadName = PlayerPorter.ReadString(bb),
                    guideName = PlayerPorter.ReadString(bb),
                    clothierName = PlayerPorter.ReadString(bb),
                    demolitionistName = PlayerPorter.ReadString(bb),
                    goblinName = PlayerPorter.ReadString(bb),
                    wizardName = PlayerPorter.ReadString(bb),

                    mechanicName = String.Empty,
                    truffleName = String.Empty,
                    steampunkerName = String.Empty,
                    dyeTraderName = String.Empty,
                    partyGirlName = String.Empty,
                    cyborgName = String.Empty,
                    painterName = String.Empty,
                    witchDoctorName = String.Empty,
                    pirateName = String.Empty,
                    anglerName = String.Empty;

                if (ver >= 35)
                {
                    mechanicName = PlayerPorter.ReadString(bb);
开发者ID:mugmickey,项目名称:PoroCYon.MCT,代码行数:67,代码来源:WorldPorter_ReadV1.cs

示例15: GetNpcByName

 public NPC GetNpcByName(string name)
 {
     if (name == null)
     {
         Console.WriteLine(MessageType.Warning, "API: getNpcByName() failed (name was null");
         return null;
     }
     NPC n = new NPC();
     for (int i = 100; i > 0; i--)
     {
         try
         {
             n.SetDefaults(i);
             if (n.name == "") continue;
             if (n.name == null) continue;
         }
         catch
         {
             continue;
         }
         if (Input.CommandMatch(name, n.name))
         {
             return n;
         }
     }
     n = null;
     return n;
 }
开发者ID:kamilion,项目名称:WraithModRevival,代码行数:28,代码来源:Core.cs


注:本文中的Terraria.NPC.SetDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。