//使用名字获得effectBasic效果信息 //重用行很好的方法 public static string getEffectInfromationWithName(string nameIn, GameObject theGameOBJ = null) { if (theGameOBJ == null) { theGameOBJ = transStatic.gameObject; } string information = ""; if (string.IsNullOrEmpty(nameIn)) { return("没有效果"); } System.Type thetype = System.Type.GetType(nameIn); effectBasic theEf = (effectBasic)theGameOBJ.GetComponent(thetype); if (theEf == null) { theEf = theGameOBJ.AddComponent(thetype) as effectBasic; theEf.Init(); } information = theEf.getInformation(); Destroy(theEf); return(information); }
void makeEffectInformation(StringBuilder theInformationString, StringBuilder theSkillInformationString, effectBasic theEffect, bool isSelf = true) { string colorUse = isSelf == true ? systemValues.SkillColorForSelf : systemValues.SkillColorForEnemy; string theTitle = isSelf == true ? "发动可触发" : "命中可触发"; theInformationString.Append(theTitle); theInformationString.Append("【"); theInformationString.Append(colorUse); theInformationString.Append(theEffect.theEffectName); theInformationString.Append(systemValues.colorEnd); theInformationString.Append("】"); if (theSkillInformationString.Length != 0) { theSkillInformationString.Append("\n\n"); } theSkillInformationString.Append(colorUse); theSkillInformationString.Append(theEffect.getInformation()); theSkillInformationString.Append(systemValues.colorEnd); string skilladder = theEffect.getExtraInformation(); if (string.IsNullOrEmpty(skilladder) == false) { theSkillInformationString.Append("\n"); theSkillInformationString.Append(systemValues.SkillExtraColor); theSkillInformationString.Append(skilladder); theSkillInformationString.Append(systemValues.colorEnd); } string lvAdder = theEffect.getEffectAttackLinkLVExtra(); if (string.IsNullOrEmpty(lvAdder) == false) { theSkillInformationString.Append("\n"); theSkillInformationString.Append(systemValues.SkillColorForLink); theSkillInformationString.Append(theEffect.getEffectAttackLinkLVExtra()); theSkillInformationString.Append(systemValues.colorEnd); } }
//工具方法,更为复杂的方法 //用于连招的显示按钮等等信息的全部获取 public static List <attackLinkInformation> getEffectInformationsMore(GameObject thePlayer, bool withAttackLinkEffect = false) { List <attackLinkInformation> theAttackLinkInformaitons = new List <attackLinkInformation> (); List <effectBasic> buffer = new List <effectBasic> (); string showString = ""; string showExtra = ""; //被动没有连招,但是也应该显示 effectBasic [] efs = thePlayer.GetComponentsInChildren <effectBasic>(); for (int i = 0; i < efs.Length; i++) { buffer.Add(efs[i]); efs [i].Init(); if (efs [i].isBE() && efs[i].isShowing()) { attackLinkInformation theInformation = new attackLinkInformation(); theInformation.attackLinkName = ""; theInformation.attackLinkString = ""; theInformation.theEffectForSelfName = efs[i].getEffectName(false, false); theInformation.theEffectForSelfInformaion = efs[i].getInformation(false) + "\n" + efs[i].getExtraInformation(); theAttackLinkInformaitons.Add(theInformation); } } //展示连招中触发的各种效果 if (withAttackLinkEffect) { attackLink[] attacklinks = thePlayer.GetComponentsInChildren <attackLink> (); //因为有顺序和统一调用的问题,建议建立之后统一进行销毁,因此建立一个预存。 foreach (attackLink ak in attacklinks) { ak.makeStart(); attackLinkInformation theInformation = new attackLinkInformation(); theInformation.attackLinkName = ak.skillName; theInformation.attackLinkString = ak.attackLinkString.Split(';')[0]; theInformation.thePlayer = thePlayer.GetComponentInChildren <PlayerBasic>(); theInformation.attackLinkInformationText = ak.getInformation(false); //获取简略的信息就足够了 //if (string.IsNullOrEmpty (ak.conNameToEMY) == false) if (!isNullOrEmpty(ak.conNameToEMY)) { //初始化一下效果 System.Type theType = System.Type.GetType(ak.conNameToEMY); //thePlayer.gameObject.AddComponent (theType); //effectBasic theEffect = thePlayer.gameObject.GetComponent (theType) as effectBasic; effectBasic theEffect = thePlayer.gameObject.AddComponent(theType) as effectBasic; buffer.Add(theEffect); if (theEffect.isShowing()) { theEffect.Init(); theInformation.theEffectForEMYName = theEffect.getEffectName(true, true); showString = theEffect.getInformation(false); showExtra = theEffect.getExtraInformation(); if (isNullOrEmpty(showExtra) == false) { showString += "\n" + showExtra; } theInformation.theEffectForEMYInformaion = showString; } } //if (string.IsNullOrEmpty (ak.conNameToSELF) == false) if (!isNullOrEmpty(ak.conNameToSELF)) { //初始化一下效果 System.Type theType = System.Type.GetType(ak.conNameToSELF); //thePlayer.gameObject.AddComponent (theType); //effectBasic theEffect = thePlayer.gameObject.GetComponent (theType) as effectBasic; effectBasic theEffect = thePlayer.gameObject.AddComponent(theType) as effectBasic; buffer.Add(theEffect); if (theEffect.isShowing()) { theEffect.Init(); theInformation.theEffectForSelfName = theEffect.getEffectName(true, true); showString = theEffect.getInformation(false); showExtra = theEffect.getExtraInformation(); if (isNullOrEmpty(showExtra) == false) { showString += "\n" + showExtra; } theInformation.theEffectForSelfInformaion = showString; } } theAttackLinkInformaitons.Add(theInformation); } //清空预存 for (int i = 0; i < buffer.Count; i++) { DestroyImmediate(buffer [i]); } } return(theAttackLinkInformaitons); }