public static void SaveGame() { string game_path = Tools.SavePath("game.data"); GameData.instance.SaveGame(); byte[] byt2 = Tools.SerializeObject(GameData.instance); Tools.WriteAllBytes(game_path, byt2); string main_role_path = Tools.SavePath("main_role.data"); RoleData.mainRole.SaveGame(); byte[] byt = Tools.SerializeObject(RoleData.mainRole); Tools.WriteAllBytes(main_role_path, byt); QuickSave save = new QuickSave() { time = GameData.instance.GetGameData(GlobalAttribute.time), name = RoleData.mainRole.name, level = RoleData.mainRole.GetAttr(RoleAttribute.level), sex = RoleData.mainRole.sex, }; string quick_save_path = Tools.SavePath("quick_save.data"); byte[] byt3 = Tools.SerializeObject(save); Tools.WriteAllBytes(quick_save_path, byt3); MessageTips.Message(17); }
private void OnClickUp(BaseEventData data) { if (!onItem) { return; } if (gongfa != null && roleData == RoleData.mainRole) { bool isWear = roleData.GonfaIsEquip(gongfa); // 是否穿戴着 if (isWear) { if (isBag) { MessageTips.Message(48); } else { RoleData.mainRole.UnfixGongfa(gongfa); } } else { RoleData.mainRole.EquipGongfa(gongfa); } } clickFunc?.Invoke(); }
public void NewGame() { string name = inputField.text; if (string.IsNullOrWhiteSpace(name)) { MessageTips.Message(5); Toggle1.isOn = true; return; } if (intrinsic < 0) { MessageTips.Message(2); Toggle1.isOn = true; return; } if (external.Count < 2) { MessageTips.Message(3); Toggle1.isOn = true; return; } if (sel_xiantian.Count < 3) { MessageTips.Message(4); Toggle2.isOn = true; return; } StartCoroutine(CreateNewGame()); }
/// <summary> /// 添加或新建道具 /// </summary> /// <param name="static_id">添加的物品静态配置id</param> /// <param name="count">添加的数量,返回时大于0则是无法添加的数量</param> /// <returns>是否成功添加 无法添加的数量在count</returns> public bool AddOrCreateItem(int static_id, ref int count) { ItemStaticData static_data = GameData.instance.item_static_data[static_id]; // 判断是否可以叠加 for (int i = 0; i < bag_items.Count; i++) { ItemData item = GameData.instance.all_item[bag_items[i]]; if (item.static_id == static_id && item.count < static_data.maxcount) { // 背包有物品 并且堆叠数量未满 int can_count = static_data.maxcount - item.count; if (can_count >= count) { item.count += count; EventManager.SendEvent(EventTyp.ItemChange, null); return(true); } else { count -= can_count; item.count += can_count; } } } if (bag_items.Count >= GetAttr(RoleAttribute.max_item)) { MessageTips.Message(21); // 提示背包已满 return(false); } do { int item_id = GameData.instance.NewItem(static_id, ref count); if (!AddItem(item_id, ref count)) { GameData.instance.RemoveItem(item_id); return(false); } } while (count > 0); return(true); }
/// <summary> /// UI是显示的(并且是最前的)就隐藏,否则就显示(到最前) /// </summary> public static void ChangeUI(string name, string sub_show = null) { if (instance.uiList == null) { return; } if (!instance.uiList.ContainsKey(name)) { MessageTips.Message(1); return; } if (IsOpen(name, sub_show)) { HideUI(name); } else { ShowUI(name, sub_show); } }
public void EquipItem(int item_id, int idx) { ItemData item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[item.static_id]; if (!LevelConfigData.CheckLevel(GetAttr(RoleAttribute.level), static_data.level)) { MessageTips.Message(43, LevelConfigData.GetBigName(static_data.level)); return; } if (static_data.sub_ype == ItemSubType.recoverRemedy || static_data.sub_ype == ItemSubType.buffRemedy) { remedy_items[idx] = item_id; EventManager.SendEvent(EventTyp.ItemChange, null); } else { EquipItem(item_id); } }
/// <summary> /// 添加道具 /// </summary> /// <param name="static_id">添加的物品id</param> /// <param name="count">添加的数量,返回时大于0则是无法添加的数量</param> /// <returns>是否成功添加 无法添加的数量在count</returns> public bool AddItem(int item_id, ref int count) { ItemData add_item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[add_item.static_id]; // 判断是否可以叠加 for (int i = 0; i < bag_items.Count; i++) { ItemData item = GameData.instance.all_item[bag_items[i]]; if (item.static_id == add_item.static_id && item.count < static_data.maxcount) { // 背包有物品 并且堆叠数量未满 int can_count = static_data.maxcount - item.count; if (can_count >= count) { item.count += count; GameData.instance.RemoveItem(add_item.id); // 物品堆叠到一起,删除旧的物品 EventManager.SendEvent(EventTyp.ItemChange, null); return(true); } else { count -= can_count; item.count += can_count; } } } if (bag_items.Count >= GetAttr(RoleAttribute.max_item)) { MessageTips.Message(21); // 提示背包已满 return(false); } // 增加物品 bag_items.Add(item_id); EventManager.SendEvent(EventTyp.ItemChange, null); return(true); }
public static void ShowUI(string name, string sub_show = null) { if (instance.uiList == null) { return; } if (!instance.uiList.ContainsKey(name)) { MessageTips.Message(1); return; } instance.sub_show = sub_show; var obj = instance.uiList[name]; if (obj.activeSelf) { obj.SetActive(false); } obj.SetActive(true); obj.transform.SetAsLastSibling(); SoundManager.PlayUIClip(SoundManager.UIClipType.bag_open); }
public void ClickKan() { // 堪舆 MessageTips.Message(1); }
public void ClickXiu() { // 修炼 MessageTips.Message(1); }
public void ClickChangeTask() { // 显示/隐藏任务 MessageTips.Message(1); }
public void ClickTime() { // 跳过本月 MessageTips.Message(1); }
public void ClickLevel() { // 逆天改命 MessageTips.Message(1); }
public void ClickNotice() { // 通知 MessageTips.Message(1); }
/// <summary> /// 装备物品 /// 戒指或坐骑:如果是已穿戴就卸下,否则就穿戴 /// 药物:是已装备的药物则卸下,否则装备到最后一个空格子,没有的话提示装备已满 /// </summary> public void EquipItem(int item_id) { ItemData item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[item.static_id]; if (!LevelConfigData.CheckLevel(GetAttr(RoleAttribute.level), static_data.level)) { MessageTips.Message(43, LevelConfigData.GetBigName(static_data.level)); return; } // 移除穿在身上的 if (static_data.sub_ype == ItemSubType.Ring) { if (equip_items[0] != -1) { int empty_count = GetAttr(RoleAttribute.max_item) - bag_items.Count; if (equip_items[0] == item_id) { // 脱下 empty_count -= GetItemAttrbuite(item_id, RoleAttribute.max_item); } else { // 更换 if (equip_items[0] != -1) { empty_count -= GetItemAttrbuite(equip_items[0], RoleAttribute.max_item); } empty_count += GetItemAttrbuite(item_id, RoleAttribute.max_item); } if (empty_count < 0) { // 无法更换或脱下戒指 MessageTips.Message(44); return; } } if (equip_items[0] == item_id) // 戒指 { equip_items[0] = -1; } else { equip_items[0] = item_id; } UpdateAttr(); EventManager.SendEvent(EventTyp.ItemChange, null); } else if (static_data.sub_ype == ItemSubType.Ride) { if (equip_items[1] == item_id) // 坐骑 { equip_items[1] = -1; } else { equip_items[1] = item_id; } UpdateAttr(); EventManager.SendEvent(EventTyp.ItemChange, null); } else if (static_data.sub_ype == ItemSubType.recoverRemedy || static_data.sub_ype == ItemSubType.buffRemedy) { for (int i = 0; i < remedy_items.Length; i++) // 判断卸下丹药 { if (remedy_items[i] == item_id) { remedy_items[i] = -1; EventManager.SendEvent(EventTyp.ItemChange, null); return; } } for (int i = 0; i < remedy_items.Length; i++) // 判断穿戴丹药 { if (remedy_items[i] == -1) { remedy_items[i] = item_id; EventManager.SendEvent(EventTyp.ItemChange, null); return; } } MessageTips.Message(27); } }
public void UseItem(int item_id, int count = 1) { ItemData item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[item.static_id]; if (!LevelConfigData.CheckLevel(GetAttr(RoleAttribute.level), static_data.level)) { MessageTips.Message(43, LevelConfigData.GetBigName(static_data.level)); return; } switch (static_data.type) { case ItemType.Remedy: // 丹药类 switch (static_data.sub_ype) { case ItemSubType.recoverRemedy: // 恢复类丹药 // 扣除道具 RemoveItem(item_id, count); // 恢复 for (int i = 0; i < static_data.attributes.Length; i++) { ChangeAttrebuteValue(static_data.attributes[i], static_data.attr_values[i] * count); } break; case ItemSubType.aptitudesRemedy: // 资质丹药 // 扣除道具 RemoveItem(item_id, count); // 增加属性 for (int i = 0; i < static_data.attributes.Length; i++) { int multiple = (GetAttr(static_data.attributes[i]) >= static_data.param[0]) ? 0 : 1; ChangeAttrebuteMaxValue(static_data.attributes[i], static_data.attr_values[i] * count * multiple); if (multiple < 1) { MessageTips.Message(46); } } break; case ItemSubType.buffRemedy: break; case ItemSubType.otherRemedy: break; } break; case ItemType.Gongfa: // 功法类 GongfaStaticData gongfa = GameData.GetStaticGongfaFromItem(item_id); RoleAttribute[][] need_attr = gongfa.attr_condition; var need_value = gongfa.value_condition; int condition_count = need_value.Length; for (int i = 0; i < condition_count; i++) { RoleAttribute[] need = need_attr[i]; int value = need_value[i]; bool can = false; foreach (RoleAttribute attr in need) { if (GetAttr(attr) >= value) { can = true; break; } } if (!can) { // 修炼资质不足 MessageTips.Message(45); return; } } RemoveItem(item_id, count, false); GongfaData new_gongfa = new GongfaData() { item_id = item.id, attr_value = gongfa.attr_value, ex_values = gongfa.ex_values, ex_color = gongfa.ex_color }; all_gongfa.Add(new_gongfa); int mood = 10; ChangeAttrebuteValue(RoleAttribute.mood, -mood); GameData.instance.SetGameData(GlobalAttribute.time, GameData.instance.GetGameData(GlobalAttribute.time) + GameConst.oneDayTicks * 15); MessageWindow.Message(49, 50, null, 0, mood.ToString(), gongfa.name); break; } }
public void ClickCai() { // 采药 MessageTips.Message(1); }
/// <summary> /// 点击成就 /// </summary> public void ClickAchievement() { MessageTips.Message(1); }
public void ClickWa() { // 挖矿 MessageTips.Message(1); }
public void ClickMap() { // 小地图 MessageTips.Message(1); }
public void ClickTask() { // 任务 MessageTips.Message(1); }
/// <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(); }