public static string GetPreName(int roleId) { var datas = ConfigRoleManager.Instance().allDatas[roleId]; int proId = datas.proId; return(ConfigProfessionManager.Instance().allDatas[proId].name); }
//让一个角色获得羁绊效果 public override void GetEffect(RoleBase role) { if (effectIndex == -1) { return; } if (type == 1) { foreach (var v in attributes) { role.attributes[v.Key] += v.Value[effectIndex]; } } else if (type == 2) { foreach (var v in attributes) { float changeVlu = ConfigRoleManager.Instance().allDatas[role.GetRoleId()].attributes[role.GetLevel() - 1][v.Key] * v.Value[effectIndex] * 1.0f / 100; role.attributes[v.Key] += changeVlu; } } else { Debug.LogError("羁绊 数值 种类数据配置错误"); } }
public static string GetCooperName(int roleId) { var datas = ConfigRoleManager.Instance().allDatas[roleId]; int cooperId = datas.cooperId; return(ConfigCooperationManager.Instance().allDatas[cooperId].name); }
//角色新建时 从配置表里读数据,传入的是 数据项的id,不是角色id public void SetId(int id, int level = 1) { // if(!ConfigRoleManager.Instance().allDatas.ContainsKey(id)) // { // Debug.Log(id); // } var data = ConfigRoleManager.Instance().allDatas[id]; this.id = id; name = data.name; cost = data.cost; SetLevel(level); etlId[0] = data.cooperId; etlId[1] = data.proId; for (int i = 0; i < data.attributes[level - 1].Length; i++) { attributes[i] = data.attributes[level - 1][i]; } //创建技能对象 if (data.skillId != 0) { skill = new SkillBase(); skill.SetId(data.skillId, level, this); } //获取fight gameobject资源 并且实例化,实例化后隐藏 //fightRole = ObjectPool.Instance().GetRoleGo(name); }
void OnClickRole(GameObject go = null) { //属性数据 var attributeData = ConfigAttributeManager.Instance().allDatas; //角色数据 var roleData = ConfigRoleManager.Instance().allDatas[roleId]; var roleAttributeData = roleData.attributes[0]; var attributeSb = new System.Text.StringBuilder(); for (int i = 0; i < 7; i++) { attributeSb.Append($"{attributeData[i].name}:{roleAttributeData[i].ToString()} "); } string skillDesc = null; if (roleData.skillId != 0) { var datas = ConfigSkillManager.Instance().allDatas[roleData.skillId]; skillDesc = $"{datas.name}:{datas.desc}"; } string cooperName = ConfigCooperationManager.Instance().allDatas[roleData.cooperId].name; string proName = ConfigProfessionManager.Instance().allDatas[roleData.proId].name; string content = $"<size=50><color={ConstConfig.levelColor[roleData.cost]}>{roleData.name}</color></size>\n<color=#8A3468>{cooperName} {proName}</color>\n\n{attributeSb.ToString()}\n\n{skillDesc}"; ViewManager.Get <WndTips>("WndTips").ShowInfo(content); }
protected override void InitDesc() { System.Text.StringBuilder namesb = new System.Text.StringBuilder("\n"); var allRoles = ConfigRoleManager.Instance().allDatas; foreach (var role in allRoles.Values) { if (role.cooperId == id) { namesb.Append($"<color={ConstConfig.levelColor[role.cost]}>[{role.name}]</color> "); } } ConfigCooperation cooperData = ConfigCooperationManager.Instance().allDatas[GetId()]; var attriData = ConfigAttributeManager.Instance().allDatas; var sb = new System.Text.StringBuilder(); string type = null; if (cooperData.type == 1) { type = " "; } else if (cooperData.type == 2) { type = "% "; } for (int i = 0; i < cooperData.counts.Length; i++) { sb.Append($"<color=blue>人口:</color>{cooperData.counts[i]}\n"); foreach (var v in cooperData.attributes) { sb.Append($"<color=yellow>{ attriData[v.Key].name}:</color>{v.Value[i]}{type}"); } int range = cooperData.range[i]; if (range == 1) { sb.Append("\n<color=blue>范围:</color>只对该羁绊的角色生效\n"); } else if (range == 2) { sb.Append("\n<color=blue>范围:</color>对我方所有角色生效\n"); } } sb.Append(namesb); desc = sb.ToString(); }
void UpdateBugIcon() { var datas = ConfigRoleManager.Instance().allDatas[roleId]; int moeny = ModelManager.Get <PlayerModel>("PlayerModel").GetMoney(); int price = datas.cost - RoleShopModel.zhekou; if (price > moeny) { buyIcon.color = Color.gray; } else { buyIcon.color = Color.white; } }
void UpdateView( ) { var datas = ConfigRoleManager.Instance().allDatas[roleId]; nameText.text = datas.name.ToString(); costText.text = (datas.cost - RoleShopModel.zhekou).ToString(); UpdateCooperText(); toneImage.sprite = AssetLoader.instance.tones[datas.cost - 1]; ShowCanLevelView(); UpdateBugIcon(); }
protected override void InitDesc() { System.Text.StringBuilder namesb = new System.Text.StringBuilder("\n"); var allRoles = ConfigRoleManager.Instance().allDatas; foreach (var role in allRoles.Values) { if (role.proId == id) { namesb.Append($"<color={ConstConfig.levelColor[role.cost]}>[{role.name}]</color> "); } } desc = $"{configData.desc}\n{namesb.ToString()}"; }
public void OnBuyRole(int index) { int id = roles[index]; int cost = ConfigRoleManager.Instance().allDatas[id].cost; int price = cost - zhekou; if (playerModel.SetMoney(-price)) { roles[index] = 0; //买了后 id 设置为0 playerModel.AddRolePre(id); EventManager.ExecuteEvent(EventType.ShopDataUpdate); } else { WndTips.ShowTips("您的余额不足以购买该角色!"); } }
protected override void Init() { base.Init(); playerModel = ModelManager.Get("PlayerModel") as PlayerModel; roles = new int[Max_Role_Count]; //数据初始化 for (int i = 1; i <= Max_Role_Count; i++) { roleCostMap.Add(i, new List <int>()); } var roleDatas = ConfigRoleManager.Instance().allDatas; foreach (var v in roleDatas) { roleCostMap[v.Value.cost].Add(v.Key); } AddEvent(); }
public void SetAIRole() { Dictionary <int, int[]> currentRoles; if (currentLevel <= MaxLevel)//maxLevel { currentRoles = roles[currentLevel - 1]; } else { //生成随机ai队列 //先选一个职业id var allPro = ConfigProfessionManager.Instance().allDatas; List <int> proIds = new List <int>(); foreach (var v in allPro.Keys) { proIds.Add(v); } int proId = proIds[UnityEngine.Random.Range(0, proIds.Count)]; //根据这个id 凑满该职业的最大数量的角色 var proData = allPro[proId]; //该职业生效的最大数量 int maxRoleNumbers = proData.counts[proData.counts.Length - 1]; //获取该职业的所有角色id List <int> roleIds = new List <int>(); foreach (var roleData in ConfigRoleManager.Instance().allDatas) { if (roleData.Value.proId == proId) { roleIds.Add(roleData.Key); } } //拿到随机出来的角色id var resRoleIds = DataHelp.GetRandom(roleIds, maxRoleNumbers); //然后再补全剩下的role ID var restRoleIds = DataHelp.GetRandomKeyInDic(ConfigRoleManager.Instance().allDatas, 9 - maxRoleNumbers); int[] ids = new int[9]; Array.ConstrainedCopy(resRoleIds, 0, ids, 0, resRoleIds.Length); Array.ConstrainedCopy(restRoleIds, 0, ids, resRoleIds.Length, restRoleIds.Length); //随机9把武器 随机9件防具 int[] wuqiIds = DataHelp.GetRandom(EquipModel.typeEquipIds[0], 9); int[] fangjuIds = DataHelp.GetRandom(EquipModel.typeEquipIds[1], 9); //key 是索引 value 是 id 等级 武器 防具 currentRoles = new Dictionary <int, int[]>(); for (int i = 0; i < 9; i++) { currentRoles.Add(i, new int[] { ids[i], UnityEngine.Random.Range(2, 4), wuqiIds[i], fangjuIds[i] }); } } var aiModel = ModelManager.Get("AIModel") as AIModel; aiModel.ClearRole(); //TODO 给ai队列加入装备 foreach (var v in currentRoles) { aiModel.SetAIRole(v.Key, v.Value[0], v.Value[1], v.Value[2], v.Value[3]); } aiModel.UpdateAiCooperData(); }