/// <summary> /// 是主角等级上升 /// </summary> /// <param name="toLv">To lv.</param> public void HostRoleUpgrade(int toLv) { if (HostData.Lv >= toLv) { return; } RoleData role = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select RoleData from RolesTable where RoleId = '" + currentRoleId + "'"); string roleDataStr; if (sqReader.Read()) { roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); role.Lv = toLv > role.Lv ? toLv : role.Lv; //更新主角数据 db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + currentRoleId + "'"); } db.CloseSqlConnection(); if (role != null) { HostData.MakeJsonToModel(); role.MakeJsonToModel(); Messenger.Broadcast <RoleData, RoleData>(NotifyTypes.HostRoleUpgradeEcho, HostData, role); CallRoleInfoPanelData(false); //刷新队伍数据 MaiHandler.SetAccount(role); } }
/// <summary> /// 卸下秘籍 /// </summary> /// <param name="id">Identifier.</param> public void UnuseBook(int id) { db = OpenDb(); //查询角色信息 SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + currentRoleId + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { string roleId = sqReader.GetString(sqReader.GetOrdinal("RoleId")); //获取角色数据 string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); sqReader = db.ExecuteQuery("select BookId from BooksTable where Id = " + id); if (sqReader.Read()) { string bookId = sqReader.GetString(sqReader.GetOrdinal("BookId")); db.ExecuteQuery("update BooksTable set SeatNo = 888, BeUsingByRoleId = '' where Id = " + id); int index = role.ResourceBookDataIds.FindIndex(item => item == bookId); if (index >= 0) { //更新角色的秘籍信息 role.ResourceBookDataIds.RemoveAt(index); db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + roleId + "'"); } } } db.CloseSqlConnection(); GetBooksListPanelData(); CallRoleInfoPanelData(false); //刷新队伍数据 }
/// <summary> /// 花费银子 /// </summary> /// <returns><c>true</c>, if silver was cost, <c>false</c> otherwise.</returns> /// <param name="num">Number.</param> public bool CostSilver(double num) { if (num <= 0) { return(false); } bool hasEnoughSilver = false; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); //查询目前的银子余额 ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver); if (resource != null) { if (resource.Num >= num) { hasEnoughSilver = true; resource.Num -= num; //扣钱 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } } } db.CloseSqlConnection(); return(hasEnoughSilver); }
/// <summary> /// 消耗资源 /// </summary> /// <returns><c>true</c>, if resource was cost, <c>false</c> otherwise.</returns> /// <param name="type">Type.</param> /// <param name="num">Number.</param> public bool CostResource(ResourceType type, int num) { ModifyResources(); bool result = false; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } if (resources != null) { ResourceData find = resources.Find(item => item.Type == type); if (find != null && find.Num >= num) { find.Num -= num; db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id); result = true; } } db.CloseSqlConnection(); return(result); }
/// <summary> /// 获取行囊物品数据 /// </summary> public void GetBagPanelData() { ModifyResources(); List <ItemData> items = new List <ItemData>(); double silverNum = 0; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ItemId, Num from BagTable where BelongToRoleId = '" + currentRoleId + "'"); ItemData item; while (sqReader.Read()) { item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", sqReader.GetString(sqReader.GetOrdinal("ItemId"))); item.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); item.Num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); items.Add(item); } sqReader = db.ExecuteQuery("select ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; if (sqReader.Read()) { string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); //查询目前的银子余额 ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver); if (resource != null) { silverNum = resource.Num; } } db.CloseSqlConnection(); Messenger.Broadcast <List <ItemData>, double>(NotifyTypes.GetBagPanelDataEcho, items, silverNum); }
/// <summary> /// 使用道具 /// </summary> /// <param name="type">Type.</param> /// <param name="num">Number.</param> public void UseProp(PropType type, int num) { db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, Data from GiftsTable where Type = " + (int)type + " and BelongToRoleId = '" + currentRoleId + "'"); string dataStr; PropData propData; if (sqReader.Read()) { dataStr = DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data"))); propData = JsonManager.GetInstance().DeserializeObject <PropData>(dataStr); propData.Num = Mathf.Clamp(propData.Num - num, 0, propData.Max); if (propData.Num > 0) { //改 db.ExecuteQuery("update GiftsTable set Data = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(propData)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } else { //删 db.ExecuteQuery("delete from GiftsTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } } db.CloseSqlConnection(); }
/// <summary> /// 查询特定资源的数量 /// </summary> /// <returns>The resource number.</returns> /// <param name="type">Type.</param> public double GetResourceNum(ResourceType type) { ModifyResources(); double num = 0; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } if (resources != null) { ResourceData find = resources.Find(item => item.Type == type); if (find != null) { num = find.Num; } } db.CloseSqlConnection(); return(num); }
/// <summary> /// 回去商店数据 /// </summary> /// <param name="storeId">Store identifier.</param> public void GetStoreData(string storeId) { ModifyResources(); StoreData store = JsonManager.GetInstance().GetMapping <StoreData>("Stores", storeId); store.MakeJsonToModel(); List <ItemData> items = store.Items; double silverNum = 0; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; if (sqReader.Read()) { string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); //查询目前的银子余额 ResourceData resource = resources.Find(item => item.Type == ResourceType.Silver); if (resource != null) { silverNum = resource.Num; } } db.CloseSqlConnection(); Messenger.Broadcast <List <ItemData>, double>(NotifyTypes.GetStorePanelDataEcho, items, silverNum); }
/// <summary> /// 请求队伍信息面板数据 /// </summary> public void CallRoleInfoPanelData(bool isfighting) { db = OpenDb(); //正序查询处于战斗队伍中的角色 SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where BelongToRoleId = '" + currentRoleId + "' and State = " + (int)RoleStateType.InTeam + " order by SeatNo"); JObject obj = new JObject(); JArray data = new JArray(); string roleId; string roleDataStr; while (sqReader.Read()) { roleId = sqReader.GetString(sqReader.GetOrdinal("RoleId")); roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); data.Add(new JArray( roleId, roleDataStr, sqReader.GetInt16(sqReader.GetOrdinal("State")), sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")) )); //缓存主角数据 if (roleId == currentRoleId) { HostData = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); HostData.Injury = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")); } } obj["data"] = data; db.CloseSqlConnection(); Messenger.Broadcast <JObject, bool>(NotifyTypes.CallRoleInfoPanelDataEcho, obj, isfighting); }
/// <summary> /// 获取准备出发界面数据 /// </summary> public void GetReadyToTravelPanelData() { ModifyResources(); List <RoleData> roles = new List <RoleData>(); UserData user = null; ItemData food = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where State != " + ((int)RoleStateType.NotRecruited) + " and BelongToRoleId = '" + currentRoleId + "' order by State"); RoleData role; string roleDataStr; while (sqReader.Read()) { roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); role.MakeJsonToModel(); role.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); role.State = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State")); role.Injury = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")); roles.Add(role); } sqReader = db.ExecuteQuery("select Data, AreaFoodNum from UserDatasTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { user = JsonManager.GetInstance().DeserializeObject <UserData>(sqReader.GetString(sqReader.GetOrdinal("Data"))); user.AreaFood.Num = sqReader.GetInt32(sqReader.GetOrdinal("AreaFoodNum")); if (user.AreaFood.Num < user.AreaFood.MaxNum) { sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { //更新 string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); ResourceData resource = resources.Find(item => item.Type == ResourceType.Food); double cutNum = (double)(user.AreaFood.MaxNum - user.AreaFood.Num); cutNum = resource.Num >= cutNum ? cutNum : resource.Num; if (cutNum > 0) { resource.Num -= cutNum; user.AreaFood.Num += (int)cutNum; } } } food = user.AreaFood; } db.CloseSqlConnection(); if (roles.Count > 0 && food != null) { Messenger.Broadcast <List <RoleData>, UserData>(NotifyTypes.GetReadyToTravelPanelDataEcho, roles, user); } }
/// <summary> /// 领悟秘籍诀要 /// </summary> /// <param name="secret">Secret.</param> public void StudySecret(BookData book, SecretData secret) { List <SecretData> secrets = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ExpData, SecretsData from BookExpsTable where BookId = " + book.Id + " and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { ExpData exp = JsonManager.GetInstance().DeserializeObject <ExpData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("ExpData")))); secrets = JsonManager.GetInstance().DeserializeObject <List <SecretData> >(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretsData")))); int bookLv = Statics.GetBookLV(exp.Cur); if (secrets.Count >= bookLv) { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>目前只能领悟最多{2}张诀要", Statics.GetQualityColorString(book.Quality), book.Name, bookLv)); db.CloseSqlConnection(); return; } else { if (secrets.FindIndex(item => item.Type == secret.Type) < 0) { secrets.Add(secret); db.ExecuteQuery("update BookExpsTable set SecretsData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(secrets)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); db.ExecuteQuery("update BookSecretsTable set BelongToBookId = '" + book.Id + "' where Id = '" + secret.PrimaryKeyId + "'"); } else { AlertCtrl.Show("该类型诀要不能重复领悟!"); db.CloseSqlConnection(); return; } } } else { secrets = new List <SecretData>() { secret }; //处理空数据初始化 db.ExecuteQuery("insert into BookExpsTable (BookId, ExpData, SecretsData, BelongToRoleId) values('" + book.Id + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(new ExpData(0, Statics.GetBookMaxExp(book.Quality)))) + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(secrets)) + "', '" + currentRoleId + "')"); db.ExecuteQuery("update BookSecretsTable set BelongToBookId = '" + book.Id + "' where Id = '" + secret.PrimaryKeyId + "'"); } db.CloseSqlConnection(); if (secrets != null) { Messenger.Broadcast <BookData, List <SecretData> >(NotifyTypes.DealSecretEcho, book, secrets); Statics.CreatePopMsg(Vector3.zero, string.Format("领悟<color=\"{0}\">{1}</color>后<color=\"{2}\">{3}</color>更为精进!!", Statics.GetQualityColorString(secret.Quality), secret.Name, Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30); SoundManager.GetInstance().PushSound("ui0010"); } }
/// <summary> /// 熔解兵器 /// </summary> /// <param name="primaryKeyId">Primary key identifier.</param> public void BreakWeapon(int primaryKeyId) { int resultId = 0; db = OpenDb(); //查询资源 SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } if (resources != null) { sqReader = db.ExecuteQuery("select Id, WeaponId from WeaponsTable where Id = " + primaryKeyId); if (sqReader.Read()) { WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", sqReader.GetString(sqReader.GetOrdinal("WeaponId"))); ResourceData findResource; ResourceData resource; float addNum; for (int i = 0; i < weapon.Needs.Count; i++) { resource = weapon.Needs[i]; findResource = resources.Find(item => item.Type == resource.Type); if (findResource != null) { addNum = Mathf.Floor((float)(resource.Num * 0.5f)); //累加资源 findResource.Num += addNum; } } //删除兵器 db.ExecuteQuery("delete from WeaponsTable where Id = " + primaryKeyId); //更新资源 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id); resultId = primaryKeyId; } } db.CloseSqlConnection(); if (primaryKeyId > 0) { Messenger.Broadcast <int>(NotifyTypes.BreakWeaponEcho, primaryKeyId); } }
/// <summary> /// 治疗侠客 /// </summary> /// <param name="id">Identifier.</param> public void CureRole(int id) { db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select RoleData, InjuryType from RolesTable where Id = " + id); int injury; bool success = false; RoleData role = null; if (sqReader.Read()) { injury = sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")); string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); if (injury > 0) { sqReader = db.ExecuteQuery("select Id, Num from BagTable where Type = " + ((int)ItemType.Vulnerary) + " and Lv >= " + injury + " and BelongToRoleId = '" + currentRoleId + "' order by Lv"); int primaryKeyId = 0; int num = 0; if (sqReader.Read()) { primaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); if (num > 1) { db.ExecuteQuery("update BagTable set Num = " + (num - 1) + " where Id = " + primaryKeyId); } else { db.ExecuteQuery("delete from BagTable where Id = " + primaryKeyId); } db.ExecuteQuery("update RolesTable set InjuryType = " + ((int)InjuryType.None) + " where Id = " + id); success = true; } else { AlertCtrl.Show(string.Format("行囊中并未发现有能够治愈{0}的伤药(需要{1}级伤药)", Statics.GetInjuryName((InjuryType)injury), injury), null); } } } db.CloseSqlConnection(); if (success && role != null) { Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"#FFFF00\">{0}</color>的伤势已经痊愈!", role.Name), Color.white, 30); GetHospitalPanelData(); CallRoleInfoPanelData(false); //刷新队伍数据 } }
/// <summary> /// 前往城镇 /// </summary> /// <param name="fromIndex">From index.</param> /// <param name="toIndex">To index.</param> public void GoToCity(int fromIndex, int toIndex) { SceneData toScene = null; ModifyResources(); db = OpenDb(); string indexToId = JsonManager.GetInstance().GetMapping <string>("SceneIndexToIds", toIndex.ToString()); SqliteDataReader sqReader = db.ExecuteQuery("select CityId from EnterCityTable where CityId == '" + indexToId + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.HasRows) { FloydResult result = floyd.GetResult(fromIndex, toIndex); //查询银子是否足够支付路费 sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; if (sqReader.Read()) { string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); //查询目前的银子余额 ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver); if (resource != null) { if (resource.Num >= result.Distance) { resource.Num -= result.Distance; //扣钱 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); toScene = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", GetCityIdByIndex(toIndex)); Debug.LogWarning(GetCityIdByIndex(toIndex) + "," + toScene.Id + "," + toScene.Name); } else { AlertCtrl.Show("银子不够支付路费!"); } } } } else { AlertCtrl.Show("并没有开启前方传送点!"); } db.CloseSqlConnection(); if (toScene != null) { Messenger.Broadcast <SceneData>(NotifyTypes.GoToCityEcho, toScene); } }
/// <summary> /// 获取秘籍的修为和已领悟的诀要集合 /// </summary> /// <returns>The book exp and secrets.</returns> public ExpAndSecretData GetBookExpAndSecrets(string bookId) { ExpAndSecretData data = new ExpAndSecretData(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select ExpData, SecretsData from BookExpsTable where BookId = '" + bookId + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { data.Exp = JsonManager.GetInstance().DeserializeObject <ExpData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("ExpData")))); data.Secrets = JsonManager.GetInstance().DeserializeObject <List <SecretData> >(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretsData")))); } db.CloseSqlConnection(); return(data); }
/// <summary> /// 查询道具诗句 /// </summary> /// <returns>The property.</returns> /// <param name="type">Type.</param> public PropData GetProp(PropType type) { PropData propData = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, Data from GiftsTable where Type = " + (int)type + " and BelongToRoleId = '" + currentRoleId + "'"); string dataStr; if (sqReader.Read()) { dataStr = DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data"))); propData = JsonManager.GetInstance().DeserializeObject <PropData>(dataStr); } db.CloseSqlConnection(); return(propData); }
/// <summary> /// 查询可以领悟的所有诀要 /// </summary> /// <returns>The effective secrets.</returns> public List <SecretData> GetEffectiveSecrets() { List <SecretData> secrets = new List <SecretData>(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select * from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "' and BelongToBookId = ''"); SecretData secret; while (sqReader.Read()) { secret = JsonManager.GetInstance().DeserializeObject <SecretData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretData")))); secret.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); secrets.Add(secret); } db.CloseSqlConnection(); return(secrets); }
/// <summary> /// 查询所有的道具 /// </summary> /// <returns>The all properties.</returns> public List <PropData> GetAllProps() { List <PropData> props = new List <PropData>(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Data from GiftsTable where BelongToRoleId = '" + currentRoleId + "'"); string dataStr; PropData propData; while (sqReader.Read()) { dataStr = DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data"))); propData = JsonManager.GetInstance().DeserializeObject <PropData>(dataStr); props.Add(propData); } db.CloseSqlConnection(); return(props); }
/// <summary> /// 根据角色id查询角色数据 /// </summary> /// <returns>The role data by role identifier.</returns> /// <param name="roleId">Role identifier.</param> public RoleData GetRoleDataByRoleId(string roleId) { RoleData data = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleData, InjuryType from RolesTable where RoleId = '" + roleId + "' and State > 0 and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); data = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); data.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); data.Injury = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")); } db.CloseSqlConnection(); return(data); }
int modifyResourceTimeout = 20; //刷新资源间隔时间(单位:秒) /// <summary> /// 检测是否有新的生产单元 /// </summary> /// <param name="cityId">City identifier.</param> public void CheckNewWorkshopItems(string cityId) { db = OpenDb(); List <ResourceRelationshipData> resourcesRelationshipsInCity = WorkshopModel.Relationships.FindAll(item => item.BelongToCityId == cityId); if (resourcesRelationshipsInCity.Count > 0) { List <ResourceData> resources; SqliteDataReader sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { //更新 string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); for (int i = 0; i < resourcesRelationshipsInCity.Count; i++) { if (resources.FindIndex(item => item.Type == resourcesRelationshipsInCity[i].Type) < 0) { resources.Add(new ResourceData(resourcesRelationshipsInCity[i].Type, 0)); } } db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } else { //新增 resources = new List <ResourceData>(); for (int i = 0; i < resourcesRelationshipsInCity.Count; i++) { resources.Add(new ResourceData(resourcesRelationshipsInCity[i].Type, 0)); } db.ExecuteQuery("insert into WorkshopResourceTable (ResourcesData, Ticks, WorkerNum, MaxWorkerNum, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "', " + DateTime.Now.Ticks + ", 0, 0, '" + currentRoleId + "')"); } //记录当前所有的工坊资源类型列表 CitySceneModel.ResourceTypeStrOfWorkShopNewFlagList = new List <string>(); for (int i = resources.Count - 1; i >= 0; i--) { CitySceneModel.ResourceTypeStrOfWorkShopNewFlagList.Add(resources[i].Type.ToString()); } } db.CloseSqlConnection(); }
/// <summary> /// 卸下兵器 /// </summary> /// <param name="id">Identifier.</param> public void TakeOffWeapon(int id) { db = OpenDb(); db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + id); SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { //获取角色数据 string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); role.ResourceWeaponDataId = ""; //更新主角关联数据 db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + currentRoleId + "'"); } db.CloseSqlConnection(); GetWeaponsListPanelData(); //刷新兵器匣列表 CallRoleInfoPanelData(false); //刷新队伍数据 }
/// <summary> /// 查询队伍中的侠客 /// </summary> /// <returns>The roles in team.</returns> public List <RoleData> GetRolesInTeam() { List <RoleData> rolesData = new List <RoleData>(); db = OpenDb(); //正序查询处于战斗队伍中的角色 SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where BelongToRoleId = '" + currentRoleId + "' and State = " + (int)RoleStateType.InTeam + " order by SeatNo"); RoleData roleData; string roleDataStr; while (sqReader.Read()) { roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); roleData = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); roleData.Injury = (InjuryType)((int)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType"))); rolesData.Add(roleData); } db.CloseSqlConnection(); return(rolesData); }
/// <summary> /// 请求医馆角色数据 /// </summary> public void GetHospitalPanelData() { db = OpenDb(); List <RoleData> roles = new List <RoleData>(); SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where State != " + ((int)RoleStateType.NotRecruited) + " and BelongToRoleId = '" + currentRoleId + "'"); RoleData role; string roleDataStr; while (sqReader.Read()) { roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); role.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); role.State = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State")); role.Injury = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")); roles.Add(role); } db.CloseSqlConnection(); Messenger.Broadcast <List <RoleData> >(NotifyTypes.GetHospitalPanelDataEcho, roles); }
/// <summary> /// 请求工坊主界面数据(包括生产材料标签页数据) /// </summary> public void GetWorkshopPanelData() { JArray data = new JArray(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); string resourceDataStr = resourcesStr; data.Add(sqReader.GetInt32(sqReader.GetOrdinal("Id"))); data.Add(resourceDataStr); // data.Add(sqReader.GetInt32(sqReader.GetOrdinal("WorkerNum"))); // data.Add(sqReader.GetInt32(sqReader.GetOrdinal("MaxWorkerNum"))); data.Add(GetWorkerNum()); data.Add(GetMaxWorkerNum()); List <ResourceData> resultResources = returnAllReceiveResourcesOnece(resourceDataStr); data.Add(JsonManager.GetInstance().SerializeObject(resultResources)); } db.CloseSqlConnection(); Messenger.Broadcast <JArray>(NotifyTypes.GetWorkshopPanelDataEcho, data); }
//将所有人的伤势缓解一级 public void RelieveRoles() { db = OpenDb(); bool success = false; RoleData role = null; SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleData, InjuryType from RolesTable where InjuryType > " + 0); string roleDataStr; while (sqReader.Read()) { roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); db.ExecuteQuery("update RolesTable set InjuryType = " + (sqReader.GetInt32(sqReader.GetOrdinal("InjuryType")) - 1) + " where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); success = true; } db.CloseSqlConnection(); if (success) { AlertCtrl.Show("各位侠客的伤势得到了缓解!"); GetHospitalPanelData(); CallRoleInfoPanelData(false); //刷新队伍数据 } }
/// <summary> /// 打造兵器 /// </summary> /// <param name="weaponId">Weapon identifier.</param> public void CreateNewWeaponOfWorkshop(string weaponId) { db = OpenDb(); WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", weaponId); List <ResourceData> needs = new List <ResourceData>(); ResourceData need; ResourceData find; for (int i = 0; i < weapon.Needs.Count; i++) { need = weapon.Needs[i]; find = needs.Find(item => item.Type == need.Type); if (find == null) { needs.Add(new ResourceData(need.Type, need.Num)); } else { find.Num += need.Num; } } SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } db.CloseSqlConnection(); if (resources != null) { bool canAdd = true; string msg = ""; for (int i = 0; i < needs.Count; i++) { need = needs[i]; find = resources.Find(item => item.Type == need.Type); if (find != null && find.Num >= need.Num) { find.Num -= need.Num; } else { canAdd = false; msg = string.Format("{0}不足!", Statics.GetResourceName(need.Type)); break; } } if (canAdd) { //检测添加武器 if (AddNewWeapon(weapon.Id)) { db = OpenDb(); db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id); db.CloseSqlConnection(); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); SoundManager.GetInstance().PushSound("ui0007"); } else { AlertCtrl.Show("兵器匣已满!", null); } } else { AlertCtrl.Show(msg, null); } } }
/// <summary> /// 刷新资源数据 /// </summary> public void ModifyResources() { JArray data = new JArray(modifyResourceTimeout, "[]", "[]"); try { db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { long ticks = sqReader.GetInt64(sqReader.GetOrdinal("Ticks")); DateTime oldDate = new DateTime(ticks); float skipSeconds = (float)(DateTime.Now - oldDate).TotalSeconds; int n = (int)Mathf.Floor((skipSeconds / modifyResourceTimeout)); //设置最大的托管时间间隔(1小时之外的资源无效) int maxN = maxModifyResourceTimeout / modifyResourceTimeout; //记录倒计时时间 data[0] = skipSeconds < modifyResourceTimeout ? (int)(modifyResourceTimeout - skipSeconds) : modifyResourceTimeout; if (n > 0) { n = n > maxN ? maxN : n; int id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); List <ResourceData> resultResources = returnAllReceiveResourcesOnece(resources, n); if (resultResources.Count > 0) { ResourceData result; ResourceData find; for (int i = 0; i < resultResources.Count; i++) { result = resultResources[i]; find = resources.Find(item => item.Type == result.Type); if (find != null) { //累加拥有的资源 find.Num += result.Num; find.Num = find.Num < 0 ? 0 : find.Num; } } db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "', Ticks = " + DateTime.Now.Ticks + " where Id = " + id); } else { //没有产出也需要更新时间戳 db.ExecuteQuery("update WorkshopResourceTable set Ticks = " + DateTime.Now.Ticks + " where Id = " + id); } //添加收获的资源列表 data[1] = JsonManager.GetInstance().SerializeObject(resultResources); //计算单位产出 data[2] = JsonManager.GetInstance().SerializeObject(returnAllReceiveResourcesOnece(resources)); } } db.CloseSqlConnection(); } catch (Exception e) { db.CloseSqlConnection(); Debug.LogWarning("ModifyResources-------------------error:" + e.ToString() + " - " + e.StackTrace); return; } Messenger.Broadcast <JArray>(NotifyTypes.ModifyResourcesEcho, data); }
/// <summary> /// 增减资源的工作家丁数 /// </summary> /// <param name="type">Type.</param> /// <param name="addNum">Add number.</param> public void ChangeResourceWorkerNum(ResourceType type, int addNum) { if (addNum == 0) { return; } addNum = Mathf.Clamp(addNum, -1, 1); JArray data = new JArray(); try { db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { // int workerNum = sqReader.GetInt32(sqReader.GetOrdinal("WorkerNum")); // int maxWorkerNum = sqReader.GetInt32(sqReader.GetOrdinal("MaxWorkerNum")); int workerNum = GetWorkerNum(); int maxWorkerNum = GetMaxWorkerNum(); if (addNum > 0 && workerNum == 0) { db.CloseSqlConnection(); return; } int id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); string resourceDataStr = resourcesStr; List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourceDataStr); ResourceData findResource = resources.Find(item => item.Type == type); if (findResource != null) { if (addNum < 0 && findResource.WorkersNum == 0) { db.CloseSqlConnection(); return; } findResource.WorkersNum += addNum; findResource.WorkersNum = findResource.WorkersNum < 0 ? 0 : findResource.WorkersNum; workerNum -= addNum; workerNum = workerNum < 0 ? 0 : (workerNum > maxWorkerNum ? maxWorkerNum : workerNum); List <ResourceData> resultResources = returnAllReceiveResourcesOnece(resources); data.Add((short)type); data.Add(findResource.WorkersNum); data.Add(workerNum); data.Add(maxWorkerNum); data.Add(JsonManager.GetInstance().SerializeObject(resultResources)); //更新数据 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "', WorkerNum = " + workerNum + " where Id = " + id); SetWorkerNum(workerNum); } } db.CloseSqlConnection(); } catch (Exception e) { db.CloseSqlConnection(); Debug.LogWarning("ChangeResourceWorkerNum-------------------error:" + e.ToString() + " - " + e.StackTrace); return; } if (data.Count > 0) { Messenger.Broadcast <JArray>(NotifyTypes.ChangeResourceWorkerNumEcho, data); } }
/// <summary> /// 兵器强化 /// </summary> /// <param name="weapon">Weapon.</param> public void WeaponLVUpgrade(WeaponData weapon) { db = OpenDb(); List <ResourceData> needs = new List <ResourceData>(); ResourceData need; ResourceData find; double needRate = DbManager.Instance.GetWeaponNeedRate(weapon.LV + 1); for (int i = 0; i < weapon.Needs.Count; i++) { need = weapon.Needs[i]; find = needs.Find(item => item.Type == need.Type); if (find == null) { needs.Add(new ResourceData(need.Type, need.Num * needRate)); } else { find.Num += (need.Num * needRate); } } SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } db.CloseSqlConnection(); if (resources != null) { bool canAdd = true; string msg = ""; for (int i = 0; i < needs.Count; i++) { need = needs[i]; find = resources.Find(item => item.Type == need.Type); if (find != null && find.Num >= need.Num) { find.Num -= need.Num; } else { canAdd = false; msg = string.Format("{0}不足!", Statics.GetResourceName(need.Type)); break; } } if (canAdd) { db = OpenDb(); sqReader = db.ExecuteQuery("select Id, Data from WeaponLVsTable where WeaponId = '" + weapon.Id + "' and BelongToRoleId = '" + currentRoleId + "'"); WeaponLVData lvData; if (sqReader.Read()) { //获取角色数据 lvData = JsonManager.GetInstance().DeserializeObject <WeaponLVData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data")))); if (weapon.LV >= lvData.MaxLV) { AlertCtrl.Show("兵器强化度已满"); db.CloseSqlConnection(); return; } lvData.LV = weapon.LV + 1; db.ExecuteQuery("update WeaponLVsTable set Data = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(lvData)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } else { lvData = new WeaponLVData(weapon.LV + 1); db.ExecuteQuery("insert into WeaponLVsTable (WeaponId, Data, BelongToRoleId) values('" + weapon.Id + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(lvData)) + "', '" + currentRoleId + "')"); } db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id); db.CloseSqlConnection(); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); SoundManager.GetInstance().PushSound("ui0007"); Messenger.Broadcast <WeaponLVData>(NotifyTypes.WeaponLVUpgradeEcho, lvData); } else { AlertCtrl.Show(msg, null); } } }
/// <summary> /// 替换兵器(不允许侠客不拿兵器) /// </summary> /// <param name="id">Identifier.</param> /// <param name="beUsingByRoleId">Be using by role identifier.</param> public void ReplaceWeapon(int id, string beUsingByRoleId) { db = OpenDb(); //查询角色信息 SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + beUsingByRoleId + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { //获取角色数据 string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData")); roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr); RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr); sqReader = db.ExecuteQuery("select * from WeaponsTable where BeUsingByRoleId = '" + beUsingByRoleId + "' and BelongToRoleId ='" + currentRoleId + "'"); while (sqReader.Read()) { //将兵器先卸下 int dataId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + dataId); } sqReader = db.ExecuteQuery("select Id, WeaponId from WeaponsTable where Id = " + id); if (sqReader.Read()) { string weaponId = sqReader.GetString(sqReader.GetOrdinal("WeaponId")); WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", weaponId); if (weapon.BelongToRoleId == "") { if (weapon.Occupation == OccupationType.None || weapon.Occupation == HostData.Occupation) { //装备新兵器 db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '" + beUsingByRoleId + "' where Id = " + id); //更新角色的武器信息 role.ResourceWeaponDataId = weaponId; //查询下新武器替换上后秘籍需不需要卸下 sqReader = db.ExecuteQuery("select Id, BookId from BooksTable where BeUsingByRoleId = '" + currentRoleId + "' and BelongToRoleId = '" + currentRoleId + "'"); BookData book; string unuseBookMsg = ""; while (sqReader.Read()) { book = JsonManager.GetInstance().GetMapping <BookData>("Books", sqReader.GetString(sqReader.GetOrdinal("BookId"))); if (book.LimitWeaponType != WeaponType.None && (book.LimitWeaponType != weapon.Type)) { db.ExecuteQuery("update BooksTable set SeatNo = 888, BeUsingByRoleId = '' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); int index = role.ResourceBookDataIds.FindIndex(item => item == book.Id); if (index >= 0) { //更新角色的秘籍信息 role.ResourceBookDataIds.RemoveAt(index); } unuseBookMsg += " " + book.Name; } } //更新主角关联数据 db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + beUsingByRoleId + "'"); if (unuseBookMsg != "") { Statics.CreatePopMsg(Vector3.zero, string.Format("拿上<color=\"{0}\">{1}</color>后不可能再习练{2}", Statics.GetQualityColorString(weapon.Quality), weapon.Name, unuseBookMsg), Color.white, 30); } SoundManager.GetInstance().PushSound("ui0011"); } else { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>只有 {2} 才能使用!", Statics.GetQualityColorString(weapon.Quality), weapon.Name, Statics.GetOccupationDesc(weapon.Occupation))); } } else { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>只有 {2} 才能使用!", Statics.GetQualityColorString(weapon.Quality), weapon.Name, JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weapon.BelongToRoleId).Name)); } } } db.CloseSqlConnection(); GetWeaponsListPanelData(); //刷新兵器匣列表 CallRoleInfoPanelData(false); //刷新队伍数据 }