public Skill(int id) { if (CfgManager.GetInstance().Skills.ContainsKey(id) == false) { Debug.LogErrorFormat("skill cfg not found: {0}", id); return; } CfgSkill cfg = CfgManager.GetInstance().Skills[id]; this.id = cfg.id; name = cfg.name; desc = cfg.desc; animation = cfg.animation; sound = cfg.sound; hiteffect = cfg.hiteffect; hitpoints = cfg.hitpoints; targettype = cfg.targettype; aoe = cfg.aoe; spcost = cfg.spcost; colddown = cfg.colddown; // skill effects int count = cfg.skilleffects.Length; if (count > 0) { skilleffects = new SkillEffect[count]; for (int i = 0; i < count; i++) { skilleffects[i] = SkillEffect.CreateSkillEffect(cfg.skilleffects[i], this); } } }
public static string GetImagePath(this CfgSkill skill) { string SkillIcon = "skill_" + skill.Icon + ".jpg"; string SkillWhenFail = "/images/ui/skillIcon/active_skill/skill_anyingjiqu.jpg"; try { string usedPath = MapPaths.GetPath("/images") + "skillIcon/"; if (File.Exists(usedPath + SkillIcon)) { return("/images/skillIcon/" + SkillIcon); } usedPath = MapPaths.GetPath("/images") + "ui/skillIcon/active_skill/"; if (File.Exists(usedPath + SkillIcon)) { return("/images/ui/skillIcon/active_skill/" + SkillIcon); } usedPath = MapPaths.GetPath("/images") + "ui/skillIcon/passive_skill/"; if (File.Exists(usedPath + SkillIcon)) { return("/images/ui/skillIcon/passive_skill/" + SkillIcon); } return(SkillWhenFail); } catch (Exception ex) { return(SkillWhenFail); } }
public static CfgSkillWeb Create(ToH_Database_WebContext context, long ID) { CfgSkillWeb ret = new CfgSkillWeb(); CfgSkill skill = (from c in context.CfgSkill select c).Where(c => c.Id == ID).FirstOrDefault(); ret.Skill = skill; if (skill != null) { string[] effects = skill.Skill_effects.Split(";"); ret.Effects = (from c in context.CfgSkillEffect select c).Where(c => effects.Contains(c.Id.ToString())).ToList(); } return(ret); }
public static string GetDescription(this CfgSkill skill) { return(Translate("TextSkill_" + skill.Id + "_description", "")); }
public static string GetName(this CfgSkill skill) { return(Translate("TextSkill_" + skill.Id + "_name", skill.Id.ToString())); }
internal static OutputValues AddUpdateSkillToAgent(string operationType, string userName, string skillName, Int32 skillLevel) { OutputValues output = new OutputValues(); try { CfgPersonQuery queryPerson = new CfgPersonQuery(); queryPerson.UserName = userName; queryPerson.TenantDbid = _configContainer.TenantDbId; CfgPerson person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (operationType == "Add") { if (person != null) { ICollection <CfgSkillLevel> agentSkills = person.AgentInfo.SkillLevels; bool flag = false; foreach (CfgSkillLevel checkSkill in agentSkills) { if (checkSkill.Skill.Name == skillName) { flag = true; break; } } if (!flag) { CfgSkillQuery querySkill = new CfgSkillQuery(); querySkill.TenantDbid = _configContainer.TenantDbId; querySkill.Name = skillName; CfgSkill skill = _configContainer.ConfServiceObject.RetrieveObject <CfgSkill>(querySkill); CfgSkillLevel skillToAdd = new CfgSkillLevel(_configContainer.ConfServiceObject, person); skillToAdd.Skill = skill; skillToAdd.Level = Convert.ToInt32(skillLevel); person.AgentInfo.SkillLevels.Add(skillToAdd); person.Save(); } } } else if (operationType == "Edit") { if (person != null) { ICollection <CfgSkillLevel> agentSkills = person.AgentInfo.SkillLevels; foreach (CfgSkillLevel editingSkill in agentSkills) { if (editingSkill.Skill.Name == skillName) { editingSkill.Level = Convert.ToInt32(skillLevel); person.Save(); break; } } } } output.MessageCode = "200"; output.Message = "Skill " + operationType + "ed Successfully."; person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (person != null) { //Update the skill level to MySkills if (person.AgentInfo.SkillLevels != null && person.AgentInfo.SkillLevels.Count > 0) { Datacontext.GetInstance().MySkills.Clear(); foreach (CfgSkillLevel skill in person.AgentInfo.SkillLevels) { Datacontext.GetInstance().MySkills.Add(new Agent.Interaction.Desktop.Helpers.MySkills(skill.Skill.Name.ToString(), skill.Level)); } } else { Datacontext.GetInstance().MySkills.Clear(); } } } catch (Exception commonException) { output.MessageCode = "2001"; output.Message = (commonException.InnerException == null ? commonException.Message : commonException.InnerException.Message); } return(output); }
public void Init() { // monster TextAsset asset = ResourceManager.Instance.LoadAsset("cfg/monster") as TextAsset; JsonData data = JsonMapper.ToObject(asset.text); foreach (string key in data.Keys) { JsonData value = data [key]; CfgMonster cfg = new CfgMonster(); cfg.id = int.Parse(key); cfg.name = (string)value["name"]; cfg.prefab = (string)value["prefab"]; m_Monsters.Add(cfg.id, cfg); } // skill asset = ResourceManager.Instance.LoadAsset("cfg/skill") as TextAsset; data = JsonMapper.ToObject(asset.text); foreach (string key in data.Keys) { JsonData value = data [key]; CfgSkill cfg = new CfgSkill(); cfg.id = int.Parse(key); cfg.name = (string)value["name"]; cfg.desc = (string)value["desc"]; cfg.animation = (string)value["animation"]; cfg.effect = (string)value["effect"]; cfg.sound = (string)value["sound"]; cfg.hiteffect = (string)value["hiteffect"]; cfg.spcost = (int)value["spcost"]; cfg.colddown = (int)value["colddown"] / 1000f; cfg.targettype = (SkillTarget)(int)value["targettype"]; cfg.aoe = (byte)value["aoe"]; JsonData effects = value["skilleffect"]; cfg.skilleffects = new int[effects.Count]; for (int i = 0; i < effects.Count; i++) { cfg.skilleffects[i] = (int)effects[i]; } JsonData points = value["hitpoint"]; cfg.hitpoints = new int[points.Count]; for (int i = 0; i < points.Count; i++) { cfg.hitpoints[i] = (int)points[i]; } m_Skills.Add(cfg.id, cfg); } // skill effect asset = ResourceManager.Instance.LoadAsset("cfg/skilleffect") as TextAsset; data = JsonMapper.ToObject(asset.text); foreach (string key in data.Keys) { JsonData value = data [key]; CfgSkillEffect cfg = new CfgSkillEffect(); cfg.id = int.Parse(key); cfg.name = (string)value["name"]; cfg.trigger = (SkillEffectTrigger)(int)value["trigger"]; cfg.operation = (SkillEffectOperation)(int)value["operation"]; JsonData args = value["args"]; cfg.args = new int[args.Count]; for (int i = 0; i < args.Count; i++) { cfg.args[i] = (int)args[i]; } m_SkillEffects.Add(cfg.id, cfg); } // skill summon asset = ResourceManager.Instance.LoadAsset("cfg/skillsummon") as TextAsset; data = JsonMapper.ToObject(asset.text); foreach (string key in data.Keys) { JsonData value = data [key]; CfgSkillSummon cfg = new CfgSkillSummon(); cfg.id = int.Parse(key); cfg.name = (string)value["name"]; cfg.prefab = (string)value["prefab"]; cfg.speed = (int)value["speed"]; cfg.life = (int)value["life"] / 1000f; cfg.hitmax = (int)value["hitmax"]; cfg.hiteffect = (string)value["hiteffect"]; JsonData effects = value["skilleffect"]; cfg.skilleffects = new int[effects.Count]; for (int i = 0; i < effects.Count; i++) { cfg.skilleffects[i] = (int)effects[i]; } m_SkillSummons.Add(cfg.id, cfg); } // buff asset = ResourceManager.Instance.LoadAsset("cfg/buff") as TextAsset; data = JsonMapper.ToObject(asset.text); foreach (string key in data.Keys) { JsonData value = data [key]; CfgBuff cfg = new CfgBuff(); cfg.id = int.Parse(key); cfg.name = (string)value["name"]; cfg.prefab = (string)value["prefab"]; cfg.life = (int)value["life"] / 1000f; cfg.operation = (BuffOperation)(int)value["operation"]; JsonData args = value["args"]; cfg.args = new int[args.Count]; for (int i = 0; i < args.Count; i++) { cfg.args[i] = (int)args[i]; } m_Buffs.Add(cfg.id, cfg); } }