// 接口实现(ICloneable的接口)aa public override object Clone() { sdBuffBehaviourAction kBuffBehaviourAction = new sdBuffBehaviourAction(); kBuffBehaviourAction.mCount = this.Count; kBuffBehaviourAction.mDelayTime = this.mDelayTime; kBuffBehaviourAction.mIntervalTime = this.mIntervalTime; kBuffBehaviourAction.mTimeStamp = this.mTimeStamp; kBuffBehaviourAction.mBehaviourAdvancedState = this.mBehaviourAdvancedState; kBuffBehaviourAction.mBuffID = this.mBuffID; kBuffBehaviourAction.mBuffProbility = this.mBuffProbility; kBuffBehaviourAction.mBuffBehaviourActionTargetType = this.mBuffBehaviourActionTargetType; return(kBuffBehaviourAction); }
// 触发动作(触发条件调用,继承自sdBehaviourAction)aa public override void DoSyncAction() { // if (!BundleGlobal.IsMobile()) // { // Debug.Log ("sdBuffBehaviourAction::DoSyncAction"); // } float fRandom = UnityEngine.Random.Range(0, 10000) / 10000.0f; if (fRandom <= mBuffProbility) { sdBuffBehaviourAction kDelayBuffBehaviourAction = this.Clone() as sdBuffBehaviourAction; kDelayBuffBehaviourAction.TimeStamp = Time.time; mBehaviourAdvancedState.AddBehaviourActionToDelayList(kDelayBuffBehaviourAction); } }
// 加载行为aa protected sdBehaviourAction LoadBehaviourAction(XmlNode kXmlNode) { XmlElement kXmlElement = (XmlElement)kXmlNode; if (kXmlElement.Name != "AIAction") { return(null); } sdBehaviourAction kBehaviourAction = null; int iID = int.Parse(kXmlElement.GetAttribute("id")); int iDelay = int.Parse(kXmlElement.GetAttribute("delay")); int iCount = int.Parse(kXmlElement.GetAttribute("count")); int iInterval = int.Parse(kXmlElement.GetAttribute("interval")); if (iID == (int)EBehaviourActionType.enBAT_Summon) { sdSummonBehaviourAction kSummonBehaviourAction = new sdSummonBehaviourAction(); kSummonBehaviourAction.DelayTime = iDelay / 1000.0f; kSummonBehaviourAction.IntervalTime = iInterval / 1000.0f; kSummonBehaviourAction.Count = iCount; kSummonBehaviourAction.LevelAreaName = kXmlElement.GetAttribute("param1") as string; kBehaviourAction = kSummonBehaviourAction; } else if (iID == (int)EBehaviourActionType.enBAT_Skill) { sdSkillBehaviourAction kSkillBehaviourAction = new sdSkillBehaviourAction(); kSkillBehaviourAction.DelayTime = iDelay / 1000.0f; kSkillBehaviourAction.IntervalTime = iInterval / 1000.0f; kSkillBehaviourAction.Count = iCount; kSkillBehaviourAction.SkillGroupProbility = int.Parse(kXmlElement.GetAttribute("param1")) / 10000.0f; string kSkilllIDGroup = kXmlElement.GetAttribute("param2") as string; string kSkilllProbilityGroup = kXmlElement.GetAttribute("param3") as string; string[] kSkilllIDArray = kSkilllIDGroup.Split(';'); string[] kSkilllProbilityArray = kSkilllProbilityGroup.Split(';'); for (int i = 0; i < kSkilllIDArray.Length; ++i) { int iSkillID = int.Parse(kSkilllIDArray[i]); float fSkillProbility = int.Parse(kSkilllProbilityArray[i]) / 10000.0f; kSkillBehaviourAction.AddSkill(iSkillID, fSkillProbility); } if (kXmlElement.HasAttribute("param4")) { string kDetectDistance = kXmlElement.GetAttribute("param4") as string; if (kDetectDistance != null) { kSkillBehaviourAction.DetectDistance = (int.Parse(kDetectDistance) != 0); } } kBehaviourAction = kSkillBehaviourAction; } else if (iID == (int)EBehaviourActionType.enBAT_Buff) { sdBuffBehaviourAction kBuffBehaviourAction = new sdBuffBehaviourAction(); kBuffBehaviourAction.DelayTime = iDelay / 1000.0f; kBuffBehaviourAction.IntervalTime = iInterval / 1000.0f; kBuffBehaviourAction.Count = iCount; kBuffBehaviourAction.BuffID = int.Parse(kXmlElement.GetAttribute("param1")); kBuffBehaviourAction.BuffBehaviourActionTargetType = (EBuffBehaviourActionTargetType)(int.Parse(kXmlElement.GetAttribute("param2"))); if (kXmlElement.HasAttribute("param3")) { string kBuffProbility = kXmlElement.GetAttribute("param3") as string; if (kBuffProbility != null) { kBuffBehaviourAction.BuffProbility = int.Parse(kBuffProbility) / 10000.0f; } } kBehaviourAction = kBuffBehaviourAction; } return(kBehaviourAction); }