Пример #1
0
    /// <summary>
    /// 持续触发
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerStay(Collider other)
    {
        if (CallBack == null)
        {
            return;
        }
        int otherLayer = (int)Mathf.Pow(2, other.gameObject.layer);
        int result     = checkLayer.value | otherLayer;

        if (result == checkLayer.value)//包含检测的层
        {
            IObjInteractive iObjInteractive = other.gameObject.GetComponent <IObjInteractive>();
            if (iObjInteractive != null)
            {
                CallBack(iObjInteractive);
            }
        }
    }
Пример #2
0
    /// <summary>
    /// 检测到攻击触发到对象(注意通过该函数实现的都是物理攻击,魔法攻击请在各自的子类中独立实现)
    /// </summary>
    /// <param name="iOjbInteractive"></param>
    protected virtual void CheckTargetResult(IObjInteractive iOjbInteractive)
    {
        if (NowCheckFrame == null)
        {
            return;
        }
        if (attackAnimationTime > NowCheckFrame.endTime || attackAnimationTime < NowCheckFrame.startTime)
        {
            return;
        }
        if (tempCheckedTargetList.Contains(iOjbInteractive))
        {
            return;
        }
        tempCheckedTargetList.Add(iOjbInteractive);
        //计算伤害
        MonsterControl monsterControl = GetComponent <MonsterControl>();

        if (monsterControl == null)
        {
            return;
        }
        IAttributeState iAttributeState = monsterControl.GetMonsterAttributeState();

        if (iAttributeState == null)
        {
            return;
        }
        iAttributeState.PhysicsAttacking *= NowCheckFrame.magnification;
        AttackHurtStruct attackHurtStruct = new AttackHurtStruct()
        {
            attributeState       = iAttributeState,
            hurtFromObj          = gameObject,
            hurtType             = EnumHurtType.NormalAction,                 //怪物的伤害都依照普通攻击来计算(普通攻击和技能的区别暂时不知道)
            statusLevelDataInfos = new StatusDataInfo.StatusLevelDataInfo[0], //暂时没有附加状态
            hurtTransferNum      = 0,
            thisUsedMana         = 0                                          //物理技能没有耗魔
        };

        iOjbInteractive.GiveAttackHurtStruct(attackHurtStruct);
    }