// 触发动作(触发条件调用,继承自sdBehaviourAction)aa public override void DoSyncAction() { if (!BundleGlobal.IsMobile()) { //Debug.Log("sdSummonBehaviourAction::DoSyncAction"); } if (mSummonLevelArea == null) { GameObject kSummonLevelAreaObject = GameObject.Find(mLevelAreaName); if (kSummonLevelAreaObject) { mSummonLevelArea = kSummonLevelAreaObject.GetComponent <sdLevelArea>(); } if (mSummonLevelArea == null) { return; } } sdSummonBehaviourAction kDelaySummonBehaviourAction = this.Clone() as sdSummonBehaviourAction; kDelaySummonBehaviourAction.TimeStamp = Time.time; kDelaySummonBehaviourAction.mSummonLevelArea = this.mSummonLevelArea; mBehaviourAdvancedState.AddBehaviourActionToDelayList(kDelaySummonBehaviourAction); }
// 接口实现(ICloneable的接口)aa public override object Clone() { sdSummonBehaviourAction kSummonBehaviourAction = new sdSummonBehaviourAction(); kSummonBehaviourAction.mCount = this.Count; kSummonBehaviourAction.mDelayTime = this.mDelayTime; kSummonBehaviourAction.mIntervalTime = this.mIntervalTime; kSummonBehaviourAction.mTimeStamp = this.mTimeStamp; kSummonBehaviourAction.mBehaviourAdvancedState = this.mBehaviourAdvancedState; kSummonBehaviourAction.LevelAreaName = this.LevelAreaName; return(kSummonBehaviourAction); }
// 加载行为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); }