Exemplo n.º 1
0
    /// <summary>
    /// 添加材质特效和声音.
    /// </summary>
    public ErrorCode AddMaterialBehaviour(MaterialBehaviourDef name, ImpactDamageType impactDamageType, float dir)
    {
        // 无效的伤害类型.
        if (impactDamageType >= ImpactDamageType.Count)
        {
            return(ErrorCode.Succeeded);
        }

        if (name != MaterialBehaviourDef.OnMaterialDie && IsDead())
        {
            return(ErrorCode.TargetIsDead);
        }

        if (name == MaterialBehaviourDef.OnMaterialDie)
        {
            uint materialID = GetMaterialResourceID();

            if (materialID == uint.MaxValue)
            {
                ErrorHandler.Parse(ErrorCode.ConfigError, dbgGetIdentifier() + " 没有材质!");
                return(ErrorCode.ConfigError);
            }

            MaterialTableItem material = DataManager.MaterialTable[materialID] as MaterialTableItem;
            if (material == null)
            {
                SkillUtilities.ResourceNotFound("material", materialID);
                return(ErrorCode.ConfigError);
            }

            if (material.deathEffectWaitTime > 0)
            {
                Scene.GetDelayBehaviourManager().AddDelayBehaviour(this, name, impactDamageType, dir, material.deathEffectWaitTime);
                return(ErrorCode.Succeeded);
            }
        }

        return(SkillDetails.AddMaterialBehaviour(this, mHitMaterialEffectCdContainer, name, impactDamageType, dir));
    }
Exemplo n.º 2
0
    /// <summary>
    /// 添加材质特效和声音.
    /// </summary>
    /// <param name="owner">被添加特效和声音的单位</param>
    /// <param name="cdContainer">cd的容器, 该函数会检查并设置CD.</param>
    /// <param name="name">添加的类型(被击, 死亡等)</param>
    /// <param name="impactDamageType">impact的伤害类型</param>
    public static ErrorCode AddMaterialBehaviour(BattleUnit owner, HitMaterialEffectCdContainer cdContainer,
                                                 MaterialBehaviourDef name, ImpactDamageType impactDamageType, float dir
                                                 )
    {
        // 无效的伤害类型.
        if (impactDamageType >= ImpactDamageType.Count)
        {
            return(ErrorCode.Succeeded);
        }

        // CD中, 只有被击的材质特效有CD, 死亡材质特效没有CD.
        if (name == MaterialBehaviourDef.OnMaterialBeHit && cdContainer.IsCoolingDown(impactDamageType))
        {
            return(ErrorCode.CoolingDown);
        }

        uint materialID = owner.GetMaterialResourceID();

        if (materialID == uint.MaxValue)
        {
            ErrorHandler.Parse(ErrorCode.ConfigError, owner.dbgGetIdentifier() + " 没有材质!");
            return(ErrorCode.ConfigError);
        }

        MaterialTableItem material = DataManager.MaterialTable[materialID] as MaterialTableItem;

        if (material == null)
        {
            SkillUtilities.ResourceNotFound("material", materialID);
            return(ErrorCode.ConfigError);
        }

        if (name == MaterialBehaviourDef.OnMaterialBeHit)
        {
            cdContainer.StartCd(impactDamageType);
        }

        MaterialItem item = material.items[(int)impactDamageType];

        uint   effectID  = uint.MaxValue;
        uint   sound     = uint.MaxValue;
        string bindpoint = "";

        switch (name)
        {
        case MaterialBehaviourDef.OnMaterialBeHit:
            effectID  = item.hitEffect;
            bindpoint = material.hitEffectBindpoint;
            sound     = item.sound;
            // 被击材质特效在被击者身上播放.
/*				SkillClientBehaviour.AddEffect2Object(owner, effectID, bindpoint, dir);*/
            if (string.IsNullOrEmpty(bindpoint))
            {
                SkillClientBehaviour.AddSceneEffect(effectID, owner.GetPosition(), dir);
            }
            else
            {
                SkillClientBehaviour.AddEffect2Object(owner, effectID, bindpoint, dir);
            }
            break;

        case MaterialBehaviourDef.OnMaterialDie:
            effectID  = item.deathEffect;
            bindpoint = material.deathEffectBindpoint;
            if (string.IsNullOrEmpty(bindpoint))
            {
                SkillClientBehaviour.AddSceneEffect(effectID, owner.GetPosition(), dir);
            }
            else
            {
                SkillClientBehaviour.AddEffect2Object(owner, effectID, bindpoint, dir);
            }

            break;

        default:
            break;
        }

        if (sound != uint.MaxValue)
        {
            SkillClientBehaviour.PlaySound(sound);
        }

        return(ErrorCode.Succeeded);
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
0
    private bool checkMaterial()
    {
        DataType myName = DataType.DATA_MATERIAL;

        System.Type           T   = typeof(MaterialTableItem);
        IDictionaryEnumerator itr = DataManager.MaterialTable.GetEnumerator();

        while (itr.MoveNext())
        {
            MaterialTableItem item = itr.Value as MaterialTableItem;
            for (uint i = 0; i < (uint)ImpactDamageType.Count; ++i)
            {
                MaterialItem subItem     = item.items[i];
                uint         hitEffect   = subItem.hitEffect;
                uint         sound       = subItem.sound;
                uint         deathEffect = subItem.deathEffect;

                if (hitEffect != uint.MaxValue &&
                    !checkLink(myName, item.resID, DataType.DATA_EFFECT, hitEffect))
                {
                    return(false);
                }

                if (sound != uint.MaxValue &&
                    !checkLink(myName, item.resID, DataType.DATA_SOUND, sound))
                {
                    return(false);
                }

                if (deathEffect != uint.MaxValue &&
                    !checkLink(myName, item.resID, DataType.DATA_EFFECT, deathEffect))
                {
                    return(false);
                }
            }
        }
//      foreach (int key in DataManager.MaterialTable.Keys)
//      {
//          MaterialTableItem item = DataManager.MaterialTable[key] as MaterialTableItem;
//          for (uint i = 0; i < (uint)ImpactDamageType.Count; ++i)
//          {
//              MaterialItem subItem = item.items[i];
//              uint hitEffect = subItem.hitEffect;
//              uint sound = subItem.sound;
//              uint deathEffect = subItem.deathEffect;
//
//              if (hitEffect != uint.MaxValue
//                  && !checkLink(myName, key, DataType.DATA_EFFECT, hitEffect))
//                  return false;
//
//              if (sound != uint.MaxValue
//                  && !checkLink(myName, key, DataType.DATA_SOUND, sound))
//                  return false;
//
//              if (deathEffect != uint.MaxValue
//                  && !checkLink(myName, key, DataType.DATA_EFFECT, deathEffect))
//                  return false;
//          }
//      }

        return(true);
    }