public Hat(Hat other) : base(other) { this.usetime = other.usetime; this.sanitybonus = other.sanitybonus; }
public static void InitRecipes() { string[,] recipes = new string[, ] { //工具 { "斧头", "树枝 燧石", "1 1", "axe" }, //每个用一个空格隔开,多了不行 { "鹤嘴锄", "树枝 燧石", "2 2", "pickaxe" }, { "end", "end", "", "" }, ///照明 { "火把", "干草 树枝", "2 2", "torch_shadow_alt" }, { "篝火", "干草 木材", "3 2", "campfire" }, { "石篝火", "木材 石头", "2 12", "firepit_stonehenge" }, { "end", "", "", "" }, //生存 { "钓鱼竿", "树枝 蜘蛛丝", "2 2", "fishingrod" }, { "end", "", "", "" }, //武器 { "长矛", "树枝 干草 燧石", "2 3 1", "spear_rose" }, { "火腿棒", "猪皮 树枝 大肉", "1 2 2", "hambat_spiralcut" }, { "end", "", "", "" }, //防具 { "草甲", "干草 树枝", "10 2", "lavaarena_armorlight" }, { "木甲", "木材 干草", "8 6", "armorwood" }, { "橄榄球头盔", "猪皮 干草", "1 3", "lavaarena_lightdamagerhat" }, { "end", "", "", "" }, //服装 { "花环", "花瓣", "12", "flowerhat_healing" }, { "草帽", "干草", "12", "strawhat_floppy" }, { "高礼帽", "蜘蛛丝", "6", "tophat_festive_bell_red_firehound" }, { "end", "", "", "" }, }; string[,] backpacks = new string[, ] { //这个比较特殊要单独写 { "背包", "12", "干草 树枝", "4 4", "backpack_catcoon" }, //12格 { "猪背包", "16", "猪皮 蜘蛛丝 干草", "4 4 6", "piggyback" }, //16格 }; //string[,] foods = new string[,] //不同于烤这个高级 //{ // {""}, //} int Length = recipes.Length / 3;//有3个字符串要除3 int index = 0; char[] separator = new char[] { ' ' }; StringSplitOptions options = StringSplitOptions.RemoveEmptyEntries; //移除空的 for (; index < Length; ++index) //工具 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Tool tool = (Tool)g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddTool(tool, recipe, skin); } for (; index < Length; ++index) //照明 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Prefab light = g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddLight(light, recipe, skin); } for (; index < Length; ++index) //生存 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Prefab live = g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddLive(live, recipe, skin); } for (; index < Length; ++index) //武器 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Weapon weapon = (Weapon)g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddFight(weapon, recipe, skin); } for (; index < Length; ++index) //防具 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Armor armor = (Armor)g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddFight(armor, recipe, skin); } for (; index < Length; ++index) //服装,没时间写了,所以就简单写了个帽子 { string name = recipes[index, 0]; if (name == "end") { index++; break; } Hat hat = (Hat)g_prefabs.GetPrefab(name); string[] prefabs = recipes[index, 1].Split(separator, options); string[] nums = recipes[index, 2].Split(separator, options); string skin = recipes[index, 3]; Dictionary <string, uint> recipe = new Dictionary <string, uint>(); for (int i = 0; i < prefabs.Length; ++i) { recipe.Add(prefabs[i], UInt32.Parse(nums[i])); } AddClothes(hat, recipe, skin); } for (int i = 0; i < backpacks.Length / 4; ++i) //不要复制粘贴!!! { string name = backpacks[i, 0]; uint capacity = UInt32.Parse(backpacks[i, 1]); Dictionary <string, uint> recipe = new Dictionary <string, uint>(); string[] prefabs = backpacks[i, 2].Split(separator, options); string[] nums = backpacks[i, 3].Split(separator, options); string skin = backpacks[i, 4]; for (int j = 0; j < prefabs.Length; ++j) { recipe.Add(prefabs[j], UInt32.Parse(nums[j])); } AddBackPack(name, recipe, capacity, skin); } }
public static void InitPrefabs() { foreach (string name in material) { Prefab prefab = new Prefab(name); prefab.AddTag("material"); prefab.AddTag("stackable");//可堆叠 prefabs.Add(name, prefab); } foreach (string v in tool) { string[] str = v.Split(); string name = str[0]; int num = Convert.ToInt32(str[1]); Tool prefab = new Tool(name, num); SetToolUSe(prefab); tools.Add(name, prefab); } foreach (string v in weapon) { var traveler = Form1.traveler; string[] str = v.Split(); string name = str[0]; double damage = Convert.ToDouble(str[1]); int usetime = Convert.ToInt32(str[2]); Weapon prefab = new Weapon(name, damage, usetime); SetWeaponSkills(prefab); prefab.usefn1 = (Prefab who) => { var weapon = (Weapon)who; traveler.SetWeapon(weapon); weapon.curusetime--; MainForm.TB_weapon.Text = weapon.name; if (weapon.IsBroken()) { MainForm.TB_weapon.Text = ""; traveler.backpack.Remove(weapon.name, 1); } MainForm.ReflashBackpackList(); }; weapons.Add(name, prefab); } foreach (string v in armor) { var traveler = Form1.traveler; string[] str = v.Split(); string name = str[0]; double defense = Convert.ToDouble(str[1]); double maxdurability = Convert.ToDouble(str[2]); Armor prefab = new Armor(name, defense, maxdurability); prefab.usefn1 = (Prefab who) => { var armor = (Armor)who; traveler.SetArmor(armor); traveler.backpack.Remove(armor.name, 1); MainForm.TB_armor.Text = armor.name; MainForm.ReflashBackpackList(); }; armors.Add(name, prefab); } foreach (string v in hat) { var traveler = Form1.traveler; string[] str = v.Split(); string name = str[0]; double sanitybonus = Convert.ToDouble(str[1]); int usetime = Convert.ToInt32(str[2]); Hat prefab = new Hat(name, sanitybonus, usetime); prefab.usefn1 = (Prefab who) => { var hat = (Hat)who; traveler.SetHat(hat); traveler.backpack.Remove(who.name, 1); MainForm.TB_hat.Text = who.name; MainForm.timer_baseupdata.Enabled = true; }; hats.Add(name, prefab); } foreach (string v in food) //简单的烤 { var traveler = Form1.traveler; string[] str = v.Split(); string name = str[0]; if (name == "end") { continue; } double hungerdelta = Convert.ToDouble(str[1]); double healthdelta = Convert.ToDouble(str[2]); double sanitydelta = Convert.ToDouble(str[3]); Food prefab = new Food(name, hungerdelta, healthdelta, sanitydelta); foods.Add(prefab.name, prefab); prefab.usefn1 = (Prefab who) => { traveler.Eat((Food)who); traveler.backpack.Remove(who.name, 1); MainForm.ReflashBasedata(); }; if (str.Length > 4) { double cookhungerdelta = Convert.ToDouble(str[4]); double cookhealthdelta = Convert.ToDouble(str[5]); double cooksanitydelta = Convert.ToDouble(str[6]); Food cookprefab = new Food("烤" + name, cookhungerdelta, cookhealthdelta, cooksanitydelta); cookprefab.recipe.Add(prefab.name, 1); prefab.SetCookfood(cookprefab); foods.Add(cookprefab.name, cookprefab); MainForm.AddCookButton(cookprefab, str[7]); //强迫加入图片 cookprefab.usefn1 = (Prefab who) => { traveler.Eat((Food)who); traveler.backpack.Remove(who.name, 1); MainForm.ReflashBasedata(); }; } } foreach (string name in goods) { if (prefabs.ContainsKey(name)) { prefabs[name].AddTag("tradeable"); } else if (tools.ContainsKey(name)) { tools[name].AddTag("tradeable"); } else if (weapons.ContainsKey(name)) { weapons[name].AddTag("tradeable"); } else if (armors.ContainsKey(name)) { armors[name].AddTag("tradeable"); } else if (foods.ContainsKey(name)) { foods[name].AddTag("tradeable"); } else { Prefab newprefab = new Prefab(name); newprefab.AddTag("tradeable"); prefabs.Add(name, newprefab); } } }
public static void RemovePrefab(Hat prefab) { hats.Remove(prefab.name); }
public void RemoveHat() { this.sanitybonus -= this.hat.sanitybonus; this.hat = null; }
public void SetHat(Hat hat) { this.hat = hat; this.sanitybonus += hat.sanitybonus; }