public void GetByID_Flow_Skill() { var name = "test"; var skills = new List <Skill> { new Skill { Id = 1, Name = name } }.AsQueryable(); var mockSet = MockHelper.MockDbSet(skills); var result = SkillExtension.GetByName(mockSet.Object, name); Assert.AreEqual(name, result.Name); }
public static void SortSkills() { SpecialFightUi.sortedSkills = new List <Skill>(); List <Skill> list = new List <Skill>(); List <Skill> list2 = new List <Skill>(); List <Skill> list3 = new List <Skill>(); List <Skill> list4 = new List <Skill>(); List <Skill> list5 = new List <Skill>(); foreach (Skill current in App.State.AllSkills) { SkillExtension extension = current.Extension; if (extension.DamagePercent > 0) { list.Add(current); } else if (extension.DodgeChance > 0) { list3.Add(current); } else if (extension.DamageBlock || extension.DamageReflect) { list4.Add(current); } else if (extension.DamageDecreaseDuration > 0L || extension.DamageIncreaseDuration > 0L) { list2.Add(current); } else { list5.Add(current); } } SpecialFightUi.sortedSkills.AddRange(list); SpecialFightUi.sortedSkills.AddRange(list2); SpecialFightUi.sortedSkills.AddRange(list3); SpecialFightUi.sortedSkills.AddRange(list4); SpecialFightUi.sortedSkills.AddRange(list5); }
private void UpdateCurrentMission(IEvent ievent) { var evn = ievent as UIEvent_UpdateCurrentMission; var currentMission = MissionManager.Instance.CurrentMissionData; var tableData = MissionManager.Instance.CurrentMissionTableData; var npcId = MissionManager.Instance.NpcId; var tableCharacter = Table.GetCharacterBase(npcId); if (null != tableCharacter) { var tableNpc = Table.GetNpcBase(tableCharacter.ExdataId); DataModel.NpcName = tableNpc.Name; DataModel.NpcDataId = npcId; } else { DataModel.NpcName = ""; DataModel.NpcDataId = -1; } DataModel.ShowReward = false; var MissionContentDataModelRewardItemCount0 = MissionContentDataModel.RewardItemCount; for (var i = 0; i < MissionContentDataModelRewardItemCount0; i++) { DataModel.RewardItem[i].ItemId = -1; } //无任务,显示对话和服务 if (null == currentMission || null == tableData) { DataModel.MissionId = -1; var tableNpc = Table.GetNpcBase(tableCharacter.ExdataId); if (null != tableNpc) { //显示对话 DataModel.MissionDialogContent = tableNpc.pop[Random.Range(0, tableNpc.pop.Length)]; //显示NPC服务 for (var i = 0; i < tableNpc.Service.Length; i++) { var serviceId = tableNpc.Service[i]; if (-1 != serviceId) { DataModel.ServiceId[i] = serviceId; DataModel.ShowService[i] = true; DataModel.ServiceName[i] = "[u]" + Table.GetService(serviceId).Name + "[/u]"; } else { DataModel.ShowService[i] = false; DataModel.ServiceId[i] = serviceId; } } //任务声音 var soundId = tableNpc.DialogSound; if (-1 != soundId) { SoundManager.Instance.StopSoundEffect(ObjNPC.LastNpcSoundId); if (!SoundManager.Instance.IsPlaying(soundId)) { var isPlayingNpcSound = Table.GetClientConfig(1204); if (int.Parse(isPlayingNpcSound.Value) == 1) { if (!SoundManager.Instance.IsPlaying(ObjNPC.MissionSoundId)) { SoundManager.Instance.PlaySoundEffect(soundId); ObjNPC.LastSoundTime = DateTime.Now; ObjNPC.LastNpcSoundId = soundId; } } } } } } else { //显示任务 //关闭NPC服务 for (var i = 0; i < DataModel.ShowService.Count; i++) { DataModel.ShowService[i] = false; DataModel.ServiceId[i] = -1; } DataModel.MissionId = tableData.Id; const int ExpItemId = 1; var state = (eMissionState)currentMission.Exdata[0]; if (eMissionState.Finished == state) { var playerLevel = Math.Max(1, PlayerDataManager.Instance.GetLevel()); DataModel.MissionDialogContent = GameUtils.GetDictionaryText(tableData.DialogueFinish); //data.BtnName = Table.GetDictionary(Resource.Dictrionary.ClaimReward).Desc[1]; DataModel.BtnStr = GameUtils.GetDictionaryText(1031); EventDispatcher.Instance.DispatchEvent(new MissionAutoAcceptEvent(false)); //重置 for (var i = 0; i < DataModel.RewardItem.Count; i++) { DataModel.RewardItem[i].ItemId = -1; } var roleId = PlayerDataManager.Instance.GetRoleId(); var start = 0; //职业奖励 for (var i = 0; i < 2; i++) { if (tableData.RoleRewardId[roleId, i] != -1) { DataModel.RewardItem[start].ItemId = tableData.RoleRewardId[roleId, i]; DataModel.RewardItem[start].Count = tableData.RoleRewardCount[roleId, i]; start++; } } //等级系数经验奖励 if (0 != tableData.IsDynamicExp) { var expCount = GameUtils.CalculateExpByLevel(tableData.DynamicExpRatio, playerLevel); DataModel.RewardItem[start].ItemId = ExpItemId; DataModel.RewardItem[start].Count = expCount; start++; } //普通任务奖励 var DataModelRewardItemCount1 = DataModel.RewardItem.Count - start; for (var i = 0; i < DataModelRewardItemCount1; i++) { if (start >= DataModel.RewardItem.Count) { Logger.Debug("DataModel.RewardItem[{0}] out of index", start); break; } if (-1 == tableData.RewardItem[i]) { continue; } DataModel.RewardItem[start].ItemId = tableData.RewardItem[i]; DataModel.RewardItem[start].Count = SkillExtension.ModifyByLevel(tableData.RewardItemCount[i], playerLevel, 100000000); start++; } DataModel.ShowReward = true; //任务声音 var soundId = tableData.DeliveryTaskMusic; if (-1 != soundId) { SoundManager.Instance.StopSoundEffect(ObjNPC.LastNpcSoundId); if (!SoundManager.Instance.IsPlaying(soundId)) { var isPlayingNpcSound = Table.GetClientConfig(1204); if (int.Parse(isPlayingNpcSound.Value) == 1) { SoundManager.Instance.StopSoundEffect(ObjNPC.MissionSoundId); SoundManager.Instance.PlaySoundEffect(soundId); ObjNPC.LastSoundTime = DateTime.Now; ObjNPC.MissionSoundId = soundId; } } } } else if (eMissionState.Acceptable == state) { DataModel.MissionDialogContent = GameUtils.GetDictionaryText(tableData.DialogueNpc); //data.BtnName = Table.GetDictionary(Resource.Dictrionary.ClaimReward).Desc[1]; DataModel.BtnStr = GameUtils.GetDictionaryText(1032); //任务声音 var soundId = tableData.AcceptTaskMusic; if (-1 != soundId) { SoundManager.Instance.StopSoundEffect(ObjNPC.LastNpcSoundId); if (!SoundManager.Instance.IsPlaying(soundId)) { var isPlayingNpcSound = Table.GetClientConfig(1204); if (int.Parse(isPlayingNpcSound.Value) == 1) { SoundManager.Instance.StopSoundEffect(ObjNPC.MissionSoundId); SoundManager.Instance.PlaySoundEffect(soundId); ObjNPC.LastSoundTime = DateTime.Now; ObjNPC.MissionSoundId = soundId; } } } EventDispatcher.Instance.DispatchEvent(new MissionAutoAcceptEvent(true)); } } }
//检查奖励 public ErrorCodes CheckGift(CharacterController character, eActivationRewardType type, int giftId) { switch (type) { case eActivationRewardType.TableGift: { var tbGift = Table.GetGift(giftId); if (tbGift == null) { return(ErrorCodes.Error_GiftID); } if (character.GetFlag(tbGift.Flag)) { return(ErrorCodes.Error_GiftAlreadyReceive); } switch ((eRewardType)tbGift.Type) { //固定礼包 case eRewardType.GiftBag: { var items = new Dictionary <int, int>(); for (var i = 0; i != 4; ++i) { if (tbGift.Param[i * 2] != -1) { items.modifyValue(tbGift.Param[i * 2], tbGift.Param[i * 2 + 1]); } } return(BagManager.CheckAddItemList(character.mBag, items)); } //在线时长 case eRewardType.OnlineReward: { var times = character.TodayTimes + DateTime.Now.GetDiffSeconds(character.OnlineTime); if (times >= tbGift.Param[0]) { return(character.mBag.CheckAddItem(tbGift.Param[1], tbGift.Param[2])); } return(ErrorCodes.Error_GiftTimeNotEnough); } //等级奖励 case eRewardType.LevelReward: { if (character.GetLevel() >= tbGift.Param[0]) { var items = new Dictionary <int, int>(); for (var i = 1; i <= 5; ++i) { var count = tbGift.Param[i + 5]; if (tbGift.Param[i] != -1) { items.modifyValue(tbGift.Param[i], count); } } return(BagManager.CheckAddItemList(character.mBag, items)); } return(ErrorCodes.Error_LevelNoEnough); } //连续登陆 case eRewardType.ContinuesLoginReward: { var days = character.GetExData(17); if (days < 1) { return(ErrorCodes.Error_GiftTimeNotEnough); } if (days > 5) { days = 5; } var items = new Dictionary <int, int>(); for (var i = 0; i < days; ++i) { var tbGift2 = Table.GetGift(13 + i); if (character.GetFlag(tbGift.Flag)) { continue; } items.modifyValue(tbGift2.Param[1], tbGift2.Param[2]); } return(BagManager.CheckAddItemList(character.mBag, items)); } //累计登陆 case eRewardType.MonthCheckinReward: { var months = DateTime.Now.Month; if (tbGift.Param[0] != 999 && months != tbGift.Param[0]) { return(ErrorCodes.Error_GiftTimeNotEnough); } var days = DateTime.Now.Day; var exdataValue = character.GetExData(tbGift.Exdata); if (exdataValue + 1 != tbGift.Param[1]) { return(ErrorCodes.Unknow); } if (days >= tbGift.Param[1]) { if (character.GetFlag(466)) { //补签 var SupplementCount = character.GetExData(18); var needGold = (int) (tbGift.Param[4] * SkillExtension.Pow(tbGift.Param[5] / 10000.0f, SupplementCount)); needGold = needGold - needGold % 5; if (character.mBag.GetRes(eResourcesType.DiamondRes) < needGold) { return(ErrorCodes.MoneyNotEnough); } return(character.mBag.CheckAddItem(tbGift.Param[2], tbGift.Param[3])); } //签到 return(character.mBag.CheckAddItem(tbGift.Param[2], tbGift.Param[3])); } return(ErrorCodes.Error_GiftTimeNotEnough); } //每日活跃度 case eRewardType.DailyActivity: { if (character.GetExData(tbGift.Exdata) >= 0) { if (character.GetExData(tbGift.Exdata) < tbGift.Param[1]) { return(ErrorCodes.Error_GiftCountNotEnough); } } } break; //每日活跃奖励 case eRewardType.DailyActivityReward: { if (character.GetExData(15) >= tbGift.Param[2]) { return(character.mBag.CheckAddItem(tbGift.Param[0], tbGift.Param[1])); } return(ErrorCodes.Error_ActivityPointNotEnough); } //七天登录奖励 case eRewardType.SevenDayReward: { if (character.GetExData((int)eExdataDefine.e94) < tbGift.Param[0]) { return(ErrorCodes.Error_GiftTimeNotEnough); } if (character.GetFlag(tbGift.Flag)) { return(ErrorCodes.Error_GiftAlreadyReceive); } var items = new Dictionary <int, int>(); for (var i = 0; i != 3; i++) { items.modifyValue(tbGift.Param[i * 2 + 1], tbGift.Param[i * 2 + 2]); } items.modifyValue(tbGift.Param[7], tbGift.Param[8]); return(BagManager.CheckAddItemList(character.mBag, items)); } default: Logger.Warn("Gift[{0}] type is overflow", giftId); break; } } break; case eActivationRewardType.DailyVipGift: { var vipLevel = character.mBag.GetRes(eResourcesType.VipLevel); var tbVip = Table.GetVIP(vipLevel); if (tbVip == null) { return(ErrorCodes.Error_NoVipGift); } Dictionary <int, int> dic = new Dictionary <int, int>(); Utils.GetVipReward(vipLevel, ref dic); if (dic.Count == 0) { return(ErrorCodes.Error_NoVipGift); } var tbDA = Table.GetDailyActivity(giftId); if (character.GetFlag(tbDA.CommonParam[0])) { return(ErrorCodes.Error_VipGiftGained); } return(BagManager.CheckAddItemList(character.mBag, dic)); } case eActivationRewardType.MonthCard: { var now = DateTime.Now; var date = character.lExdata64.GetTime(Exdata64TimeType.MonthCardExpirationDate); if (date < now) { return(ErrorCodes.Error_NoMonthCard); } var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_MonthCardGained); } } break; case eActivationRewardType.LifeCard: { if (!character.GetFlag(2682)) //终生卡标记 { return(ErrorCodes.Error_NoLifeCard); } var tbRecharge = Table.GetRecharge(giftId); if (null == tbRecharge) { return(ErrorCodes.Error_GiftID); } var flagId = tbRecharge.Param[2]; if (character.GetFlag(flagId)) { return(ErrorCodes.Error_LifeCardGained); } } break; case eActivationRewardType.WeekCard: { var now = DateTime.Now; var date = character.lExdata64.GetTime(Exdata64TimeType.WeekCardExpirationDate); if (date < now) { return(ErrorCodes.Error_NoWeekCard); } var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_WeekCardGained); } } break; } return(ErrorCodes.OK); }
//给予奖励 public ErrorCodes GiveGift(CharacterController character, eActivationRewardType type, int giftId) { var result = ErrorCodes.OK; switch (type) { case eActivationRewardType.TableGift: { var tbGift = Table.GetGift(giftId); if (tbGift == null) { return(ErrorCodes.Error_GiftID); } if (character.GetFlag(tbGift.Flag)) { return(ErrorCodes.Error_GiftAlreadyReceive); } //执行领取 switch ((eRewardType)tbGift.Type) { //固定礼包 case eRewardType.GiftBag: { //Dictionary<int, int> items = new Dictionary<int, int>(); for (var i = 0; i != 4; ++i) { if (tbGift.Param[i * 2] != -1) { character.mBag.AddItem(tbGift.Param[i * 2], tbGift.Param[i * 2 + 1], eCreateItemType.Gift); } } } break; //在线时长 case eRewardType.OnlineReward: { result = character.mBag.AddItem(tbGift.Param[1], tbGift.Param[2], eCreateItemType.Online); } break; //等级奖励 case eRewardType.LevelReward: { for (var i = 1; i <= 5; ++i) { var count = tbGift.Param[i + 5]; if (tbGift.Param[i] != -1) { character.mBag.AddItem(tbGift.Param[i], count, eCreateItemType.LevelUp); } } } break; //连续登陆 case eRewardType.ContinuesLoginReward: { //result = character.mBag.AddItem(tbGift.Param[1], tbGift.Param[2]); var days = character.GetExData(17); if (days > 5) { days = 5; } for (var i = 0; i < days; ++i) { var tbGift2 = Table.GetGift(13 + i); if (character.GetFlag(tbGift2.Flag)) { continue; } character.mBag.AddItem(tbGift2.Param[1], tbGift2.Param[2], eCreateItemType.ContinueDay); character.SetFlag(tbGift2.Flag); } return(ErrorCodes.OK); } //签到 case eRewardType.MonthCheckinReward: { if (character.GetFlag(466)) { //补签 var SupplementCount = character.GetExData(18); var needGold = (int) (tbGift.Param[4] * SkillExtension.Pow(tbGift.Param[5] / 10000.0f, SupplementCount)); needGold = needGold - needGold % 5; character.mBag.DeleteItem((int)eResourcesType.DiamondRes, needGold, eDeleteItemType.ReSign); character.SetExData(18, SupplementCount + 1); character.AddExData(tbGift.Exdata, 1); result = character.mBag.AddItem(tbGift.Param[2], tbGift.Param[3], eCreateItemType.ReSign); } else { //签到 character.SetFlag(466); character.AddExData(tbGift.Exdata, 1); result = character.mBag.AddItem(tbGift.Param[2], tbGift.Param[3], eCreateItemType.Sign); } } break; ////每日活跃度 //case eRewardType.DailyActivity: // { // character.AddExData(tbGift.Param[3], tbGift.Param[0]); // } // break; //每日活跃奖励 case eRewardType.DailyActivityReward: { result = character.mBag.AddItem(tbGift.Param[0], tbGift.Param[1], eCreateItemType.Activity); } break; //七天登录奖励 case eRewardType.SevenDayReward: { for (var i = 0; i != 3; i++) { character.mBag.AddItem(tbGift.Param[i * 2 + 1], tbGift.Param[i * 2 + 2], eCreateItemType.SevenDayReward); } character.mBag.AddItem(tbGift.Param[7], tbGift.Param[8], eCreateItemType.SevenDayReward); character.SetFlag(tbGift.Flag); } break; default: Logger.Warn("Gift[{0}] type is overflow", giftId); break; } if (result == ErrorCodes.OK) { character.SetFlag(tbGift.Flag); } } break; case eActivationRewardType.DailyVipGift: { var vipLevel = character.mBag.GetRes(eResourcesType.VipLevel); var tbVip = Table.GetVIP(vipLevel); Dictionary <int, int> dic = new Dictionary <int, int>(); Utils.GetVipReward(vipLevel, ref dic); if (dic.Count == 0) { return(ErrorCodes.Error_NoVipGift); } var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_VipGiftGained); } result = BagManager.CheckAddItemList(character.mBag, dic); if (result != ErrorCodes.OK) { return(result); } character.SetFlag(flag); result = character.mBag.AddItems(dic, eCreateItemType.DailyVipGift); } break; case eActivationRewardType.MonthCard: { var diaCount = Table.GetServerConfig(419).ToInt(); result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.MonthCard); var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_MonthCardGained); } character.SetFlag(flag); character.SetFlag(tbDA.CommonParam[0]); character.AddExData((int)eExdataDefine.e778, 1); } break; case eActivationRewardType.WeekCard: { var tbRecharge = Table.GetRecharge(43); var diaCount = tbRecharge.Param[0]; //策划配置到此列 result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.WeekCard); var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_WeekCardGained); } character.SetFlag(flag); character.AddExData((int)eExdataDefine.e779, 1); } break; case eActivationRewardType.LifeCard: { var tbRecharge = Table.GetRecharge(giftId); if (null == tbRecharge) { return(ErrorCodes.Error_GiftID); } var flagId = tbRecharge.Param[2]; if (character.GetFlag(flagId)) { return(ErrorCodes.Error_LifeCardGained); } var diaCount = tbRecharge.Param[0]; result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.LifeCard); if (result == ErrorCodes.OK) { character.SetFlag(flagId); } else { return(result); } } break; } return(result); }
private static void MissinReward(int missionId, ReadonlyObjectList <ItemIdDataModel> dataModel) { var tableData = Table.GetMissionBase(missionId); if (null == tableData) { return; } //重置 for (var i = 0; i < dataModel.Count; i++) { dataModel[i].ItemId = -1; dataModel[i].Count = -1; } //物品id const int expItemId = 1; var playerLevel = Math.Max(1, PlayerDataManager.Instance.GetLevel()); var roleId = PlayerDataManager.Instance.GetRoleId(); var start = 0; //职业奖励 for (var i = 0; i < 2; i++) { if (tableData.RoleRewardId[roleId, i] != -1) { dataModel[start].ItemId = tableData.RoleRewardId[roleId, i]; dataModel[start].Count = tableData.RoleRewardCount[roleId, i]; start++; } } //等级系数经验奖励 if (0 != tableData.IsDynamicExp) { var expCount = GameUtils.CalculateExpByLevel(tableData.DynamicExpRatio, playerLevel); dataModel[start].ItemId = expItemId; dataModel[start].Count = expCount; start++; } //普通任务奖励 for (var i = 0; i < tableData.RewardItem.Length && start < dataModel.Count; i++) { if (-1 == tableData.RewardItem[i]) { continue; } dataModel[start].ItemId = tableData.RewardItem[i]; dataModel[start].Count = SkillExtension.ModifyByLevel(tableData.RewardItemCount[i], playerLevel, 100000000); start++; } //普通任务奖励 /* * var DataModelRewardItemCount1 = dataModel.Count - start; * for (int i = 0; i < DataModelRewardItemCount1; i++) * { * if (start > dataModel.Count) * { * Logger.Debug("DataModel.RewardItem[{0}] out of index", start); * * break; * } * if (-1 == tableData.RewardItem[i]) * { * * continue; * } * dataModel[start].ItemId = tableData.RewardItem[i]; * dataModel[start].Count = tableData.RewardItemCount[i]; * start++; * } */ }