Example #1
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;
        }
    }
Example #2
0
    protected virtual void onDie(AttackerAttr killerAttr, ImpactDamageType impactDamageType)
    {
        MaterialTableItem material = null;
        uint materialID            = GetMaterialResourceID();

        if (materialID != uint.MaxValue)
        {
            material = DataManager.MaterialTable[materialID] as MaterialTableItem;
        }
        bool operate = false;

        //根据材质修正尸体的存在时间
        if (impactDamageType < ImpactDamageType.Count)
        {
            if (material != null)
            {
                MaterialItem item = material.items[(int)impactDamageType];
                if (item.deatdelay >= 0)
                {
                    mWaitTime      = item.deatdelay;
                    mDisappearTime = 0;
                    operate        = true;
                }
            }
        }

        if (!operate)
        {
            mWaitTime      = mMaxWaitDisappearTime;
            mDisappearTime = mMaxDisappearTime;
        }

        // 检查击杀的随机事件.
        BattleUnit killer = killerAttr.CheckedAttackerObject();

        // 检查是否是自杀.
        if (killer != null && InstanceID != killerAttr.AttackerID)
        {
            killer.OnKillOther(killerAttr, this);
        }

        // 系统回收不触发死亡事件, 自杀依然触发.
        // 如果凶手通过随机事件杀死this, 那么不触发this的随机事件.
        if (killerAttr.AttackerID != uint.MaxValue && !killerAttr.StructMadeByRandEvent)
        {
            ApplyRandEvent(killer, RandEventTriggerType.OnBeKilled, new OnBeKilledEventArg(killerAttr));
        }

        // 通知skilleffect的清理.
        SkillDetails.OnSkillEffectOwnerEvent(mSkillEffectManager, SkillEffectOwnerEventDef.OwnerDie);

        if (material != null && impactDamageType < ImpactDamageType.Count)
        {
            MaterialItem item = material.items[(int)impactDamageType];
            if (item.mtl)
            {
                ////火死亡
                if (impactDamageType == ImpactDamageType.Fire)
                {
                    SetDeathMaterial("burn_out");
                }
                ////毒死亡
                if (impactDamageType == ImpactDamageType.Poison)
                {
                    SetDeathMaterial("poison");
                }
                //冰死亡
                if (impactDamageType == ImpactDamageType.Frost)
                {
                    SetDeathMaterial("iceimpact");
                }
            }
        }

        // 死亡特效, 声音, 动作等.
        // 当所有的效果, 动作都结束时, 开始死亡动作.
        if (mActionCenter != null)
        {
            ErrorHandler.Parse(
                mActionCenter.StartAction(new ActionDieInitParam()
            {
                attackerAttr = killerAttr, damageType = impactDamageType
            }),
                "failed to create action die"
                );
        }

        DieAward(killerAttr.AttackerID);
    }