private void extraDamageEffect(PlayerBasic playerAim) //额外添加挂在的计算脚本 { if (thePlayer.theAttackLinkNow != null && string.IsNullOrEmpty(thePlayer.theAttackLinkNow.conNameToEMY) == false) //效果不可叠加 { System.Type theType = System.Type.GetType(thePlayer.theAttackLinkNow.conNameToEMY); if (!playerAim.gameObject.GetComponent(theType)) { try { playerAim.gameObject.AddComponent(theType); //print("makeEffect3"); } catch { //无法添加这个效果 //那么就转换成伤害,造成2点真实伤害 thePlayer.OnAttack(playerAim, 2, true); //print ("canNotAddEMY"); } } else { effectBasic theEffect = playerAim.gameObject.GetComponent(theType) as effectBasic; theEffect.updateEffect(); //print ("update"); } thePlayer.theAttackLinkNow.conNameToEMY = ""; } }
//使用名字获得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); }
//额外增加效果的时候 public void setEffect(effectBasic theEffectIn) { theButton.gameObject.SetActive(true); theEffect = theEffectIn; isEffecting = theEffectIn.isEffecting; theFillAmountImage.color = theEffect.isEffecting ? EffectColor : NotEffectColor; }
//获得连招的效果信息 string getAttacklinkEffectInformation(attackLink theAttacklink, GameObject theButton, out string theSkillInformation) { StringBuilder theInformationString = new StringBuilder(); StringBuilder theSkillInformationString = new StringBuilder(); if (systemValues.isNullOrEmpty(theAttacklink.conNameToSELF) == false) { System.Type theType = System.Type.GetType(theAttacklink.conNameToSELF); //theButton.gameObject.AddComponent (theType); ////effectBasic theselfEffect = theButton.GetComponent <effectBasic> (); //effectBasic theselfEffect = (effectBasic)theButton.GetComponent (theType); effectBasic theselfEffect = (effectBasic)theButton.gameObject.AddComponent(theType); theselfEffect.Init(); makeEffectInformation(theInformationString, theSkillInformationString, theselfEffect); Destroy(theselfEffect); } if (systemValues.isNullOrEmpty(theAttacklink.conNameToEMY) == false) { System.Type theType = System.Type.GetType(theAttacklink.conNameToEMY); //theButton.gameObject.AddComponent (theType); ////effectBasic theEMYEffect = theButton.GetComponent <effectBasic> (); //effectBasic theEMYEffect = (effectBasic)theButton.GetComponent (theType); effectBasic theEMYEffect = (effectBasic)theButton.gameObject.AddComponent(theType); theEMYEffect.Init(); makeEffectInformation(theInformationString, theSkillInformationString, theEMYEffect, false); Destroy(theEMYEffect); } theSkillInformation = theSkillInformationString.ToString(); return(theInformationString.ToString()); }
//检查这个效果是不是已经在显示中了 bool checkIfIsShowing(effectBasic theEffect) { for (int i = 0; i < flashItem.Count; i++) { if (flashItem [i].theEffect == theEffect && (theEffect != null)) { return(true); } } return(false); }
private bool isEffecting = true; //保存引用,这样就不用每一次都颜色赋值了 public void makeStart(GameObject theEffectShowButton, Transform father, effectBasic theEffectIn, Color effectColorIn, Color notEffectColorIn) { theButton = GameObject.Instantiate <GameObject> (theEffectShowButton); theButton.transform.SetParent(father.transform); //theButton.GetComponent <informationMouseShow> ().showText = theEffect.theEffectName + "\n" + theEffect.theEffectInformation; theShowText = theButton.GetComponentInChildren <Text> (); theFillAmountImage = theButton.transform.Find("CoolingFrontPicture").GetComponent <Image> (); EffectColor = effectColorIn; NotEffectColor = notEffectColorIn; theEffect = theEffectIn; isEffecting = theEffectIn.isEffecting; theFillAmountImage.color = theEffect.isEffecting ? EffectColor : NotEffectColor; }
private void extraDamageEffect(PlayerBasic playerAim) //额外添加挂在的计算脚本 { if (thePlayer.theAttackLinkNow != null && systemValues.isNullOrEmpty(thePlayer.theAttackLinkNow.conNameToEMY) == false) //效果不可叠加 { //System.Type theType = System.Type.GetType (thePlayer.theAttackLinkNow.conNameToEMY); System.Type theType = thePlayer.theAttackLinkNow.EffectTypeForEMY; if (theType == null) { return; } effectBasic theEffect = playerAim.gameObject.GetComponent(theType) as effectBasic; if (!theEffect) { try { //print("makeEffect"); theEffect = (effectBasic)playerAim.gameObject.AddComponent(theType); theEffect.SetAttackLinkIndex(thePlayer.EffectAttackLinkIndex); theEffect.SetAttackLink(thePlayer.theAttackLinkNow); thePlayer.EffectAttackLinkIndex = 0; //刷新为初始数值 } catch (Exception E) { print(E.ToString()); //无法添加这个效果 //那么就转换成伤害,造成2点真实伤害 //thePlayer.OnAttack (playerAim,2,true); //print ("canNotAddEMY"); } } else { theEffect.updateEffect(); //theEffect.SetAttackLinkIndex(thePlayer.EffectAttackLinkIndex); //theEffect.SetAttackLink(thePlayer.theAttackLinkNow); //print ("update"); } thePlayer.theAttackLinkNow.conNameToEMY = ""; } }
//使用名字获得effectBasic效果信息 //重用行很好的方法 public static string getEffectNameWithName(string nameIn, GameObject theGameOBJ = null) { if (theGameOBJ == null) { theGameOBJ = transStatic.gameObject; } string information = ""; 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.theEffectName; Destroy(theEf); return(information); }
float theDistance = 0; //距离中间变量 private void extraEffectSELF() { if (thePlayer.theAttackLinkNow != null && systemValues.isNullOrEmpty(thePlayer.theAttackLinkNow.conNameToSELF) == false) //效果不可叠加 { //System.Type theType = System.Type.GetType (thePlayer.theAttackLinkNow.conNameToSELF); System.Type theType = thePlayer.theAttackLinkNow.EffectTypeForSelf; if (theType == null) { return; } effectBasic theEffect = thePlayer.gameObject.GetComponent(theType) as effectBasic; if (!theEffect) { try { theEffect = (effectBasic)thePlayer.gameObject.AddComponent(theType); theEffect.SetAttackLinkIndex(thePlayer.EffectAttackLinkIndex); theEffect.SetAttackLink(thePlayer.theAttackLinkNow); thePlayer.EffectAttackLinkIndex = 0; //刷新为初始数值 } catch (Exception E) { print(E.ToString()); //无法添加这个效果 //那么就转换成恢复效果,恢复2生命 //thePlayer.ActerHp += 2f; //print ("canNotAddSELF"); } } else { theEffect.updateEffect(); theEffect.SetAttackLinkIndex(thePlayer.EffectAttackLinkIndex); theEffect.SetAttackLink(thePlayer.theAttackLinkNow); thePlayer.EffectAttackLinkIndex = 0; //刷新为初始数值 } thePlayer.theAttackLinkNow.conNameToSELF = ""; } }
//工具方法,获得所有可显示的技能效果等等的信息 public static string getEffectInformations(GameObject thePlayer, bool withAttackLinkEffect = false) { List <effectBasic> buffer = new List <effectBasic> (); if (withAttackLinkEffect) { attackLink[] attacklinks = thePlayer.GetComponentsInChildren <attackLink> (); //因为有顺序和统一调用的问题,建议建立之后统一进行销毁,因此建立一个预存。 foreach (attackLink ak in attacklinks) { 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 (!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); } } } string skillsInformation = "\n"; string skillsNames = "\n"; effectBasic[] effects = thePlayer.GetComponents <effectBasic> (); foreach (effectBasic ef in effects) { ef.Init(); string showString = ef.getInformation(); string showExtra = ef.getExtraInformation(); if (ef.isShowing()) { skillsNames += ef.getEffectName(false) + "\n"; } if (string.IsNullOrEmpty(showExtra) == false) { showString += "\n" + showExtra; } skillsInformation += showString; if (string.IsNullOrEmpty(showString) == false) { skillsInformation += "\n\n"; } } //清空预存 if (withAttackLinkEffect) { for (int i = 0; i < buffer.Count; i++) { DestroyImmediate(buffer [i]); } } //return skillsInformation; return(skillsNames); }
//工具方法,更为复杂的方法 //用于连招的显示按钮等等信息的全部获取 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); }
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); } }