private void SetGameLevelDetailDes(int gameLevelId, GameLevelGrade grade) { //1.读取游戏关卡表 GameLevelEntity gameLevelEntity = GameLevelDBModel.GetInstance.GetEntityById(gameLevelId); //2.读取游戏关卡难度等级表 GameLevelGradeEntity gameLevelGradeEntity = GameLevelGradeDBModel.GetInstance.GetEntityByGameLevelIdAndGrade(gameLevelId, grade); data = new TransferData(); data.SetValue <string>("GameLevelDesc", gameLevelGradeEntity.Desc); data.SetValue <string>("GameLevelConditionDesc", gameLevelGradeEntity.ConditionDesc); data.SetValue <string>("GameLevelDlgPic", gameLevelEntity.DlgPic); data.SetValue <int>("GameLevelExp", gameLevelGradeEntity.Exp); data.SetValue <int>("GameLevelGold", gameLevelGradeEntity.Gold); data.SetValue <int>("GameLevelCommentFighting", gameLevelGradeEntity.CommendFighting); data.SetValue <string>("GameLevelName", gameLevelEntity.Name); data.SetValue <string>("GameLevelName", gameLevelEntity.Name); data.SetValue <int>("GameLevelId", gameLevelEntity.Id); m_levelDetailView.SetUI(data, SetGameLevelDetailDes); }
private void SetGameLevelDetails(int gameLevelId, GameLevelGrade grade) { m_GameLevelSceneId = gameLevelId; m_Garade = grade; GameLevelEntity levelEnitiy = GameLevelDBModel.Instance.Get(gameLevelId); GameLevelGradeEntity gradeEnitiy = GameLevelGradeDBModel.Instance.GetEnityByLevelIdAndGrade(gameLevelId, grade); if (levelEnitiy == null || gradeEnitiy == null) { return; } DataTransfer data = new DataTransfer(); data.SetData(ConstDefine.GameLevelId, levelEnitiy.Id); data.SetData(ConstDefine.GameLevelName, levelEnitiy.Name); data.SetData(ConstDefine.GameLevelSceneName, levelEnitiy.SceneName); data.SetData(ConstDefine.GameLevelDlgPic, levelEnitiy.DlgPic); //装备 List <DataTransfer> equipDatas = new List <DataTransfer>(); List <GoodsEntity> equipEnitys = gradeEnitiy.RewardEquipList; if (equipEnitys != null && equipEnitys.Count > 0) { equipEnitys.Sort((GoodsEntity entity1, GoodsEntity entity2) => { if (entity1.GoodsProbability > entity2.GoodsProbability) { return(1); } else if (entity1.GoodsProbability == entity2.GoodsProbability) { return(0); } else { return(-1); } }); for (int i = 0; i < equipEnitys.Count; i++) { DataTransfer equipData = new DataTransfer(); equipData.SetData(ConstDefine.GameLevelGoodsId, equipEnitys[i].GoodsId); equipData.SetData(ConstDefine.GameLevelGoodsName, equipEnitys[i].GoodsName); equipData.SetData(ConstDefine.GameLevelGoodsProbability, equipEnitys[i].GoodsProbability); equipData.SetData(ConstDefine.GameLevelGoodsCount, equipEnitys[i].GoodsCount); equipDatas.Add(equipData); } } //道具 List <DataTransfer> itemDatas = new List <DataTransfer>(); List <GoodsEntity> itemEnitys = gradeEnitiy.RewardItemList; if (itemEnitys != null && itemEnitys.Count > 0) { itemEnitys.Sort((GoodsEntity entity1, GoodsEntity entity2) => { if (entity1.GoodsProbability > entity2.GoodsProbability) { return(-1); } else if (entity1.GoodsProbability == entity2.GoodsProbability) { return(0); } else { return(1); } }); for (int i = 0; i < itemEnitys.Count; i++) { DataTransfer itemData = new DataTransfer(); itemData.SetData(ConstDefine.GameLevelGoodsId, itemEnitys[i].GoodsId); itemData.SetData(ConstDefine.GameLevelGoodsName, itemEnitys[i].GoodsName); itemData.SetData(ConstDefine.GameLevelGoodsProbability, itemEnitys[i].GoodsProbability); itemData.SetData(ConstDefine.GameLevelGoodsCount, itemEnitys[i].GoodsCount); itemDatas.Add(itemData); } } //材料 List <DataTransfer> materiaDatas = new List <DataTransfer>(); List <GoodsEntity> materiaEnitys = gradeEnitiy.RewardMateriaList; if (materiaEnitys != null && materiaEnitys.Count > 0) { materiaEnitys.Sort((GoodsEntity entity1, GoodsEntity entity2) => { if (entity1.GoodsProbability > entity2.GoodsProbability) { return(-1); } else if (entity1.GoodsProbability == entity2.GoodsProbability) { return(0); } else { return(1); } }); for (int i = 0; i < materiaEnitys.Count; i++) { DataTransfer materiaData = new DataTransfer(); materiaData.SetData(ConstDefine.GameLevelGoodsId, materiaEnitys[i].GoodsId); materiaData.SetData(ConstDefine.GameLevelGoodsName, materiaEnitys[i].GoodsName); materiaData.SetData(ConstDefine.GameLevelGoodsProbability, materiaEnitys[i].GoodsProbability); materiaData.SetData(ConstDefine.GameLevelGoodsCount, materiaEnitys[i].GoodsCount); materiaDatas.Add(materiaData); } } data.SetData(ConstDefine.GameLevelRewardEquip, equipDatas); data.SetData(ConstDefine.GameLevelRewardItem, itemDatas); data.SetData(ConstDefine.GameLevelRewardMaterial, materiaDatas); data.SetData(ConstDefine.GameLevelRewardGold, gradeEnitiy.Gold); data.SetData(ConstDefine.GameLevelRewardExp, gradeEnitiy.Exp); data.SetData(ConstDefine.GameLevelDesc, gradeEnitiy.Desc); data.SetData(ConstDefine.GameLevelConditionDesc, gradeEnitiy.ConditionDesc); data.SetData(ConstDefine.GameLevelCommendFighting, gradeEnitiy.CommendFighting); m_GameLevelDetailsView.SetUI(data); }
/// <summary> /// 打开关卡胜利页面 /// </summary> private void OpenGameLevelVictoryView() { m_GameLevelVictoryView = UIViewUtil.Instance.OpenWindow(UIViewType.GameLevelVictory).GetComponent <UIGameLevelVictoryView>(); m_GameLevelVictoryView.OnReturnWorldScene = OnClickGameLevelVictoryViewReturnWorldSceneButton; GameLevelEntity levelEnitiy = GameLevelDBModel.Instance.Get(m_GameLevelSceneId); GameLevelGradeEntity gradeEnitiy = GameLevelGradeDBModel.Instance.GetEnityByLevelIdAndGrade(m_GameLevelSceneId, m_Garade); if (levelEnitiy == null || gradeEnitiy == null) { return; } DataTransfer data = new DataTransfer(); data.SetData(ConstDefine.GameLevelRewardGold, gradeEnitiy.Gold); data.SetData(ConstDefine.GameLevelRewardExp, gradeEnitiy.Exp); data.SetData(ConstDefine.GameLevelPassTime, CurPassTime); int star = 1; if (CurPassTime < gradeEnitiy.Star2) { star = 3; } else if (CurPassTime < gradeEnitiy.Star1) { star = 2; } data.SetData(ConstDefine.GameLevelStarCount, star); List <GoodsEntity> rewards = new List <GoodsEntity>(); //可以放在服务器里面计算,为了简单就直接在这计算了 //装备 rewards.Clear(); int ranmdom01 = UnityEngine.Random.Range(0, 100); DataTransfer equipData = new DataTransfer(); List <GoodsEntity> equipEnitys = gradeEnitiy.RewardEquipList; for (int i = 0; i < equipEnitys.Count; i++) { if (ranmdom01 < equipEnitys[i].GoodsProbability) { rewards.Add(equipEnitys[i]); } } GoodsEntity equipEnity = equipEnitys[UnityEngine.Random.Range(0, rewards.Count)]; if (equipEnity != null) { equipData.SetData(ConstDefine.GameLevelGoodsId, equipEnity.GoodsId); equipData.SetData(ConstDefine.GameLevelGoodsName, equipEnity.GoodsName); equipData.SetData(ConstDefine.GameLevelGoodsProbability, equipEnity.GoodsProbability); equipData.SetData(ConstDefine.GameLevelGoodsCount, equipEnity.GoodsCount); data.SetData(ConstDefine.GameLevelRewardEquip, equipData); CurGameLevelGetGoodsList.Add(new GetGoodsEntity() { GoodsId = equipEnity.GoodsId, GoodsCount = 1, GoodsType = 0 }); } //道具 rewards.Clear(); int ranmdom02 = UnityEngine.Random.Range(0, 100); DataTransfer itemData = new DataTransfer(); List <GoodsEntity> itemEnitys = gradeEnitiy.RewardItemList; for (int i = 0; i < itemEnitys.Count; i++) { if (ranmdom02 < itemEnitys[i].GoodsProbability) { rewards.Add(itemEnitys[i]); } } GoodsEntity itemEnity = itemEnitys[UnityEngine.Random.Range(0, rewards.Count)]; if (itemEnity != null) { itemData.SetData(ConstDefine.GameLevelGoodsId, itemEnity.GoodsId); itemData.SetData(ConstDefine.GameLevelGoodsName, itemEnity.GoodsName); itemData.SetData(ConstDefine.GameLevelGoodsProbability, itemEnity.GoodsProbability); itemData.SetData(ConstDefine.GameLevelGoodsCount, itemEnity.GoodsCount); data.SetData(ConstDefine.GameLevelRewardItem, itemData); CurGameLevelGetGoodsList.Add(new GetGoodsEntity() { GoodsId = itemEnity.GoodsId, GoodsCount = 1, GoodsType = 1 }); } //材料 rewards.Clear(); int ranmdom03 = UnityEngine.Random.Range(0, 100); DataTransfer materiaData = new DataTransfer(); List <GoodsEntity> materiaEnitys = gradeEnitiy.RewardMateriaList; for (int i = 0; i < materiaEnitys.Count; i++) { if (ranmdom03 < materiaEnitys[i].GoodsProbability) { rewards.Add(materiaEnitys[i]); } } GoodsEntity materiaEnity = materiaEnitys[UnityEngine.Random.Range(0, rewards.Count)]; if (materiaEnity != null) { materiaData.SetData(ConstDefine.GameLevelGoodsId, materiaEnity.GoodsId); materiaData.SetData(ConstDefine.GameLevelGoodsName, materiaEnity.GoodsName); materiaData.SetData(ConstDefine.GameLevelGoodsProbability, materiaEnity.GoodsProbability); materiaData.SetData(ConstDefine.GameLevelGoodsCount, materiaEnity.GoodsCount); data.SetData(ConstDefine.GameLevelRewardMaterial, materiaData); CurGameLevelGetGoodsList.Add(new GetGoodsEntity() { GoodsId = materiaEnity.GoodsId, GoodsCount = 1, GoodsType = 2 }); } m_GameLevelVictoryView.SetUI(data); CurGameLevelTotalExp += gradeEnitiy.Exp; CurGameLevelTotalGold += gradeEnitiy.Gold; GameLevel_VictoryProto proto = new GameLevel_VictoryProto(); proto.GameLevelId = m_GameLevelSceneId; proto.Grade = (byte)m_Garade; proto.Star = (byte)star; proto.Exp = CurGameLevelTotalExp; proto.Gold = CurGameLevelTotalGold; foreach (var item in CurGameLevelKillMonsterDic) { GameLevel_VictoryProto.MonsterItem monster = new GameLevel_VictoryProto.MonsterItem(); monster.MonsterId = item.Key; monster.MonsterCount = item.Value; proto.KillMonsterList.Add(monster); } foreach (var item in CurGameLevelGetGoodsList) { GameLevel_VictoryProto.ReceiveGoodsItem goods = new GameLevel_VictoryProto.ReceiveGoodsItem(); goods.GoodsType = item.GoodsType; goods.GoodsId = item.GoodsId; goods.GoodsCount = item.GoodsCount; proto.ReceiveGoodsList.Add(goods); } NetWorkSocket.Instance.SendMsg(proto.ToArray()); }