static string LogList(GongfaType gongfa_typ) { List <GongfaType> typs = new List <GongfaType>(); for (int i = 1; i != 1 << 31; i = i << 1) { if (((int)gongfa_typ & i) == i) { typs.Add((GongfaType)i); } } return(string.Join(", ", typs)); }
public GongfaStaticData(int lv, GongfaType gongfa_typ, int color, int create_id) { id = create_id; level = lv; this.color = color; price = 20 * (lv + 1) * (color + 1); type = gongfa_typ; // 主属性 GongfaAttrData[] main_attr_data = GongfaAttrConfig.GetMainAttr(gongfa_typ | GongfaType.main); int attr_count = main_attr_data.Length; attr_id = new int[attr_count]; attr_value = new int[attr_count][]; for (int i = 0; i < attr_count; i++) { attr_id[i] = main_attr_data[i].id; attr_value[i] = main_attr_data[i].GetRandomAttr(lv, color); } string name = ""; // 随机功法词条 int ex_count = lv + color; ex_id = new int[ex_count]; ex_values = new int[ex_count][]; ex_color = new int[ex_count]; for (int i = 0; i < ex_count; i++) { ex_color[i] = UnityEngine.Random.Range(0, GameConst.max_color + 1); GongfaAttrData congfa_attr_data = GongfaAttrConfig.GetRandomExAttr(gongfa_typ); ex_id[i] = congfa_attr_data.id; ex_values[i] = congfa_attr_data.GetRandomAttr(lv, color); if (i < 2) { name += congfa_attr_data.name; } } this.name = name + main_attr_data[0].name; difficult = lv * lv + color; SetGongfaCondition(); }
public virtual void SetGongfaCondition() { // 功法需求 attr_condition = new RoleAttribute[1][]; value_condition = new int[1] { level *level * 6 + level *color + level * 2 + color }; // 等级*等级*6+等级*品质+等级*2+品质 int max = RoleAttribute.linggen_wood - RoleAttribute.gongfa_knife; for (int i = 0; i <= max; i++) { GongfaType typ = (GongfaType)(1 << i); if ((type & typ) == typ) { attr_condition[0] = new RoleAttribute[] { RoleAttribute.gongfa_knife + i }; break; } } UnityEngine.Debug.Log(" A属性条件 " + attr_condition); UnityEngine.Debug.Log(" A属性条件 " + attr_condition[0][0]); }
/// <summary> /// 卸下功法 /// </summary> public void UnfixGongfa(ItemSubType item_sub_typ, GongfaType gongfa_typ = GongfaType.none) { switch (item_sub_typ) { case ItemSubType.Heart: for (int i = 0; i < heart_gongfa.Length; i++) { if (heart_gongfa[i] == null) { continue; } GongfaStaticData equip_gongfa = GetGongfaStaticData(heart_gongfa[i]); if (equip_gongfa != null && ((equip_gongfa.type & gongfa_typ) == gongfa_typ)) { heart_gongfa[i] = null; break; } } break; case ItemSubType.Body: body_gongfa = null; break; case ItemSubType.Attack: attack_gongfa = null; break; case ItemSubType.Skill: skill_gongfa = null; break; case ItemSubType.Magic: magic_gongfa = null; break; } EventManager.SendEvent(EventTyp.GongfaChange, null); UpdateAttr(); }
/// <summary> /// 创建功法 /// </summary> public static void CreateRandomGongfa(int lv, GongfaType gongfa_typ, int color, List <GongfaStaticData> gongfa_list, List <ItemStaticData> item_list) { create_id = gongfa_list.Count; GongfaStaticData gongfa; ItemSubType sub_type = ItemSubType.Heart; if ((gongfa_typ & GongfaType.heart) == GongfaType.heart) { gongfa = new HeartGongfaStaticData(lv, gongfa_typ, color, create_id); } else { gongfa = new SkillGongfaStaticData(lv, gongfa_typ, color, create_id); if ((gongfa_typ & GongfaType.attack) == GongfaType.attack) { sub_type = ItemSubType.Attack; } else if ((gongfa_typ & GongfaType.body) == GongfaType.body) { sub_type = ItemSubType.Body; } else if ((gongfa_typ & GongfaType.skill) == GongfaType.skill) { sub_type = ItemSubType.Skill; } else if ((gongfa_typ & GongfaType.magic) == GongfaType.magic) { sub_type = ItemSubType.Magic; } } if (gongfa != null) { gongfa_list.Add(gongfa); CreateGongfaItem(gongfa, item_list, sub_type); } }
public static void Init() { List <GongfaStaticData> gongfa_list = new List <GongfaStaticData>(); List <ItemStaticData> item_list = new List <ItemStaticData>(GameData.instance.item_static_data); // 生成心法 几个境界就循环几次 int lv_count = LevelConfigData.dataList.Length / 3; // 每个境界有前期,中期,后期 所以这里要除以3 得到境界数量 int max_count = lv_count * gongfa_count * gongfa_count; // 心法 等级数量 * 品质数量 * 功法类型数量 * // 等级数量 * 品质数量 * 功法类型数量 * max_id = lv_count * GameConst.max_color * gongfa_count * create_count * 12 * 12; for (int lv = 0; lv < lv_count; lv++) // 炼气期 筑基期 结丹期 金丹期 ... { for (int color = 1; color <= GameConst.max_color; color++) // 绿 蓝 紫 黄 橙 ... { int role_attr_offset = 0; for (GongfaType typ = GongfaType.knife; typ <= GongfaType.wood; typ = (GongfaType)((int)typ << 1)) // 刀枪剑拳掌指火水雷风土木 { for (GongfaType bigtype = GongfaType.heart; bigtype <= GongfaType.magic; bigtype = (GongfaType)((int)bigtype << 1)) // 心法 武技/灵技 身法 绝技 神通 { if (bigtype == GongfaType.heart) { for (GongfaType subtyp = GongfaType.jin; subtyp <= GongfaType.juan; subtyp = (GongfaType)((int)subtyp << 1)) // 劲 御 录 诀 经 神功 密卷 大法 { for (int gongfa_idx = 0; gongfa_idx < create_count; gongfa_idx++) // 每个境界每个属性该功法创建数量 { CreateRandomGongfa(lv, typ | bigtype | subtyp, color, gongfa_list, item_list); } } } else { for (int gongfa_idx = 0; gongfa_idx < create_count; gongfa_idx++) // 每个境界每个属性该功法创建数量 { CreateRandomGongfa(lv, typ | bigtype, color, gongfa_list, item_list); } } } role_attr_offset++; // 刀枪剑拳掌指火水雷风土木 } } } //// 测试 start //CreateRandomGongfa(0, GongfaType.attack | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.body | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.skill | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.magic | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.jin | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.shi | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.lu | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.jue | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.jing | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.fa | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.gong | GongfaType.sword, 5, gongfa_list, item_list); //CreateRandomGongfa(0, GongfaType.heart | GongfaType.juan | GongfaType.sword, 5, gongfa_list, item_list); //// 测试 end Debug.Log("功法总创建数量 " + create_id + "/" + max_id + " id{" + (item_list.Count - create_id - 1) + "-" + (item_list.Count - 1) + "}"); GameData.instance.gongfa_static_data = gongfa_list.ToArray(); GameData.instance.item_static_data = item_list.ToArray(); }
/// <summary> /// 装配功法 /// </summary> public void EquipGongfa(GongfaData gongfa, int idx = -1) { int item_id = gongfa.item_id; ItemData item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[item.static_id]; switch (static_data.sub_ype) { case ItemSubType.Heart: GongfaStaticData static_gongfa = GetGongfaStaticData(gongfa); GongfaType sub_type = GetHeartType(static_gongfa.type); // 先判断是否有装备相同类型的功法 int same = -1; for (int i = 0; i < heart_gongfa.Length; i++) { if (heart_gongfa[i] == null) { if (idx == -1) { idx = i; } continue; } GongfaStaticData equip_gongfa = GetGongfaStaticData(heart_gongfa[i]); if ((equip_gongfa.type & sub_type) == sub_type) { same = i; if (idx == -1) { idx = i; } } } if (CheckDaodian(gongfa, same == -1 ? 0 : ((HeartGongfaStaticData)GetGongfaStaticData(gongfa)).need_daodian)) { if (same != -1) { heart_gongfa[same] = null; } heart_gongfa[idx] = gongfa; } else { MessageTips.Message(47); } break; case ItemSubType.Body: body_gongfa = gongfa; break; case ItemSubType.Attack: attack_gongfa = gongfa; break; case ItemSubType.Skill: skill_gongfa = gongfa; break; case ItemSubType.Magic: magic_gongfa = gongfa; break; } EventManager.SendEvent(EventTyp.GongfaChange, null); UpdateAttr(); }
public static Dictionary <GongfaType, GongfaAttrData[]> typeList; // 键是功法类型 值是该类型对应可以有哪些词条 static GongfaAttrConfig() { Dictionary <GongfaType, List <GongfaAttrData> > all = new Dictionary <GongfaType, List <GongfaAttrData> >(); dataList = new Dictionary <int, GongfaAttrData>(); string[] data = Tools.ReadAllText("Config/gongfaAttrConfig.txt").Split('\n'); foreach (string line in data) { if (string.IsNullOrWhiteSpace(line)) { break; } if (line.StartsWith("#")) { continue; } #if UNITY_EDITOR Debug.Log(line); #endif string[] configs = line.Split('\t'); int id = int.Parse(configs[0]); // 计算词条对应的功法 GongfaType type = GongfaType.none; string[] types = configs[1].Split('|'); foreach (string typ_str in types) { type |= (GongfaType)Enum.Parse(typeof(GongfaType), typ_str); } string des = configs[3]; string name = configs[4]; float cool = float.Parse(configs[5]); int cost = int.Parse(configs[6]); bool isSkill = false; // 词条赋予的属性 RoleAttribute attr; GongfaSkill skill = GongfaSkill.None; if (!Enum.TryParse(configs[7], out attr)) { isSkill = true; skill = (GongfaSkill)Enum.Parse(typeof(GongfaSkill), configs[7]); } // 第一个索引是保存不同境界的最小随机范围 第二个索引是有些词条会有多个属性变量 int[][] min_attr; int[][] max_attr; string attr_str = configs[8]; if (!(string.IsNullOrWhiteSpace(attr_str) || attr_str == "-")) { List <int[]> all_min_attr = new List <int[]>(); List <int[]> all_max_attr = new List <int[]>(); string[] allattr = attr_str.Split(';'); for (int attr_idx = 0; attr_idx < allattr.Length; attr_idx++) { int[] minAttr = new int[GameConst.max_item_level]; int[] maxAttr = new int[GameConst.max_item_level]; string[] attrs = allattr[attr_idx].Split('|'); for (int lv = 0; lv < attrs.Length; lv++) { string[] minmax = attrs[lv].Split('-'); minAttr[lv] = (int.Parse(minmax[0])); maxAttr[lv] = (int.Parse(minmax[1])); } all_min_attr.Add(minAttr); all_max_attr.Add(maxAttr); } min_attr = all_min_attr.ToArray(); max_attr = all_max_attr.ToArray(); } else { min_attr = new int[0][]; max_attr = new int[0][]; } if (!all.ContainsKey(type)) { all.Add(type, new List <GongfaAttrData>()); } GongfaAttrData attr_data = new GongfaAttrData() { id = id, type = type, name = name, des = des, isSkill = isSkill, attr = attr, skill = skill, min_attr = min_attr, max_attr = max_attr, cost = cost, cool = cool, }; all[type].Add(attr_data); dataList.Add(id, attr_data); } typeList = new Dictionary <GongfaType, GongfaAttrData[]>(); foreach (KeyValuePair <GongfaType, List <GongfaAttrData> > item in all) { typeList.Add(item.Key, item.Value.ToArray()); } }
public HeartGongfaStaticData(int lv, GongfaType gongfa_typ, int color, int create_id) : base(lv, gongfa_typ, color, create_id) { need_daodian = (int)((level * level * 6 + level * color + level * 2 + color) * 0.1f * color + 2 * color); // (等级*等级*6+等级*品质+等级*2+品质)*0.1*品质+2*品质 }