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


C# NPC.netDefaults方法代码示例

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


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

示例1: FillVanilla

        /// <summary>
        /// Adds all the original vanilla NPCs.
        /// </summary>
        internal static void FillVanilla()
        {
            for (int i = -65; i < NPCID.Count; i++)
            {
                if (i == 0)
                    continue;

                NPC n = new NPC();
                n.netDefaults(i);

                NpcDef def = new NpcDef(Lang.npcName(n.type, true));

                def.InternalName = n.name;
                def.Type = n.type;
                def.NetID = i;

                CopyNpcToDef(def, n);

                DefFromType.Add(i, def);
                // TODO Fix overlapping names
                //VanillaDefFromName.Add(n.name, def);
            }
        }
开发者ID:chatrat12,项目名称:Prism,代码行数:26,代码来源:NpcDefHandler.cs

示例2: NPCLoot

        public void NPCLoot()
        {
            if (Main.netMode == 1 || this.type >= NPCID.Count)
            {
                return;
            }
            bool flag = NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3;
            int num = this.type;
            switch (num)
            {
            case 13:
            case 14:
            case 15:
                if (this.boss)
                {
                    AchievementsHelper.NotifyNPCKilled(this);
                }
                break;
            default:
                switch (num)
                {
                case 125:
                case 126:
                {
                    int num2 = (this.type == NPCID.Spazmatism) ? 125 : 126;
                    if (!NPC.AnyNPCs(num2))
                    {
                        AchievementsHelper.NotifyNPCKilled(this);
                        AchievementsHelper.CheckMechaMayhem(this.type);
                        goto IL_C1;
                    }
                    goto IL_C1;
                }
                case 127:
                    break;
                default:
                    if (num != 134)
                    {
                        AchievementsHelper.NotifyNPCKilled(this);
                        goto IL_C1;
                    }
                    break;
                }
                AchievementsHelper.CheckMechaMayhem(this.type);
                AchievementsHelper.NotifyNPCKilled(this);
                break;
            }
            IL_C1:
            int num3 = Item.NPCtoBanner(this.BannerID());
            if (num3 > 0 && !NPCID.Sets.ExcludedFromDeathTally[this.type] && this.AnyInteractions())
            {
                NPC.killCount[num3]++;
                if (Main.netMode == 2)
                {
                    NetMessage.SendData((int)PacketTypes.NpcKillCount, -1, -1, "", num3, 0f, 0f, 0f, 0, 0, 0);
                }
                int num4 = 50;
                if (NPC.killCount[num3] % num4 == 0 && num3 > 0)
                {
                    int l = Item.BannerToNPC(num3);
                    NPC nPC = new NPC();
                    nPC.netDefaults(l);
                    int num5 = this.lastInteraction;
                    if (!Main.player[num5].active || Main.player[num5].dead)
                    {
                        num5 = this.FindClosestPlayer();
                    }
                    string text = string.Concat(new object[]
                    {
                        "The ",
                        NPC.killCount[num3],
                        "th ",
                        Lang.npcName(l, false),
                        " has been defeated!"
                    });
                    if (num5 >= 0 && num5 < 255)
                    {
                        text = string.Concat(new object[]
                        {
                            Main.player[num5].name,
                            " has defeated the ",
                            NPC.killCount[num3],
                            "th ",
                            Lang.npcName(l, false),
                            "!"
                        });
                    }
                    if (Main.netMode == 0)
                    {
                        Main.NewText(text, 250, 250, 0, false);
                    }
                    else if (Main.netMode == 2)
                    {
                        NetMessage.SendData((int)PacketTypes.ChatText, -1, -1, text, 255, 250f, 250f, 0f, 0, 0, 0);
                    }
                    int num6 = 1615 + num3 - 1;
                    if (num3 >= 249)
                    {
                        num6 = 3593 + num3 - 249;
                    }
//.........这里部分代码省略.........
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:101,代码来源:NPC.cs

示例3: NPCIdSearch

 public static List<object> NPCIdSearch(string search)
 {
     try
     {
         var found = new List<object>();
         for (int i = -65; i < Main.maxNPCTypes; i++)
         {
             NPC npc = new NPC();
             npc.netDefaults(i);
             if (npc.name.ToLower().Contains(search.ToLower()))
                 found.Add(npc);
         }
         return found;
     }
     catch { return new List<object>(); }
 }
开发者ID:Brunban2,项目名称:Essentials-SignCommands,代码行数:16,代码来源:esUtils.cs

示例4: Initialize


//.........这里部分代码省略.........
				Main.cloud[num13] = new Cloud();
			}
			for (int num14 = 0; num14 < 100; num14++)
			{
				Main.combatText[num14] = new CombatText();
			}
			for (int num15 = 0; num15 < 20; num15++)
			{
				Main.itemText[num15] = new ItemText();
			}
			for (int num16 = 0; num16 < 2749; num16++)
			{
				Item item = new Item();
				item.SetDefaults(num16, false);
				Main.itemName[num16] = item.name;
				if (item.headSlot > 0)
				{
					Item.headType[item.headSlot] = item.type;
				}
				if (item.bodySlot > 0)
				{
					Item.bodyType[item.bodySlot] = item.type;
				}
				if (item.legSlot > 0)
				{
					Item.legType[item.legSlot] = item.type;
				}
			}
			NPC nPC = new NPC();
			for (int num17 = -65; num17 < 378; num17++)
			{
				if (num17 != 0)
				{
					nPC.netDefaults(num17);
					if (nPC.lifeMax > 32767)
					{
						Main.npcLifeBytes[num17] = 4;
					}
					else
					{
						if (nPC.lifeMax > 127)
						{
							Main.npcLifeBytes[num17] = 2;
						}
						else
						{
							Main.npcLifeBytes[num17] = 1;
						}
					}
				}
			}
			for (int num18 = 0; num18 < Recipe.maxRecipes; num18++)
			{
				Main.recipe[num18] = new Recipe();
				Main.availableRecipeY[num18] = (float)(65 * num18);
			}
			Recipe.SetupRecipes();
			for (int num19 = 0; num19 < Main.numChatLines; num19++)
			{
				Main.chatLine[num19] = new ChatLine();
			}
			for (int num20 = 0; num20 < Liquid.resLiquid; num20++)
			{
				Main.liquid[num20] = new Liquid();
			}
			for (int num21 = 0; num21 < 10000; num21++)
开发者ID:NoviaDroid,项目名称:Terraria,代码行数:67,代码来源:Main.cs

示例5: InitLifeBytes

 public static void InitLifeBytes()
 {
     NPC nPC = new NPC();
     for (int i = -65; i < 540; i++)
     {
         if (i != 0)
         {
             nPC.netDefaults(i);
             if (nPC.lifeMax > 32767)
             {
                 Main.npcLifeBytes[i] = 4;
             }
             else if (nPC.lifeMax <= 127)
             {
                 Main.npcLifeBytes[i] = 1;
             }
             else
             {
                 Main.npcLifeBytes[i] = 2;
             }
         }
     }
     nPC = null;
 }
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:24,代码来源:Main.cs

示例6: GetNPCByName

 public static List<NPC> GetNPCByName(string name)
 {
     var found = new List<NPC>();
     for (int i = 1; i < Main.maxNPCTypes; i++)
     {
         NPC npc = new NPC();
         npc.netDefaults(i);
         if (npc.name.ToLower().Contains(name.ToLower()))
             found.Add(npc);
     }
     return found;
 }
开发者ID:InanZen,项目名称:Essentials-SignCommands,代码行数:12,代码来源:esMain.cs

示例7: Find

		public static async void Find(CommandArgs e)
		{
			var regex = new Regex(@"^\w+ -(?<switch>\w+) (?<search>.+?) ?(?<page>\d*)$");
			Match match = regex.Match(e.Message);
			if (!match.Success)
			{
				e.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}find <-switch> <name...> [page]",
					TShock.Config.CommandSpecifier);
				e.Player.SendSuccessMessage("Valid {0}find switches:", TShock.Config.CommandSpecifier);
				e.Player.SendInfoMessage("-command: Finds a command.");
				e.Player.SendInfoMessage("-item: Finds an item.");
				e.Player.SendInfoMessage("-npc: Finds an NPC.");
				e.Player.SendInfoMessage("-tile: Finds a tile.");
				e.Player.SendInfoMessage("-wall: Finds a wall.");
				return;
			}

			int page = 1;
			if (!String.IsNullOrWhiteSpace(match.Groups["page"].Value) &&
				(!int.TryParse(match.Groups["page"].Value, out page) || page <= 0))
			{
				e.Player.SendErrorMessage("Invalid page '{0}'!", match.Groups["page"].Value);
				return;
			}

			switch (match.Groups["switch"].Value.ToLowerInvariant())
			{
				#region Command

				case "command":
					{
						var commands = new List<string>();

						await Task.Run(() =>
						{
							foreach (
								Command command in
									TShockAPI.Commands.ChatCommands.FindAll(c => c.Names.Any(s => s.ContainsInsensitive(match.Groups[2].Value))))
							{
								commands.Add(String.Format("{0} (Permission: {1})", command.Name, command.Permissions.FirstOrDefault()));
							}
						});

						PaginationTools.SendPage(e.Player, page, commands,
							new PaginationTools.Settings
							{
								HeaderFormat = "Found Commands ({0}/{1}):",
								FooterFormat = String.Format("Type /find -command {0} {{0}} for more", match.Groups[2].Value),
								NothingToDisplayString = "No commands were found."
							});
						return;
					}

				#endregion

				#region Item

				case "item":
					var items = new List<string>();

					await Task.Run(() =>
					{
						for (int i = -48; i < 0; i++)
						{
							var item = new Item();
							item.netDefaults(i);
							if (item.name.ContainsInsensitive(match.Groups[2].Value))
							{
								items.Add(String.Format("{0} (ID: {1})", item.name, i));
							}
						}
						for (int i = 0; i < Main.itemName.Length; i++)
						{
							if (Main.itemName[i].ContainsInsensitive(match.Groups[2].Value))
							{
								items.Add(String.Format("{0} (ID: {1})", Main.itemName[i], i));
							}
						}
					});

					PaginationTools.SendPage(e.Player, page, items,
						new PaginationTools.Settings
						{
							HeaderFormat = "Found Items ({0}/{1}):",
							FooterFormat = String.Format("Type /find -item {0} {{0}} for more", match.Groups[2].Value),
							NothingToDisplayString = "No items were found."
						});
					return;

				#endregion

				#region NPC

				case "npc":
					var npcs = new List<string>();

					await Task.Run(() =>
					{
						for (int i = -65; i < 0; i++)
						{
//.........这里部分代码省略.........
开发者ID:Stealownz,项目名称:EssentialsPlus,代码行数:101,代码来源:Commands.cs

示例8: NPCLoot

        public void NPCLoot()
        {
            if (Main.netMode == 1 || this.type >= 540)
            {
                return;
            }
            bool flag = NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3;
            int num = this.type;
            switch (num)
            {
            case 13:
            case 14:
            case 15:
                if (this.boss)
                {
                    AchievementsHelper.NotifyNPCKilled(this);
                }
                break;
            default:
                switch (num)
                {
                case 125:
                case 126:
                {
                    int num2 = (this.type == 126) ? 125 : 126;
                    if (!NPC.AnyNPCs(num2))
                    {
                        AchievementsHelper.NotifyNPCKilled(this);
                        AchievementsHelper.CheckMechaMayhem(this.type);
                        goto IL_C1;
                    }
                    goto IL_C1;
                }
                case 127:
                    break;
                default:
                    if (num != 134)
                    {
                        AchievementsHelper.NotifyNPCKilled(this);
                        goto IL_C1;
                    }
                    break;
                }
                AchievementsHelper.CheckMechaMayhem(this.type);
                AchievementsHelper.NotifyNPCKilled(this);
                break;
            }
            IL_C1:
            int num3 = Item.NPCtoBanner(this.BannerID());
            if (num3 > 0 && !NPCID.Sets.ExcludedFromDeathTally[this.type] && this.AnyInteractions())
            {
                NPC.killCount[num3]++;
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(83, -1, -1, "", num3, 0f, 0f, 0f, 0, 0, 0);
                }
                int num4 = 50;
                if (NPC.killCount[num3] % num4 == 0 && num3 > 0)
                {
                    int l = Item.BannerToNPC(num3);
                    NPC nPC = new NPC();
                    nPC.netDefaults(l);
                    int num5 = this.lastInteraction;
                    if (!Main.player[num5].active || Main.player[num5].dead)
                    {
                        num5 = this.FindClosestPlayer();
                    }
                    string text = string.Concat(new object[]
                    {
                        "The ",
                        NPC.killCount[num3],
                        "th ",
                        Lang.npcName(l, false),
                        " has been defeated!"
                    });
                    if (num5 >= 0 && num5 < 255)
                    {
                        text = string.Concat(new object[]
                        {
                            Main.player[num5].name,
                            " has defeated the ",
                            NPC.killCount[num3],
                            "th ",
                            Lang.npcName(l, false),
                            "!"
                        });
                    }
                    if (Main.netMode == 0)
                    {
                        Main.NewText(text, 250, 250, 0, false);
                    }
                    else if (Main.netMode == 2)
                    {
                        NetMessage.SendData(25, -1, -1, text, 255, 250f, 250f, 0f, 0, 0, 0);
                    }
                    int num6 = 1615 + num3 - 1;
                    if (num3 >= 249)
                    {
                        num6 = 3593 + num3 - 249;
                    }
//.........这里部分代码省略.........
开发者ID:Celant,项目名称:TerrariaAPI-Server,代码行数:101,代码来源:NPC.cs

示例9: GetNPCByName

 /// <summary>
 /// Gets a NPC by name
 /// </summary>
 /// <param name="name">Name</param>
 /// <returns>List of matching NPCs</returns>
 public static List<NPC> GetNPCByName(string name)
 {
     var found = new List<NPC>();
     NPC npc = new NPC();
     string nameLower = name.ToLower();
     for (int i = -17; i < Main.maxNPCTypes; i++)
     {
         npc.netDefaults(i);
         if (npc.name.ToLower() == nameLower)
             return new List<NPC> { npc };
         if (npc.name.ToLower().StartsWith(nameLower))
             found.Add((NPC)npc.Clone());
     }
     return found;
 }
开发者ID:jordsti,项目名称:TPulse,代码行数:20,代码来源:GameResources.cs

示例10: GetNPCById

 /// <summary>
 /// Gets an NPC by ID
 /// </summary>
 /// <param name="id">ID</param>
 /// <returns>NPC</returns>
 public static NPC GetNPCById(int id)
 {
     NPC npc = new NPC();
     npc.netDefaults(id);
     return npc;
 }
开发者ID:jordsti,项目名称:TPulse,代码行数:11,代码来源:GameResources.cs


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