/// <summary> /// 当triggerType指定的事件发生时, 检查randEventContainer列表, 触发随机事件. /// </summary> /// <param name="theOther">触发事件的单位.</param> /// <param name="eventOwner">为随机事件的拥有者.</param> /// <remarks>randevent的技能效果不由任何技能发起(只可以得知该随机事件是如何被注册的)</remarks> public static void ApplyRandEvent( BattleUnit theOther, BattleUnit eventOwner, BattleUnitRandEventContainer randEventContainer, RandEventTriggerType triggerType, RandEventArg triggerArg ) { List <uint> buffNeed2Remove = new List <uint>(); List <BattleUnitRandEvent> typedContainer = randEventContainer[triggerType]; //LinkedListNode<BattleUnitRandEvent> currentNode = typedContainer.First; // SkillScript可能产生新的randevent加入容器中, 导致容器改变, 因此不能通过foreach遍历. // 获取当前指定类型的容器中的元素个数, 只遍历当前的元素(新的randevent通过AddLast加入到容器中, 因此不会被遍历到). for (int i = typedContainer.Count - 1; i >= 0; --i) { BattleUnitRandEvent randEvent = typedContainer[i]; SkillRandEventTableItem randEventRes = randEvent.randEventResource; // 检查CD. if (randEvent.cdMilliseconds != 0) { continue; } // 检查概率. if (!SkillUtilities.Random100(randEventRes.probability)) { continue; } SkillClientBehaviour.AddEffect2Object(eventOwner, randEventRes._3DEffectID, randEventRes._3DEffectBindpoint); if (randEvent.mScript != null && !randEvent.mScript.RunScript(triggerArg)) { buffNeed2Remove.Add((uint)randEvent.fromBuffRes.resID); } randEvent.cdMilliseconds = randEventRes.cdMilliseconds; } // for (int count = typedContainer.Count; count != 0; --count, currentNode = currentNode.Next) // { // // } for (int i = 0; i < buffNeed2Remove.Count; ++i) { eventOwner.RemoveSkillBuffByResID(buffNeed2Remove[i]); } /* foreach (uint id in buffNeed2Remove)*/ }
/// <summary> /// 检测并在当前角色应用随机事件. /// </summary> /// <param name="attackerAttr">触发该事件的角色的属性</param> /// <param name="skillCommonResID">触发该事件的技能ID</param> /// <param name="type">事件触发类型</param> public void ApplyRandEvent(BattleUnit theOther, RandEventTriggerType type, RandEventArg argument) { SkillDetails.ApplyRandEvent(theOther, this, mRandEventContainer, type, argument); }
/// <summary> ///获取指定类型的随机事件的容器. /// </summary> public List <BattleUnitRandEvent> this[RandEventTriggerType type] { get { return(mContainer[(int)type]); } }