/// <summary> /// 丢弃物品 /// </summary> /// <param name="id">Identifier.</param> public void DiscardItem(int id) { bool discarded = false; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ItemId from BagTable where Id = " + id); ItemData item = null; while (sqReader.Read()) { item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", sqReader.GetString(sqReader.GetOrdinal("ItemId"))); //检测物品是否可以丢弃 if (item.CanDiscard) { //丢弃物品 db.ExecuteQuery("delete from BagTable where Id = " + id); discarded = true; } } db.CloseSqlConnection(); if (discarded) { GetBagPanelData(); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"#1ABDE6\">{0}</color>已被丢弃", item.Name), Color.white, 30); } }
/// <summary> /// 工坊相关消息 /// </summary> public static void WorkshopNotifyInit() { Messenger.AddListener <string>(NotifyTypes.ShowWorkshopPanel, (cityId) => { WorkshopPanelCtrl.Show(cityId); }); Messenger.AddListener(NotifyTypes.GetWorkshopPanelData, () => { DbManager.Instance.GetWorkshopPanelData(); }); Messenger.AddListener <JArray>(NotifyTypes.GetWorkshopPanelDataEcho, (data) => { Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); WorkshopPanelCtrl.MakeGetWorkshopPanelDataEcho(data); }); Messenger.AddListener <ResourceType, int>(NotifyTypes.ChangeResourceWorkerNum, (type, num) => { DbManager.Instance.ChangeResourceWorkerNum(type, num); }); Messenger.AddListener <JArray>(NotifyTypes.ChangeResourceWorkerNumEcho, (data) => { WorkshopPanelCtrl.MakeChangeResourceWorkerNumEcho(data); }); Messenger.AddListener(NotifyTypes.ModifyResources, () => { DbManager.Instance.ModifyResources(); }); Messenger.AddListener <JArray>(NotifyTypes.ModifyResourcesEcho, (data) => { WorkshopPanelCtrl.MakeModifyResourcesEcho(data); }); Messenger.AddListener(NotifyTypes.GetWorkshopWeaponBuildingTableData, () => { DbManager.Instance.GetWorkshopWeaponBuildingTableData(); }); Messenger.AddListener <JArray>(NotifyTypes.GetWorkshopWeaponBuildingTableDataEcho, (data) => { WorkshopPanelCtrl.MakeGetWorkshopWeaponBuildingTableDataEcho(data); }); Messenger.AddListener <string>(NotifyTypes.CreateNewWeaponOfWorkshop, (weaponId) => { DbManager.Instance.CreateNewWeaponOfWorkshop(weaponId); }); Messenger.AddListener(NotifyTypes.GetWorkshopWeaponBreakingTableData, () => { DbManager.Instance.GetWorkshopWeaponBreakingTableData(); }); Messenger.AddListener <List <WeaponData> >(NotifyTypes.GetWorkshopWeaponBreakingTableDataEcho, (weapons) => { WorkshopPanelCtrl.MakeGetWorkshopWeaponBreakingTableDataEcho(weapons); }); Messenger.AddListener <int>(NotifyTypes.BreakWeapon, (primaryKeyId) => { DbManager.Instance.BreakWeapon(primaryKeyId); }); Messenger.AddListener <int>(NotifyTypes.BreakWeaponEcho, (primaryKeyId) => { WorkshopPanelCtrl.MakeBreakWeaponEcho(primaryKeyId); Statics.CreatePopMsg(Vector3.zero, "兵器被扔进熔炼炉内瞬间化为乌有", Color.white, 30); SoundManager.GetInstance().PushSound("ui0008"); }); }
/// <summary> /// 将背包里的辎重箱放入工坊资源中 /// </summary> public void BringResourcesToWorkshop() { db = OpenDb(); //查询背包 SqliteDataReader sqReader = db.ExecuteQuery("select * from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot); if (sqReader.HasRows) { List <ResourceType> types = new List <ResourceType>(); List <int> nums = new List <int>(); ResourceType type; while (sqReader.Read()) { type = Statics.ChangeItemTypeToResourctType((ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type"))); types.Add(type); nums.Add(sqReader.GetInt32(sqReader.GetOrdinal("Num")) * sqReader.GetInt32(sqReader.GetOrdinal("Lv"))); } if (types.Count > 0) { //查询出资源 sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { int resourceId = 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); ResourceData findResource; int num; string msg = ""; for (int i = 0; i < types.Count; i++) { findResource = resources.Find(re => re.Type == types[i]); if (findResource != null) { num = nums[i]; findResource.Num += num; msg += string.Format("\n{0}+{1}", Statics.GetResourceName(types[i]), num); } else { msg += string.Format("\n<color=\"#FF0000\">工坊产力不够无力储存{0}只好丢弃</color>", Statics.GetResourceName(types[i])); } } //清空背包里的辎重箱 db.ExecuteQuery("delete from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot); //更新资源数据 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + resourceId); if (msg != "") { msg = "这次游历江湖带回了" + msg; Statics.CreatePopMsg(Vector3.zero, msg, Color.green, 30); } } } } db.CloseSqlConnection(); }
/// <summary> /// 购买物品成功回调 /// </summary> /// <param name="msg">Message.</param> /// <param name="silver">Silver.</param> public void BuyItemEcho(string msg, double silver) { silverNum = silver; Statics.CreatePopMsg(Vector3.zero, msg, Color.white, 30); silverText.rectTransform.anchoredPosition3D = new Vector3(40, 0, 0); silverText.transform.DOKill(); silverText.transform.DOShakePosition(0.5f, 5); silverText.text = silverNum.ToString(); }
/// <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="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); //刷新队伍数据 } }
void onClick(GameObject e) { switch (e.name) { case "limePowderBlockImage": if (propLimePowderData == null) { break; } if (limePowderTimerImage.fillAmount <= 0) { limePowderTimerImage.DOKill(); limePowderTimerImage.fillAmount = 1; limePowderTimerImage.DOFillAmount(0, 5).SetEase(Ease.Linear); propLimePowderData.Num--; refreshLimePowder(); Messenger.Broadcast <PropType, int>(NotifyTypes.UseProp, PropType.LimePowder, 1); Messenger.Broadcast(NotifyTypes.MakeUpdateProps); if (Random.Range(0, 100) >= 50) { Hide(); //任务详情界面打开时不呼出角色信息板 if (TaskDetailInfoPanelCtrl.Ctrl == null) { Messenger.Broadcast <bool>(NotifyTypes.CallRoleInfoPanelData, false); } Messenger.Broadcast(NotifyTypes.PlayBgm); Statics.CreatePopMsg(Vector3.zero, "抓了一把石灰粉洒向敌人,本方全身而退!", Color.yellow, 30); PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, ""); } else { Statics.CreatePopMsg(Vector3.zero, "抓了一把石灰粉洒向敌人,被对方躲开!", Color.red, 30); } } break; case "pauseBtn": paused = !paused; pauseBtn.GetComponentInChildren <Text>().text = paused ? "继续" : "暂停"; infoBgImageRect.offsetMax = new Vector2(infoBgImageRect.offsetMax.x, paused ? -120 : -400); enemyBody.gameObject.SetActive(!paused); break; default: break; } }
/// <summary> /// 融合诀要 /// </summary> /// <param name="secret">Secret.</param> public bool MixSecrets(SecretData secret) { bool result = false; if (secret.Quality >= QualityType.FlashRed) { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>已经是顶级诀要无法继续融合", Statics.GetQualityColorString(secret.Quality), secret.Name)); return(result); } db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select count(*) as num from BookSecretsTable where T = " + ((short)secret.Type) + " and Q = " + ((short)secret.Quality) + " and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { if (sqReader.GetInt32(sqReader.GetOrdinal("num")) >= 2) { sqReader = db.ExecuteQuery("select Id from BookSecretsTable where T = " + ((short)secret.Type) + " and Q = " + ((short)secret.Quality) + " and BelongToRoleId = '" + currentRoleId + "' and Id != " + secret.PrimaryKeyId + " order by Id limit 0, 1"); //删除素材诀要 while (sqReader.Read()) { db.ExecuteQuery("delete from BookSecretsTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } //升级选中的诀要 sqReader = db.ExecuteQuery("select SecretData, Q from BookSecretsTable where Id = " + secret.PrimaryKeyId); if (sqReader.Read()) { SecretData secretData = JsonManager.GetInstance().DeserializeObject <SecretData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretData")))); short endQuality = (short)(((int)secretData.Quality) + 1); secretData.Quality = (QualityType)(endQuality); db.ExecuteQuery("update BookSecretsTable set SecretData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secretData)) + "', Q = " + ((short)secretData.Quality) + " where Id = " + secret.PrimaryKeyId); Statics.CreatePopMsg(Vector3.zero, string.Format("融合<color=\"{0}\">{1}</color>后使你武功精进!", Statics.GetQualityColorString(secretData.Quality), secretData.Name), Color.white, 30); SoundManager.GetInstance().PushSound("ui0010"); result = true; } else { AlertCtrl.Show("需要融合的诀要不存在"); } } else { AlertCtrl.Show(string.Format("至少需要2张相同品质的<color=\"{0}\">{1}</color>才能融合成更高级的诀要", Statics.GetQualityColorString(secret.Quality), secret.Name)); } } db.CloseSqlConnection(); return(result); }
/// <summary> /// 请求资源累加数据 /// </summary> /// <param name="data">Data.</param> public void ModifyResourcesEcho(JArray data) { modifyTimeout = (int)data[0] + 1; List <ResourceData> receiveResources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(data[1].ToString()); List <ResourceData> _receiveResources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(data[2].ToString()); Timer.RemoveTimer("WorkshopModifyResourceTimer"); timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(modifyTimeout)); Timer.AddTimer("WorkshopModifyResourceTimer", modifyTimeout, (timer) => { timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(timer.Second)); }, (timer) => { timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(timer.Second)); Messenger.Broadcast(NotifyTypes.ModifyResources); }); ResourceData receive; WorkshopResourceContainer findContainer; string msg = ""; for (int i = 0; i < receiveResources.Count; i++) { receive = receiveResources[i]; if (receive.Num != 0) { msg += string.Format("<color=\"{2}\">{0} {1}</color>\n", Statics.GetResourceName(receive.Type), (receive.Num > 0 ? ("+" + receive.Num.ToString()) : receive.Num.ToString()), receive.Num > 0 ? "#00FF00" : "#FF0000"); if (toggleGroup0.gameObject.activeSelf) { findContainer = resourceContainers.Find(item => item.Type == receive.Type); //更新资源的工作家丁数 if (findContainer != null) { findContainer.UpdateNum(receive.Num); } } } } if (msg != "") { Statics.CreatePopMsg(Vector3.zero, msg, Color.white, 30); } //刷新产出总量 if (_receiveResources.Count > 0) { resultResources = _receiveResources; RefreshResultResourcesView(); } }
/// <summary> /// 吃干粮 /// </summary> /// <param name="id">Identifier.</param> /// <param name="num">Number.</param> public void Eat(int id, int num) { int eatNum = 0; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, Data, AreaFoodNum from UserDatasTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { int userDataId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); UserData user = JsonManager.GetInstance().DeserializeObject <UserData>(sqReader.GetString(sqReader.GetOrdinal("Data"))); user.AreaFood.Num = sqReader.GetInt32(sqReader.GetOrdinal("AreaFoodNum")); user.AreaFood.Num = user.AreaFood.Num > user.AreaFood.MaxNum ? user.AreaFood.MaxNum : user.AreaFood.Num; if (user.AreaFood.Num < user.AreaFood.MaxNum) { eatNum = user.AreaFood.MaxNum - user.AreaFood.Num; eatNum = eatNum <= num ? eatNum : num; user.AreaFood.Num += eatNum; num -= eatNum; if (num > 0) { //减掉吃掉的干粮辎重 db.ExecuteQuery("update BagTable set Num = " + num + " where Id = " + id); } else { //删除干粮辎重 db.ExecuteQuery("delete from BagTable where Id = " + id); } //更新当前干粮 db.ExecuteQuery("Update UserDatasTable set Data = '" + JsonManager.GetInstance().SerializeObjectDealVector(user) + "', AreaFoodNum = " + user.AreaFood.Num + " where Id = " + userDataId); AreaMainPanelCtrl.MakeUpdateFoods(user.AreaFood.Num); } else { AlertCtrl.Show("目前体力充沛不需要进食!"); } } db.CloseSqlConnection(); if (eatNum > 0) { Statics.CreatePopMsg(Vector3.zero, string.Format("补充了{0}个干粮", eatNum), Color.green, 30); GetBagPanelData(); } }
/// <summary> /// 结交侠客 /// </summary> /// <param name="id">Identifier.</param> public void InviteRole(int id) { bool invited = false; RoleData role = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleId, State from RolesTable where Id = " + id); if (sqReader.Read()) { role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", sqReader.GetString(sqReader.GetOrdinal("RoleId"))); RoleStateType state = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State")); if (state == RoleStateType.NotRecruited) { sqReader = db.ExecuteQuery("select * from WeaponsTable where WeaponId = '" + role.ResourceWeaponDataId + "' and BeUsingByRoleId == '' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { //删掉兵器 db.ExecuteQuery("delete from WeaponsTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); //结交侠客 db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + ", SeatNo = 888 where Id = " + id); invited = true; } else { AlertCtrl.Show("你的兵器匣里并没有称手的兵器!", null); } } else { AlertCtrl.Show("你们已经结识!", null); } } db.CloseSqlConnection(); if (invited && role != null) { Statics.CreatePopMsg(Vector3.zero, string.Format("你与<color=\"#FFFF00\">{0}</color>撮土为香,结成八拜之交!", role.Name), Color.white, 30); GetRolesOfWinShopPanelData(role.HometownCityId); } }
/// <summary> /// 使用物品 /// </summary> /// <param name="Id">Identifier.</param> public void UseItem(int id) { db = OpenDb(); string itemId = ""; ItemType type = ItemType.None; int num = 0; SqliteDataReader sqReader = db.ExecuteQuery("select ItemId, Type, Num from BagTable where Id = " + id); if (sqReader.Read()) { itemId = sqReader.GetString(sqReader.GetOrdinal("ItemId")); type = (ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type")); num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); } db.CloseSqlConnection(); if (type != ItemType.None && num > 0) { ItemData item; switch (type) { case ItemType.Food: Eat(id, num); break; case ItemType.Weapon: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); if (AddNewWeapon(item.StringValue, "")) { WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", item.StringValue); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); //删除兵器盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); } else { AlertCtrl.Show("兵器匣已满,请先整理兵器匣"); } break; case ItemType.Book: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); BookData book = JsonManager.GetInstance().GetMapping <BookData>("Books", item.StringValue); if (AddNewBook(item.StringValue, "")) { Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30); //删除秘籍盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); } else { AlertCtrl.Show(string.Format("你已经习得<color=\"{0}\">{1}</color>, 无需再研读", Statics.GetQualityColorString(book.Quality), book.Name)); } break; default: AlertCtrl.Show("该物品不可使用!"); break; } } }
/// <summary> /// 出售背包中的物品 /// </summary> /// <param name="ids">Identifiers.</param> public void SellItems(JArray ids) { List <ItemData> items = new List <ItemData>(); 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"))); if (item.SellPrice >= 0) { item.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); item.Num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); items.Add(item); } } //检查前端传递过来的选中的物品id是否合法 int id; ItemData findItem; double addSilverNum = 0; double silverNum = 0; string queryStr = ""; for (int i = 0; i < ids.Count; i++) { id = (int)ids[i]; findItem = items.Find(find => find.PrimaryKeyId == id); if (findItem != null) { addSilverNum += findItem.SellPrice * findItem.Num; queryStr += (i > 0 ? "or " : "" + ("Id = " + id)); } } //删除选中的物品 if (queryStr != "") { db.ExecuteQuery("delete from BagTable where " + queryStr); } //添加银子到资源 sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; if (sqReader.Read()) { resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData"))); //查询目前的银子余额 ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver); if (resource != null) { resource.Num += addSilverNum; silverNum = resource.Num; //加钱 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } } db.CloseSqlConnection(); Messenger.Broadcast <double>(NotifyTypes.SellItemsEcho, silverNum); Statics.CreatePopMsg(Vector3.zero, string.Format("{0} {1}", Statics.GetResourceName(ResourceType.Silver), "+" + addSilverNum.ToString()), Color.green, 30); }
/// <summary> /// Scenes the notify init. /// </summary> public static void AreaNotifyInit() { Messenger.AddListener <AreaTarget, AreaMain>(NotifyTypes.AreaInit, (target, main) => { AreaModel.CurrentTarget = target; AreaModel.AreaMainScript = main; //加载动态事件列表 Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName); //打开大地图UI交互界面 Messenger.Broadcast(NotifyTypes.CallAreaMainPanelData); //如果当前所处的位置是城镇,则进入城镇 if (UserModel.CurrentUserData.PositionStatu == UserPositionStatusType.InCity) { Messenger.Broadcast <string>(NotifyTypes.EnterCityScene, UserModel.CurrentUserData.CurrentCitySceneId); } }); Messenger.AddListener(NotifyTypes.AreaDestroyed, () => { if (AreaModel.CurrentTarget != null && AreaModel.CurrentTarget.gameObject != null) { MonoBehaviour.Destroy(AreaModel.CurrentTarget.gameObject); AreaModel.CurrentTarget = null; } Messenger.Broadcast(NotifyTypes.HideAreaMainPanel); }); Messenger.AddListener(NotifyTypes.CallAreaMainPanelData, () => { Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.CallUserData, (userData) => { Messenger.Broadcast <JArray>(NotifyTypes.CallAreaMainPanelDataEcho, new JArray(userData.AreaFood.IconId, userData.AreaFood.Num, userData.AreaFood.MaxNum, userData.CurrentAreaSceneName)); Vector2 pos = new Vector2(userData.CurrentAreaX, userData.CurrentAreaY); Messenger.Broadcast <Vector2, bool>(NotifyTypes.SetAreaPosition, pos, false); }); }); Messenger.AddListener <JArray>(NotifyTypes.CallAreaMainPanelDataEcho, (data) => { AreaMainPanelCtrl.Show(data); Messenger.Broadcast(NotifyTypes.MakeUpdateProps); }); Messenger.AddListener(NotifyTypes.MakeUpdateProps, () => { AreaMainPanelCtrl.MakeUpdateProps(DbManager.Instance.GetAllProps()); }); Messenger.AddListener <PropType, int>(NotifyTypes.AddProp, (type, num) => { DbManager.Instance.AddProp(type, num); Messenger.Broadcast(NotifyTypes.MakeUpdateProps); }); Messenger.AddListener <PropType, int>(NotifyTypes.UseProp, (type, num) => { DbManager.Instance.UseProp(type, num); }); Messenger.AddListener(NotifyTypes.HideAreaMainPanel, () => { AreaMainPanelCtrl.Hide(); }); Messenger.AddListener <string, bool>(NotifyTypes.MoveOnArea, (direction, duringMove) => { //如果触发战斗则禁止移动 if (BattleFightPanelCtrl.Ctrl != null || !AreaModel.CurrentTarget.CanTriggerEvent()) { return; } //移动前先判断移动目的地是否有战斗 Vector2 nextMovePosition = AreaModel.CurrentTarget.GetNextMovePosition(direction); //判断前方是否是障碍 tk2dRuntime.TileMap.TileInfo groundTile = AreaModel.CurrentTarget.GetTileInfo((int)nextMovePosition.x, (int)nextMovePosition.y, 0); //判断禁止通过的碰撞区域 if (groundTile == null || groundTile.stringVal == "obstacle") { Statics.CreatePopMsg(Vector3.zero, "撞到墙上了,请绕行", Color.white, 30); return; } string fightEventId = string.Format("{0}_{1}_{2}", UserModel.CurrentUserData.CurrentAreaSceneName, (int)nextMovePosition.x, (int)nextMovePosition.y); EventData data; if (AreaMain.ActiveAreaEventsMapping.ContainsKey(fightEventId)) { data = AreaMain.ActiveAreaEventsMapping[fightEventId]; if (data.Type == SceneEventType.Battle) { ConfirmCtrl.Show("前方将有恶战,是否继续?", () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.EventId); }, null, "动手", "撤退"); return; } } else if (AreaMain.StaticAreaEventsMapping.ContainsKey(fightEventId)) { //判断静态事件是否禁用 if (!AreaMain.DisableEventIdMapping.ContainsKey(fightEventId)) { data = AreaMain.StaticAreaEventsMapping[fightEventId]; if (data.Type == SceneEventType.Battle) { ConfirmCtrl.Show("前方将有恶战,是否继续?", () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.EventId); //处理静态事件的预禁用操作 EventData disableEvent = new EventData(); disableEvent.Id = fightEventId; disableEvent.Type = SceneEventType.DisableEvent; disableEvent.X = (int)nextMovePosition.x; disableEvent.Y = (int)nextMovePosition.y; Messenger.Broadcast <EventData>(NotifyTypes.HandleDisableEvent, disableEvent); }, null, "动手", "撤退"); return; } if (data.Type == SceneEventType.Pagoda) { ConfirmCtrl.Show("前方有守卫,是否继续?", () => { string eventId = data.EventId; if (eventId == "10310020") { //处理金兀术难度选择后战斗id的变化 int difficulty = PlayerPrefs.GetInt("TowerDifficulty"); switch (difficulty) { case 1: eventId = "10310021"; break; case 2: eventId = "10310022"; break; default: break; } } Messenger.Broadcast <string>(NotifyTypes.CreateBattle, eventId); //处理静态事件的预禁用操作 EventData disableEvent = new EventData(); disableEvent.Id = fightEventId; disableEvent.EventId = eventId; disableEvent.Type = SceneEventType.DisablePagoda; disableEvent.X = (int)nextMovePosition.x; disableEvent.Y = (int)nextMovePosition.y; Messenger.Broadcast <EventData>(NotifyTypes.HandleDisableEvent, disableEvent); }, null, "动手", "撤退"); return; } else if (data.OpenType != SceneEventOpenType.None) { //静态事件有一个开启判定类型 switch (data.OpenType) { case SceneEventOpenType.FightWined: if (!DbManager.Instance.IsFightWined(data.OpenKey)) { ConfirmCtrl.Show(string.Format("前方有强敌守卫,是否硬闯?{0}", data.Notice), () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.OpenKey); }, null, "动手", "撤退"); return; } break; case SceneEventOpenType.NeedItem: if (DbManager.Instance.GetUsedItemNumByItemId(data.OpenKey) <= 0) { ItemData item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", data.OpenKey); if (DbManager.Instance.GetItemNumByItemId(data.OpenKey) > 0) { ConfirmCtrl.Show(string.Format("需要交出 <color=\"#1ABDE6\">{0}</color> 才能通过", item.Name), () => { if (DbManager.Instance.CostItemFromBag(data.OpenKey, 1)) { DbManager.Instance.UpdateUsedItemRecords(data.OpenKey, 1); AlertCtrl.Show(string.Format("交出了 <color=\"#1ABDE6\">{0}</color>", item.Name)); } }, null, "给", "不给"); } else { AlertCtrl.Show(string.Format("行囊里没有<color=\"#1ABDE6\">{0}</color>,不能过去!{1}", item.Name, data.Notice)); } return; } break; case SceneEventOpenType.NeedTasks: if (!string.IsNullOrEmpty(data.StringValue)) { string[] taskIds = data.StringValue.Split(new char[] { '|' }); if (!DbManager.Instance.HasAnyTask(taskIds)) { AlertCtrl.Show(string.Format("前方暂时无法通过!\n<color=\"#00FF00\">{0}</color>", data.Notice)); return; } } break; default: break; } } } } //判定体力是否足够移动 DbManager.Instance.MoveOnArea(direction, duringMove); // Messenger.Broadcast<string, int, bool>(NotifyTypes.MoveOnAreaEcho, direction, 666, duringMove); }); Messenger.AddListener <string, int, bool>(NotifyTypes.MoveOnAreaEcho, (direction, foodsNum, duringMove) => { if (foodsNum > 0) { AreaMainPanelCtrl.MakeArrowShow(direction, foodsNum); Vector2 pos = AreaModel.CurrentTarget.Move(direction, foodsNum > 0, duringMove); AreaMainPanelCtrl.MakeSetPosition(pos); } else { if (UserModel.CurrentRebornTimes >= UserModel.MaxRebornTimes) { AlertCtrl.Show("干粮耗尽, 先回城镇休整", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); } else { // ConfirmCtrl.Show(string.Format("干粮耗尽,您愿意观看一段视频获得{0}点体力吗?\n(复活次数:{1}/{2})", UserModel.CurrentFoodNums / 2, UserModel.MaxRebornTimes - UserModel.CurrentRebornTimes, UserModel.MaxRebornTimes), () => { // MaiHandler.StartRewardedVideo(() => { // UserModel.CurrentFoodNums = UserModel.CurrentFoodNums / 2; // UserModel.CurrentRebornTimes++; // Messenger.Broadcast<int>(NotifyTypes.EatFood, UserModel.CurrentFoodNums); // }); // MaiHandler.SendEvent("StartRewardedVideoForFoods", DbManager.Instance.HostData.Lv.ToString()); // }, () => { // Messenger.Broadcast(NotifyTypes.BackToCity); // }, "观看", "不了"); ConfirmCtrl.Show(string.Format("干粮耗尽,您愿意花费5000两银子获得{0}点体力吗?\n(复活次数:{1}/{2})", UserModel.CurrentFoodNums / 2, UserModel.MaxRebornTimes - UserModel.CurrentRebornTimes, UserModel.MaxRebornTimes), () => { if (DbManager.Instance.CostSilver(5000)) { UserModel.CurrentFoodNums = UserModel.CurrentFoodNums / 2; UserModel.CurrentRebornTimes++; Messenger.Broadcast <int>(NotifyTypes.EatFood, UserModel.CurrentFoodNums); } else { AlertCtrl.Show("银两不足, 先回城镇休整", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); } MaiHandler.SendEvent("StartRewardedVideoForFoods", DbManager.Instance.HostData.Lv.ToString()); }, () => { Messenger.Broadcast(NotifyTypes.BackToCity); }, "花钱", "不了"); } BattleFightPanelCtrl.Hide(); //强制退出战斗 } }); Messenger.AddListener <Vector2, bool>(NotifyTypes.SetAreaPosition, (pos, doEvent) => { AreaMainPanelCtrl.MakeSetPosition(pos); if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.SetPosition(pos, doEvent); } }); Messenger.AddListener <string>(NotifyTypes.GetActiveEventsInArea, (sceneId) => { DbManager.Instance.GetActiveEventsInArea(sceneId); }); Messenger.AddListener <List <EventData> >(NotifyTypes.GetActiveEventsInAreaEcho, (events) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.UpdateActiveAreaEventsData(events); AreaModel.AreaMainScript.RefreshActiveAreaEventsView(); } }); Messenger.AddListener <EventData>(NotifyTypes.HandleDisableEvent, (ev) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.HandleDisableEvent(ev); } }); Messenger.AddListener <bool>(NotifyTypes.ReleaseDisableEvent, (win) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.ReleaseDisableEvent(win); } }); Messenger.AddListener <string, EventData>(NotifyTypes.PushDisableEvent, (eventId, eventData) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.PushDisableEvent(eventId, eventData); } }); Messenger.AddListener <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, (excepts) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.ClearDisableEventIdMapping(excepts); } }); Messenger.AddListener <int>(NotifyTypes.EatFood, (num) => { int eatNum = DbManager.Instance.EatFood(num); AlertCtrl.Show(string.Format("打开包袱发现<color=\"#00FF00\">{0}个干粮</color>{1}", num, eatNum != num ? "\n你的行囊只装得下<color=\"#FF0000\">" + eatNum + "个</color>" : "")); }); }
/// <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); //刷新队伍数据 }
void onClick(GameObject e) { if (Time.fixedTime - date <= timeout) { return; } switch (e.name) { case "SureBtn": case "Block": Back(); break; case "ResetBtn": ConfirmCtrl.Show("是否打开塔内重置机关?\n<color=\"#ff0000\">[重置后塔内守卫将会重生]</color>", () => { Messenger.Broadcast <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, null); Statics.CreatePopMsg(Vector3.zero, "通天塔内守卫全部重生!", Color.red, 30); }); break; case "difficultyBtn0": if (difficultyBtns[0].enabled) { ConfirmCtrl.Show("是否激活普通强度?", () => { if (DbManager.Instance.CostSilver(10000)) { PlayerPrefs.SetInt("TowerDifficulty", 0); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "普通的量子强度被激活", Color.white, 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; case "difficultyBtn1": if (difficultyBtns[1].enabled) { ConfirmCtrl.Show("是否激活噩梦强度?\n(4倍修为)", () => { if (DbManager.Instance.CostSilver(180000)) { PlayerPrefs.SetInt("TowerDifficulty", 1); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "噩梦的量子强度被激活", new Color(0.93f, 1, 0.33f), 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; case "difficultyBtn2": if (difficultyBtns[2].enabled) { ConfirmCtrl.Show("是否激活绝望强度?\n(8倍修为)", () => { if (DbManager.Instance.CostSilver(980000)) { PlayerPrefs.SetInt("TowerDifficulty", 2); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "绝望的量子强度被激活", new Color(0.98f, 0.26f, 0.26f), 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; default: break; } }
/// <summary> /// 使用物品 /// </summary> /// <param name="Id">Identifier.</param> public void UseItem(int id) { db = OpenDb(); string itemId = ""; ItemType type = ItemType.None; int num = 0; SqliteDataReader sqReader = db.ExecuteQuery("select ItemId, Type, Num from BagTable where Id = " + id); if (sqReader.Read()) { itemId = sqReader.GetString(sqReader.GetOrdinal("ItemId")); type = (ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type")); num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); } db.CloseSqlConnection(); if (type != ItemType.None && num > 0) { ItemData item; switch (type) { case ItemType.Food: if (UserModel.CurrentUserData.PositionStatu == UserPositionStatusType.InArea) { Eat(id, num); SoundManager.GetInstance().PushSound("ui0004"); } else { AlertCtrl.Show("野外闯荡江湖时才能吃干粮"); } break; case ItemType.Weapon: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); if (AddNewWeapon(item.StringValue, "")) { WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", item.StringValue); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); //删除兵器盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); SoundManager.GetInstance().PushSound("ui0004"); } else { AlertCtrl.Show("兵器匣已满,请先整理兵器匣"); } break; case ItemType.Book: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); BookData book = JsonManager.GetInstance().GetMapping <BookData>("Books", item.StringValue); if (AddNewBook(item.StringValue, "")) { Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30); //删除秘籍盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); SoundManager.GetInstance().PushSound("ui0004"); } else { AlertCtrl.Show(string.Format("你已经习得<color=\"{0}\">{1}</color>, 无需再研读", Statics.GetQualityColorString(book.Quality), book.Name)); } break; case ItemType.RandomSecre: //打开随机诀要锦囊 item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); db = OpenDb(); sqReader = db.ExecuteQuery("select count(*) as num from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "'"); bool isSecretsFull = false; if (sqReader.Read()) { isSecretsFull = sqReader.GetInt32(sqReader.GetOrdinal("num")) >= MaxSecretNumOfBag; } if (!isSecretsFull) { //添加新的诀要 SecretData secret = Statics.CreateNewSecret(Statics.GetRandomSecretType(item.StringValue), QualityType.White); db.ExecuteQuery("insert into BookSecretsTable (SecretData, T, Q, BelongToBookId, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secret)) + "', " + ((short)secret.Type) + ", " + ((short)secret.Quality) + ", '', '" + currentRoleId + "')"); PlayerPrefs.SetString("AddedNewBookFlag", "true"); PlayerPrefs.SetString("AddedNewSecretFlag", "true"); Messenger.Broadcast(NotifyTypes.MakeRoleInfoPanelRedPointRefresh); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(secret.Quality), secret.Name), Color.white, 30); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); SoundManager.GetInstance().PushSound("ui0004"); } else { AlertCtrl.Show(string.Format("诀要背包上限为{0},请先清理背包", MaxSecretNumOfBag)); } break; default: AlertCtrl.Show("该物品不可使用!"); break; } } }
/// <summary> /// Battles the notify init. /// </summary> public static void BattleNotifyInit() { Messenger.AddListener <string>(NotifyTypes.CreateBattle, (fightId) => { if (BattleFightPanelCtrl.Ctrl != null) { Statics.CreatePopMsg(Vector3.zero, "已在战斗中", Color.white, 30); return; } //获取队伍角色列表 // RoleData currentRoleData = RoleInfoPanelCtrl.GetCurrentRoleData(); RoleData currentRoleData = DbManager.Instance.GetHostRoleData(); if (currentRoleData == null) { return; } currentRoleData.MakeJsonToModel(); if (currentRoleData.Injury == InjuryType.Moribund) { AlertCtrl.Show("你已奄奄一息无法再战!", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); return; } //获取战斗数据 // FightData fightData = new FightData(); // fightData.Id = fightId; // fightData.Type = FightType.Normal; // RoleData enemy0 = new RoleData(); // enemy0.Id = "enemy0"; // enemy0.Name = "赏金刺客"; // enemy0.HalfBodyId = "enemy000001"; // BookData book0 = new BookData(); // book0.Id = "book20001"; // book0.Name = "地痞撒泼"; // book0.IconId = "200000"; // SkillData skill0 = new SkillData(); // skill0.Type = SkillType.MagicAttack; // skill0.Name = "背负投"; // BuffData buff0 = new BuffData(); // buff0.Type = BuffType.Vertigo; //// buff0.Value = 8888; //// buff0.FirstEffect = true; // buff0.RoundNumber = 3; // buff0.Rate = 30; // buff0.FirstEffect = true; // skill0.DeBuffDatas.Add(buff0); // SkillData skill1 = new SkillData(); // skill1.Type = SkillType.PhysicsAttack; // skill1.Name = "抱摔"; // SkillData skill2 = new SkillData(); // skill2.Type = SkillType.PhysicsAttack; // skill2.Name = "撕咬"; // book0.Skills.Add(skill0); // book0.Skills.Add(skill1); // book0.Skills.Add(skill2); // enemy0.Books.Add(book0); // enemy0.AttackSpeed = 2; // enemy0.HP = 10000; // enemy0.MaxHP = 10000; // WeaponData weapon5 = new WeaponData(); // weapon5.Id = "weapon5"; // weapon5.Id = "阔刃刀"; // weapon5.Width = 360; // weapon5.Rates = new float[] { 1, 0.6f, 0.2f, 0.1f }; // enemy0.Weapon = weapon5; // fightData.Enemys = new List<RoleData>() { // enemy0 // }; // List<RoleData> teams = RoleInfoPanelCtrl.GetRoleDatas(); List <RoleData> teams = DbManager.Instance.GetRolesInTeam(); List <List <SecretData> > secrets = new List <List <SecretData> >(); for (int i = 0, len = teams.Count; i < len; i++) { if (teams[i].IsHost) { WeaponLVData weaponLvData = DbManager.Instance.GetWeaponLV(teams[i].ResourceWeaponDataId); teams[i].CurrentWeaponLV = weaponLvData.LV; } teams[i].MakeJsonToModel(); secrets.Add(DbManager.Instance.GetSecretsBelongBooks(teams[i].ResourceBookDataIds)); } FightData fightData = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId); fightData.MakeJsonToModel(); Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); SoundManager.GetInstance().PauseBGM(); SoundManager.GetInstance().PushSound("ui0003"); Messenger.Broadcast <System.Action, System.Action>(NotifyTypes.PlayCameraVortex, () => { // BattleMainPanelCtrl.Show(currentRoleData, fightData); List <ItemData> drugs = new List <ItemData>(); // drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100001")); // drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100002")); // drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100003")); List <ItemData> allVulnerary = DbManager.Instance.GetItems(ItemType.Drug); for (int i = 0; i < 3; i++) { if (allVulnerary.Count > i) { drugs.Add(allVulnerary[i]); } else { break; } } //处理通天塔量子强度影响的敌人成长率 if (UserModel.CurrentUserData.CurrentAreaSceneName == "Area31") { int difficulty = PlayerPrefs.GetInt("TowerDifficulty"); float growUp; switch (difficulty) { case 0: default: growUp = 1; break; case 1: growUp = 2; break; case 2: growUp = 4; break; } for (int i = 0, len = fightData.Enemys.Count; i < len; i++) { fightData.Enemys[i].SetGrowUp(growUp); } } BattleFightPanelCtrl.Show(fightData, teams, secrets, fightData.Enemys, drugs, DbManager.Instance.GetProp(PropType.LimePowder)); PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, fightId); }, () => { // Messenger.Broadcast<bool>(NotifyTypes.CallRoleInfoPanelData, true); }); }); Messenger.AddListener <List <RoleData>, string>(NotifyTypes.CreateTestBattle, (roles, fightId) => { // List<List<SecretData>> secrets = new List<List<SecretData>>(); // for (int i = 0, len = roles.Count; i < len; i++) { // secrets.Add(DbManager.Instance.GetSecretsBelongBooks(roles[i].ResourceBookDataIds)); // } TextAsset asset = Resources.Load <TextAsset>("Data/Json/TestSecrets"); List <List <SecretData> > secrets = PlayerPrefs.GetString("FightEditorUseSecret") == "true" ? JsonManager.GetInstance().DeserializeObject <List <List <SecretData> > >(asset.text) : new List <List <SecretData> >(); FightData fightData = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId); fightData.MakeJsonToModel(); // BattleMainPanelCtrl.Show(currentRoleData, fightData); List <ItemData> drugs = new List <ItemData>(); drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100001")); drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100002")); drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100003")); for (int i = 0, len = fightData.Enemys.Count; i < len; i++) { fightData.Enemys[i].SetGrowUp(PlayerPrefs.GetFloat("FightEditorTestGroupUp")); } BattleFightPanelCtrl.Show(fightData, roles, secrets, fightData.Enemys, drugs, DbManager.Instance.GetProp(PropType.LimePowder)); }); Messenger.AddListener <bool, List <DropData>, FightData>(NotifyTypes.EndBattle, (win, drops, fightData) => { if (!win) { MaiHandler.SendEvent("FightFail", DbManager.Instance.HostData.Lv.ToString(), fightData.Id); } // Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); Messenger.Broadcast <System.Action, System.Action>(NotifyTypes.PlayCameraVortex, () => { //如果普通战斗失败则回之前到过的城镇去疗伤 if (fightData.Type == FightType.Normal && !win) { AlertCtrl.Show("江湖凶险, 稍事休息后再出发!", () => { Messenger.Broadcast(NotifyTypes.BackToCity); PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, ""); }); } else { PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, ""); } // BattleMainPanelCtrl.Hide(); BattleFightPanelCtrl.Hide(); }, () => { //任务详情界面打开时不呼出角色信息板 if (TaskDetailInfoPanelCtrl.Ctrl == null) { Messenger.Broadcast <bool>(NotifyTypes.CallRoleInfoPanelData, false); } Messenger.Broadcast(NotifyTypes.PlayBgm); if (drops.Count > 0) { Messenger.Broadcast <List <DropData> >(NotifyTypes.ShowDropsListPanel, drops); } if (fightData.Type == FightType.Task) { Messenger.Broadcast(NotifyTypes.ReloadTaslDetailInfoData); if (win) { Messenger.Broadcast <string>(NotifyTypes.MakeFightWinedBtnDisable, fightData.Id); } } }); }); Messenger.AddListener <RoleData>(NotifyTypes.ChangeCurrentTeamRoleInBattle, (roleData) => { BattleMainPanelCtrl.ChangeCurrentTeamRole(roleData); }); Messenger.AddListener <int>(NotifyTypes.ChangeCurrentTeamBookInBattle, (index) => { BattleMainPanelCtrl.ChangeCurrentTeamBook(index); }); Messenger.AddListener <JArray, List <BookData> >(NotifyTypes.SendFightResult, (data, books) => { DbManager.Instance.SendFightResult((bool)data[0], data[1].ToString(), (int)data[2], (int)data[5], books, (float)data[6]); JArray usedSkillIdData = (JArray)data[3]; JArray d; for (int i = 0; i < usedSkillIdData.Count; i++) { d = (JArray)usedSkillIdData[i]; DbManager.Instance.UpdateUsedTheSkillRecords(d[0].ToString(), (int)d[1]); } JArray plusIndexData = (JArray)data[4]; for (int i = 0; i < plusIndexData.Count; i++) { d = (JArray)plusIndexData[i]; DbManager.Instance.UpdateWeaponPowerPlusSuccessedRecords((int)d[0], (int)d[1]); } }); Messenger.AddListener <bool, List <DropData>, FightData>(NotifyTypes.SendFightResultEcho, (win, drops, fightData) => { //加载动态事件列表 Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName); Messenger.Broadcast <bool, List <DropData>, FightData>(NotifyTypes.EndBattle, win, drops, fightData); }); Messenger.AddListener(NotifyTypes.BackToCity, () => { string eventId = JsonManager.GetInstance().GetMapping <string>("AreaCityPosDatas", UserModel.CurrentUserData.CurrentCitySceneId); string[] fen = eventId.Split(new char[] { '_' }); if (fen.Length >= 3) { string areaName = fen[0]; int x = int.Parse(fen[1]); int y = int.Parse(fen[2]); if (UserModel.CurrentUserData != null) { UserModel.CurrentUserData.PositionStatu = UserPositionStatusType.InCity; UserModel.CurrentUserData.CurrentAreaSceneName = areaName; UserModel.CurrentUserData.CurrentAreaX = x; UserModel.CurrentUserData.CurrentAreaY = y; Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, null); Messenger.Broadcast <string>(NotifyTypes.GoToScene, areaName); } } }); Messenger.AddListener(NotifyTypes.BattleFaild, () => { BattleMainPanelCtrl.MakeFaild(); }); Messenger.AddListener <string>(NotifyTypes.MakePopRole, (dieRoleId) => { RoleInfoPanelCtrl.MakePopRole(dieRoleId); }); }
/// <summary> /// 添加掉落物到背包 /// </summary> /// <returns>The item to bag.</returns> /// <param name="drops">Drops.</param> public List <DropData> PushItemToBag(List <DropData> drops, bool withoutNumLimit = false, float makeAFortuneRate = 0) { int bagNumLeft = GetItemNumLeftInBag(); List <DropData> resultDrops = new List <DropData>(); db = OpenDb(); SqliteDataReader sqReader; DropData drop; int num; int maxNum; int addNum; bool isSecretsFull; for (int i = 0; i < drops.Count; i++) { drop = drops[i]; if (drop.Item == null) { drop.MakeJsonToModel(); } if (drop.Item.Type == ItemType.Task) { //判断是否为任务物品,任务物品在使用过后就不再掉落 sqReader = db.ExecuteQuery("select * from UsedItemRecordsTable where ItemId = '" + drop.Item.Id + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.HasRows) { continue; } } //背包位子如果不足则除了任务物品之外,其他的物品都不能添加进背包 //诀要也不受背包满限制 if (!withoutNumLimit && bagNumLeft <= 0) { if (drop.Item.Type != ItemType.Task && drop.Item.Type != ItemType.Book && drop.Item.Type < ItemType.SecretIncreaseMaxHP) { Statics.CreatePopMsg(Vector3.zero, string.Format("背包满了,{0}不能拾取", drop.Item.Name), Color.red, 30); continue; } } //判断是否掉落 if (!drop.IsTrigger(makeAFortuneRate)) { continue; } if (drop.Item.Type < ItemType.SecretIncreaseMaxHP) { //查询背包里是否有物品以及物品的数量是否达到上限 sqReader = db.ExecuteQuery("select * from BagTable where ItemId = '" + drop.Item.Id + "' and Num < MaxNum and BelongToRoleId = '" + currentRoleId + "'"); if (!sqReader.HasRows) { //添加新的物品 db.ExecuteQuery("insert into BagTable (ItemId, Type, Num, MaxNum, Lv, BelongToRoleId) values('" + drop.Item.Id + "', " + ((int)drop.Item.Type) + ", " + drop.Item.Num + ", " + drop.Item.MaxNum + ", " + drop.Item.Lv + ", '" + currentRoleId + "')"); } else { int itemNum = drop.Item.Num; //修改物品的数量 while (sqReader.Read()) { num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); maxNum = sqReader.GetInt32(sqReader.GetOrdinal("MaxNum")); addNum = (maxNum - num) <= itemNum ? (maxNum - num) : itemNum; itemNum -= addNum; db.ExecuteQuery("update BagTable set Num = " + (num + addNum) + " where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); //如果掉落物的数量还有则下个循环继续处理添加物品 if (itemNum > 0) { i--; } } } resultDrops.Add(drop); //任务物品不算入背包占位数 if (!withoutNumLimit && drop.Item.Type != ItemType.Task) { bagNumLeft--; } } else { //处理诀要 sqReader = db.ExecuteQuery("select count(*) as num from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "'"); isSecretsFull = false; if (sqReader.Read()) { isSecretsFull = sqReader.GetInt32(sqReader.GetOrdinal("num")) >= MaxSecretNumOfBag; } if (!isSecretsFull) { //添加新的诀要 SecretData secret = Statics.CreateNewSecret(Statics.ChangeItemTypeToSecretType(drop.Item.Type), QualityType.White); db.ExecuteQuery("insert into BookSecretsTable (SecretData, T, Q, BelongToBookId, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secret)) + "', " + ((short)secret.Type) + ", " + ((short)secret.Quality) + ", '', '" + currentRoleId + "')"); resultDrops.Add(drop); PlayerPrefs.SetString("AddedNewBookFlag", "true"); PlayerPrefs.SetString("AddedNewSecretFlag", "true"); } else { Statics.CreatePopMsg(Vector3.zero, string.Format("诀要背包上限为{0},请先清理背包", MaxSecretNumOfBag), Color.red, 30); } } } db.CloseSqlConnection(); if (resultDrops.Count > 0) { PlayerPrefs.SetString("AddedNewItemFlag", "true"); } return(resultDrops); }
/// <summary> /// 研读秘籍 /// </summary> /// <param name="id">Identifier.</param> public void ReadBook(int id) { bool read = false; BookData book = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select BookId from BooksTable where Id = " + id); if (sqReader.Read()) { book = JsonManager.GetInstance().GetMapping <BookData>("Books", sqReader.GetString(sqReader.GetOrdinal("BookId"))); if (book.Occupation == OccupationType.None || book.Occupation == HostData.Occupation) { bool enough = true; string msg = ""; CostData cost; ItemData item; //计算需要的物品是否足够 for (int i = 0; i < book.Needs.Count; i++) { cost = book.Needs[i]; item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", cost.Id); sqReader = db.ExecuteQuery("select Num from BagTable where ItemId = '" + cost.Id + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { if (sqReader.GetInt32(sqReader.GetOrdinal("Num")) < cost.Num) { enough = false; msg = string.Format("行囊里的{0}不够", item.Name); break; } } else { enough = false; msg = string.Format("行囊里并不曾见过有{0}", item.Name); break; } } if (enough) { int num; //扣除物品 for (int i = 0; i < book.Needs.Count; i++) { cost = book.Needs[i]; sqReader = db.ExecuteQuery("select Id, Num from BagTable where ItemId = '" + cost.Id + "' and BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { num = sqReader.GetInt32(sqReader.GetOrdinal("Num")) - cost.Num; num = num < 0 ? 0 : num; if (num > 0) { db.ExecuteQuery("update BagTable set Num = " + num + " where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } else { db.ExecuteQuery("delete from BagTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } } } //研读秘籍 db.ExecuteQuery("update BooksTable set State = " + ((int)BookStateType.Read) + ", SeatNo = 888 where Id = " + id); read = true; } else { AlertCtrl.Show(msg, null); } } else { AlertCtrl.Show(string.Format("非{0}弟子不得研习<color=\"{1}\">{2}</color>!", Statics.GetOccupationName(book.Occupation), Statics.GetQualityColorString(book.Quality), book.Name)); } } db.CloseSqlConnection(); if (read && book != null) { Statics.CreatePopMsg(Vector3.zero, string.Format("研读<color=\"{0}\">{1}</color>后使你武功精进!", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30); GetBooksOfForbiddenAreaPanelData(book.BelongToCityId); } }
/// <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> public void InviteRoleWithResources(int id) { bool invited = false; RoleData role = null; db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleId, State from RolesTable where Id = " + id); if (sqReader.Read()) { role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", sqReader.GetString(sqReader.GetOrdinal("RoleId"))); RoleStateType state = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State")); if (state == RoleStateType.NotRecruited) { //兵器匣里并没有需要的兵器 WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", role.ResourceWeaponDataId); 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; } } sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int resourceId = 0; if (sqReader.Read()) { resourceId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData"))); } 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(); db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + resourceId); //结交侠客 db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + ", SeatNo = 888 where Id = " + id); invited = true; db.CloseSqlConnection(); } else { AlertCtrl.Show(msg, null); } } } else { AlertCtrl.Show("你们已经结识!", null); } } db.CloseSqlConnection(); if (invited && role != null) { Statics.CreatePopMsg(Vector3.zero, string.Format("你与<color=\"#FFFF00\">{0}</color>撮土为香,结成八拜之交!", role.Name), Color.white, 30); GetRolesOfWinShopPanelData(role.HometownCityId); } }
/// <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); } } }
void dealBattleProcess(BattleProcess process) { freeHeightGrid.PushContext(process.Result); switch (process.Type) { case BattleProcessType.Normal: default: break; case BattleProcessType.EnemyPop: enemyBody.DOFade(0, 0); refreshEnemy(); enemyBody.DOFade(1, 0.45f); state = delayDoing; delayDate = Time.fixedTime; delayTimeout = 0.5f; enemyNumText.text = string.Format("剩余敌人: {0}/{1}", BattleLogic.Instance.EnemysData.Count - BattleLogic.Instance.CurrentEnemy, BattleLogic.Instance.EnemysData.Count); break; case BattleProcessType.Attack: if (process.IsTeam) { refreshEnemyBlood(); dealSkillEffectAndSound("Team", process.Skill); //记录使用过的招式 if (!usedSkillIdMapping.ContainsKey(process.Skill.Id)) { usedSkillIdMapping.Add(process.Skill.Id, 1); } else { usedSkillIdMapping[process.Skill.Id]++; } enemyBody.transform.DOShakePosition(0.25f, 20, 50, 90); } else { refreshTeamBlood(); dealSkillEffectAndSound("Enemy", process.Skill); enemyBody.transform.DOScale(1.5f, 0.15f).SetLoops(2, LoopType.Yoyo); } if (!process.IsMissed) { Statics.CreatePopMsg( process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position, process.HurtedHP > 0 ? ("+" + process.HurtedHP) : process.HurtedHP.ToString(), process.HurtedHP > 0 ? Color.green : Color.red, 40, 0.2f); } else { if (!process.IsIgnoreAttack) { Statics.CreatePopMsg( process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position, "闪避", Color.white, 40, 0.2f); } else { Statics.CreatePopMsg( process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position, "无视伤害", Color.white, 40, 0.2f); } } state = delayDoing; delayDate = Time.fixedTime; delayTimeout = 0.3f; break; case BattleProcessType.Increase: case BattleProcessType.Plus: if (process.IsTeam) { refreshTeamBlood(); dealSkillEffectAndSound("Enemy", process.Skill); } else { refreshEnemyBlood(); } if (process.HurtedHP != 0) { Statics.CreatePopMsg( process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.3f : enemyPoplPos.transform.position + Vector3.up * 0.3f, process.HurtedHP > 0 ? ("+" + process.HurtedHP + "(恢复)") : process.HurtedHP.ToString() + "(流血)", process.HurtedHP > 0 ? Color.green : Color.red, 40, 0.2f); } break; case BattleProcessType.Drug: refreshTeamBlood(); Statics.CreatePopMsg( process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.3f : enemyPoplPos.transform.position + Vector3.up * 0.3f, "+" + process.HurtedHP + "(药)", Color.green, 40, 0.2f); break; case BattleProcessType.ReboundInjury: if (process.IsTeam) { refreshTeamBlood(); } else { refreshEnemyBlood(); } Statics.CreatePopMsg( process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.4f : enemyPoplPos.transform.position + Vector3.up * 0.4f, process.HurtedHP + "(反伤)", Color.red, 40, 0.2f); break; case BattleProcessType.AccidentalInjury: if (process.IsTeam) { refreshTeamBlood(); } else { refreshEnemyBlood(); } Statics.CreatePopMsg( process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.5f : enemyPoplPos.transform.position + Vector3.up * 0.5f, process.HurtedHP + "(误伤)", Color.red, 40, 0.2f); break; } }