Example #1
0
    override public bool Init(ObjectInitParam param)
    {
        if (!base.Init(param))
        {
            return(false);
        }

        mHomePosition.x = mPosition.x;
        mHomePosition.y = mPosition.y;
        mHomePosition.z = mPosition.z;

        mProperty = new RoleProperty();

        mActionCenter         = new BattleUnitActionCenter(this);
        mSkillContainer       = new BattleUnitSkillContainer();
        mSkillEffectManager   = new SkillEffectManager(this);
        mActiveFlagsContainer = new ActiveFlagsContainer();
        mRandEventContainer   = new BattleUnitRandEventContainer();

        mHitMaterialEffectCdContainer = new HitMaterialEffectCdContainer();

        // 默认透明度为100.
        SetBaseProperty((int)PropertyTypeEnum.PropertyTypeAlpha, 100);

        // 默认硬直抗性为100.
        SetBaseProperty((int)PropertyTypeEnum.PropertyTypeSpasticityResistance, 100);

        SetBaseProperty((int)PropertyTypeEnum.PropertyTypeScale_Rate, 100);

        return(true);
    }
Example #2
0
    /// <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)*/
    }
Example #3
0
    public static ErrorCode RemoveRandEvent(BattleUnit owner,
                                            BattleUnitRandEventContainer randEventContainer,
                                            SkillBuffTableItem buffRes,
                                            SkillEffectStopReason stopReason
                                            )
    {
        if (buffRes.randEvent == uint.MaxValue)
        {
            return(ErrorCode.Succeeded);
        }

        randEventContainer.Remove(buffRes, stopReason);

        return(ErrorCode.Succeeded);
    }
Example #4
0
    /// <summary>
    /// 添加randEventResourceID指定的skillrandevent资源.
    /// </summary>
    /// <param name="randEventResourceID"></param>
    public static ErrorCode AddRandEvent(BattleUnit owner,
                                         BattleUnitRandEventContainer randEventContainer,
                                         SkillBuffTableItem buffRes,
                                         AttackerAttr buffCreaterAttr
                                         )
    {
        if (buffRes.randEvent == uint.MaxValue)
        {
            return(ErrorCode.Succeeded);
        }

        SkillRandEventTableItem randEventRes = DataManager.RandEventTable[buffRes.randEvent] as SkillRandEventTableItem;

        randEventContainer.Add(owner, buffRes, randEventRes, ref buffCreaterAttr);

        return(ErrorCode.Succeeded);
    }
Example #5
0
    override public void Destroy()
    {
        if (mBattleUintAI != null)
        {
            mBattleUintAI.Destory();
            mBattleUintAI = null;
        }

        if (mActionCenter != null)
        {
            mActionCenter.Destroy();
            mActionCenter = null;
        }

        if (mSkillEffectManager != null)
        {
            SkillDetails.OnSkillEffectOwnerEvent(mSkillEffectManager, SkillEffectOwnerEventDef.OwnerLeaveScene);
            mSkillEffectManager.Destroy();
            mSkillEffectManager = null;
        }

        mActiveFlagsContainer = null;
        mRandEventContainer   = null;

        mHitMaterialEffectCdContainer = null;

        mProperty = null;

        mUIShield = null;

        base.Destroy();



        for (int i = 0; i < mAttachMents.Length; ++i)
        {
            AttachMent attach = mAttachMents[i];
            if (attach != null && attach.visual != null)
            {
                attach.visual.Destroy();
            }
            mAttachMents[i] = null;
        }
    }