/// <summary> /// 0 Monster /// 1 Player /// 2 Npc /// </summary> /// <param name="isPlayer">If set to <c>true</c> is player.</param> /// <param name="mid">Middle.</param> /// <param name="level">Level.</param> public UnitData(bool isPlayer, int mid, int level) { IsPlayer = isPlayer; Log.Important("Init Unit Data is " + isPlayer + " " + mid + " " + level); if (!isPlayer) { config = GMDataBaseSystem.SearchIdStatic <MonsterFightConfigData>(GameData.MonsterFightConfig, mid); } else { jobConfig = GMDataBaseSystem.SearchIdStatic <RoleJobDescriptionsData>(GameData.RoleJobDescriptions, mid); RoleUpgradeConfigData lastInfo = null; foreach (RoleUpgradeConfigData r in GameData.RoleUpgradeConfig) { if (r.job == mid && r.level == level) { playerConfig = r; break; } if (r.job == mid) { lastInfo = r; } } //等级超过了配置区间 if (playerConfig == null) { playerConfig = lastInfo; } Log.Important("jobConfig " + jobConfig + " playerConfig " + playerConfig); } }
public string ChapterName(int cha) { Log.GUI("GetChapter Name " + cha); var chapter = GMDataBaseSystem.SearchIdStatic <ChapterConfigData> (GameData.ChapterConfig, cha); return(chapter.name); }
public SkillData(int skillId, int level) { skillConfig = GMDataBaseSystem.SearchIdStatic <SkillConfigData>(GameData.SkillConfig, skillId); foreach (SkillEffectConfigData sd in GameData.SkillEffectConfig) { if (sd.skillId == skillId && sd.skillLevel == level) { effectConfig = sd; break; } } foreach (SkillLearnConfigData sd in GameData.SkillLearnConfig) { if (sd.skillId == skillId) { learnConfig = sd; break; } } if (learnConfig == null) { Log.Sys("Skill Learn Config Not exist " + skillId + " " + level); } if (effectConfig == null) { Log.Sys("SkillData Init Error " + skillId + " " + level); } Log.Important("skill Id and skill Effect " + skillConfig + " " + effectConfig); }
void OnLevelUp() { if (equipData != null) { var lev = equipData.entry.Level; var needLevel = GMDataBaseSystem.SearchIdStatic <EquipLevelData>(GameData.EquipLevel, lev); var myLev = ObjectManager.objectManager.GetMyAttr().Level; if (needLevel.level > myLev) { WindowMng.windowMng.ShowNotifyLog(string.Format("只有自身达到{0}级,才能掌控更高级装备", needLevel.level)); return; } var lv = WindowMng.windowMng.PushView("UI/LevelUpEquip"); var eq = lv.GetComponent <LevelUpEquip>(); eq.SetEquip(equipData); } else { var lv = WindowMng.windowMng.PushView("UI/LevelUpGem"); var gem = lv.GetComponent <LevelUpGem>(); gem.SetData(backpackData); MyEventSystem.PushEventStatic(MyEvent.EventType.UpdateItemCoffer); } }
public static UnitData GetNpcData(int npcId) { int key = 2 * 1000000 + npcId * 10 + 0; if (monsterData.ContainsKey(key)) { return(monsterData [key]); } var config = GMDataBaseSystem.SearchIdStatic <NpcConfigData>(GameData.NpcConfig, npcId); UnitData ud = new UnitData(config); monsterData [key] = ud; return(ud); }
//根据BaseID 以及装备类型获得ItemData public ItemData(int goodsType, int baseId) { if (goodsType == 0) { propsConfig = GMDataBaseSystem.SearchIdStatic <PropsConfigData> (GameData.PropsConfig, baseId); config = propsConfig; } else { equipConfig = GMDataBaseSystem.SearchIdStatic <EquipConfigData> (GameData.EquipConfig, baseId); config = equipConfig; } if (config == null) { Log.Critical("Init ItemData Error " + goodsType + " " + baseId); } }
public CDataBase GetJsonDatabase(DBName db) { CDataBase database; if (databaseMap.TryGetValue(db, out database)) { } else { var binData = Resources.Load(dbName[(int)db]) as TextAsset; //Log.Important("binData "+binData); var arr = SimpleJSON.JSON.Parse(binData.text) as SimpleJSON.JSONArray; //Log.Important("Load database "+arr.ToString()); database = new CDataBase(arr); databaseMap[db] = database; } return(database); }
void UpdateFrame() { var entry = equipData.entry; string baseAttr = ""; if (equipData.itemData.Damage > 0) { baseAttr += string.Format("[9800fc]攻击力:{0}[-]\n", equipData.itemData.Damage); } if (equipData.itemData.RealArmor > 0) { baseAttr += string.Format("[8900cf]防御力:{0}[-]\n", equipData.itemData.RealArmor); } string initAttr = string.Format("[fc0000]天赋攻击:{0}[-]\n[fc0000]天赋防御:{1}[-]\n", entry.RndAttack, entry.RndDefense); string extarAttr = string.Format("[fc0000]额外攻击:{0}[-]\n[fc0000]额外防御:{1}[-]\n", equipData.entry.ExtraAttack, equipData.entry.ExtraDefense); Name.text = string.Format("[ff9500]{0}({1}级)[-]\n[0098fc]{2}金币[-]\n{3}{4}{5}[fcfc00]{6}[-]", equipData.itemData.ItemName, equipData.entry.Level, equipData.itemData.GoldCost, baseAttr, initAttr, extarAttr, equipData.itemData.Description); var levCost = GMDataBaseSystem.SearchIdStatic <EquipLevelData>(GameData.EquipLevel, equipData.entry.Level + 1); if (levCost != null) { Rate.text = string.Format("[ff9500]成功率:{0}%[-]\n[ff9500]金币:{1}[-]", levCost.rate, levCost.gold ); } InitList(); StartCoroutine(WaitReset()); }
//从配置代码中获取数据 public IConfig SearchIdByConf(DBName db, int id) { CDataBase database = null; if (databaseMap.TryGetValue(db, out database)) { database = databaseMap [db]; } else { var ch = new List <IConfig>(); if (db == DBName.PropsConfig) { foreach (PropsConfigData p in GameData.PropsConfig) { ch.Add(p); } } else if (db == DBName.EquipConfig) { foreach (EquipConfigData p in GameData.EquipConfig) { ch.Add(p); } } else if (db == DBName.ChapterConfig) { foreach (ChapterConfigData p in GameData.ChapterConfig) { ch.Add(p); } } database = new CDataBase(ch); } return(database.SearchIdByConf(id)); }
public T SearchId <T>(List <T> data, int id) where T : IConfig { return(GMDataBaseSystem.SearchIdStatic <T>(data, id)); }
public static void LevelUpEquip(KBEngine.Packet packet) { var playerInfo = ServerData.Instance.playerInfo; var inpb = packet.protoBody as CGLevelUpEquip; var eid = inpb.EquipId; var curLev = 0; PackInfo packInfo = null; foreach (var e in playerInfo.DressInfoList) { if (e.PackEntry.Id == eid) { packInfo = e; break; } } if (packInfo != null) { curLev = packInfo.PackEntry.Level + 1; var levCost = GMDataBaseSystem.SearchIdStatic <EquipLevelData>(GameData.EquipLevel, curLev); if (levCost == null) { SendNotify("装备已经升到顶级了"); return; } var myGold = playerInfo.Gold; if (levCost.gold > myGold) { SendNotify("金币不足"); return; } AddGold(-levCost.gold); var extraAtt = 0; var extraDef = 0; foreach (var g in inpb.GemIdList) { var pinfo = GetItemInPack(g); var itemData = Util.GetItemData(0, pinfo.PackEntry.BaseId); extraAtt += itemData.GetRndAtk(); extraDef += itemData.GetRndDef(); ReduceItem(g, 1); } var rate = Random.Range(0, 100); if (rate < levCost.rate) { packInfo.PackEntry.Level++; packInfo.PackEntry.ExtraAttack += extraAtt; packInfo.PackEntry.ExtraDefense += extraDef; SendNotify("装备升级成功, 本次概率" + rate); var update = GCPushEquipDataUpdate.CreateBuilder(); update.PackInfo = packInfo; ServerBundle.SendImmediatePush(update); } else { SendNotify("装备升级失败, 本次概率" + rate + " 需要概率 " + levCost.rate); } } }