private void InitData() { _mapName = LuaScriptMgr.Instance.GetTableValue <string>("first_fightTable", "map"); LuaTable herosLT = LuaScriptMgr.Instance.GetLuaTable("first_fightTable.heros"); LuaTable enemiesLT = LuaScriptMgr.Instance.GetLuaTable("first_fightTable.enemies"); foreach (LuaTable lt in herosLT.ToArray()) { FirstFightCharacterData ffcd = new FirstFightCharacterData(); ffcd.id = lt[1].ToString().ToInt32(); ffcd.starLevel = lt[2].ToString().ToInt32(); ffcd.formationPosition = (FormationPosition)lt[3].ToString().ToInt32(); ffcd.hp = lt[4].ToString().ToUInt32(); ffcd.cd1 = lt[5].ToString().ToFloat(); ffcd.cd2 = lt[6].ToString().ToFloat(); ffcd.isRole = lt[7].ToString() == "1"; heros.Add(ffcd); } foreach (LuaTable lt in enemiesLT.ToArray()) { FirstFightCharacterData ffcd = new FirstFightCharacterData(); ffcd.id = lt[1].ToString().ToInt32(); ffcd.starLevel = lt[2].ToString().ToInt32(); ffcd.formationPosition = (FormationPosition)lt[3].ToString().ToInt32(); ffcd.hp = lt[4].ToString().ToUInt32(); ffcd.cd1 = lt[5].ToString().ToFloat(); ffcd.cd2 = lt[6].ToString().ToFloat(); ffcd.isRole = lt[7].ToString() == "1"; enemies.Add(ffcd); } }
public FirstFightCharacterData GetCharacterDataById(int id) { FirstFightCharacterData result = default(FirstFightCharacterData); bool isFind = false; for (int i = 0, count = heros.Count; i < count; i++) { if (heros[i].id == id) { result = heros[i]; isFind = true; break; } } if (isFind) { return(result); } for (int i = 0, count = enemies.Count; i < count; i++) { if (enemies[i].id == id) { result = enemies[i]; break; } } return(result); }
public void InitFightData() { List <FightHeroInfo> fightHeroInfoList = new List <FightHeroInfo>(); for (int i = 0, count = heros.Count; i < count; i++) { FirstFightCharacterData ffcd = heros[i]; if (ffcd.isRole) { PlayerInfo playerInfo = new PlayerInfo((uint)ffcd.id); playerInfo.advanceLevel = ffcd.starLevel; PlayerFightProtoData pfpd = new PlayerFightProtoData(); pfpd.posIndex = (int)ffcd.formationPosition; pfpd.attr = new HeroAttrProtoData(); pfpd.attr.hp = (int)ffcd.hp; pfpd.attr.hpUp = (int)ffcd.hp; FightPlayerInfo fightPlayerInfo = new FightPlayerInfo(playerInfo, pfpd); FightProxy.instance.SetFightPlayerInfo(fightPlayerInfo); } else { HeroInfo heroInfo = new HeroInfo(ffcd.id); heroInfo.advanceLevel = ffcd.starLevel; HeroFightProtoData hfpd = new HeroFightProtoData(); hfpd.posIndex = (int)ffcd.formationPosition; hfpd.attr = new HeroAttrProtoData(); hfpd.attr.hp = (int)ffcd.hp; hfpd.attr.hpUp = (int)ffcd.hp; FightHeroInfo fightHeroInfo = new FightHeroInfo(heroInfo, hfpd); fightHeroInfoList.Add(fightHeroInfo); } } FightProxy.instance.SetFightHeroInfoList(fightHeroInfoList); List <FightHeroInfo> enemyFightHeroInfoList = new List <FightHeroInfo>(); for (int i = 0, count = enemies.Count; i < count; i++) { FirstFightCharacterData ffcd = enemies[i]; HeroInfo heroInfo = new HeroInfo(ffcd.id); heroInfo.advanceLevel = ffcd.starLevel; HeroFightProtoData hfpd = new HeroFightProtoData(); hfpd.posIndex = (int)ffcd.formationPosition; hfpd.attr = new HeroAttrProtoData(); hfpd.attr.hp = (int)ffcd.hp; hfpd.attr.hpUp = (int)ffcd.hp; FightHeroInfo fightHeroInfo = new FightHeroInfo(heroInfo, hfpd); enemyFightHeroInfoList.Add(fightHeroInfo); } FightProxy.instance.SetEnemyFightHeroInfoList(enemyFightHeroInfoList); }