コード例 #1
0
ファイル: KCharacter.cs プロジェクト: zuojiashun/src
    public SKILL_RESULT_CODE CastSkill(uint dwSkillID, ref KTarget pTarget)
    {
        int nRetCode = 0;
        SKILL_RESULT_CODE nResult          = SKILL_RESULT_CODE.srcFailed;
        KCharacter        pTargetCharacter = null;

        if (m_pEntity == null)
        {
            return(SKILL_RESULT_CODE.srcFailed);
        }

        ISkillPart skillPart = m_pEntity.GetPart(EntityPart.Skill) as ISkillPart;

        if (skillPart == null)
        {
            return(SKILL_RESULT_CODE.srcFailed);
        }

        if (pTarget == null)
        {
            return(SKILL_RESULT_CODE.srcFailed);
        }

        nRetCode = pTarget.GetTarget(ref pTargetCharacter);
        if (nRetCode == 0 || pTargetCharacter == null)
        {
            return(SKILL_RESULT_CODE.srcFailed);
        }

        IEntity targetEntity = pTargetCharacter.m_pEntity;

        if (targetEntity == null)
        {
            return(SKILL_RESULT_CODE.srcFailed);
        }

        skillPart.ReqNpcUseSkill(targetEntity, dwSkillID);


        //
        KSkill pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID);

        pSkill.Cast(this, this, ref pTarget);



        //测试代码
        // 伤害飘子
        //FlyFontDataManager.Instance.ShowDamage(999, 1, pTargetCharacter.m_dwID, EntityType.EntityType_NPC, 1000000);
        //pTargetCharacter.Test_ConcludeResult();



        nResult = SKILL_RESULT_CODE.srcSuccess;
Exit0:
        return(nResult);
    }
コード例 #2
0
ファイル: KSkill.cs プロジェクト: zuojiashun/src
    //以目标为中心的圆形区域
    SKILL_RESULT_CODE CastOnTargetArea(KCharacter pDisplayCaster, KCharacter pLogicCaster, ref KTarget rTarget)
    {
        SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed;
        int           nRetCode    = 0;
        KSKILL_BULLET pBullet     = new KSKILL_BULLET();

        float fTargetX = 0f;
        float fTargetZ = 0f;

        nRetCode = SetupBullet(pBullet, pLogicCaster, ref rTarget);
        if (nRetCode == 0)
        {
            goto Exit0;
        }


        if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop)
        {
            pLogicCaster.AddBullet(pBullet);
        }
        else
        {
            nRetCode = rTarget.GetTarget(ref fTargetX, ref fTargetZ);
            if (nRetCode == 0)
            {
                goto Exit0;
            }

            nRetCode = (int)ApplyOnSingle(pBullet);
            if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess)
            {
                return((SKILL_RESULT_CODE)nRetCode);
            }

            nRetCode = (int)ApplyOnArea(pBullet, fTargetX, fTargetZ);
            if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess)
            {
                return((SKILL_RESULT_CODE)nRetCode);
            }
        }


        nResult = SKILL_RESULT_CODE.srcSuccess;
Exit0:
        return(nResult);
    }
コード例 #3
0
ファイル: KSkill.cs プロジェクト: zuojiashun/src
    public SKILL_RESULT_CODE CheckTargetRange(KCharacter pCaster, ref KTarget rTarget)
    {
        SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed;
        int nRetCode = 0;

        float fMaxRange   = 0f;
        float fCasterX    = 0f;
        float fCasterZ    = 0f;
        float fTargetX    = 0f;
        float fTargetZ    = 0f;
        float fTouchRange = 0f;

        pCaster.GetAbsoluteCoordinate(ref fCasterX, ref fCasterZ);

        nRetCode = rTarget.GetTarget(ref fTargetX, ref fTargetZ);
        if (nRetCode == 0)
        {
            goto Exit0;
        }

        fMaxRange = pCaster.m_fTouchRange + m_fMaxRadius + fTouchRange;

        nRetCode = (int)SkillInRange(fCasterX, fCasterZ, fTargetX, fTargetZ, m_fMinRadius, fMaxRange);
        if (nRetCode == (int)IN_RANGE_RESULT.irrTooClose)
        {
            return(SKILL_RESULT_CODE.srcTooCloseTarget);
        }
        if (nRetCode == (int)IN_RANGE_RESULT.irrTooFar)
        {
            return(SKILL_RESULT_CODE.srcTooFarTarget);
        }
        if (nRetCode != (int)IN_RANGE_RESULT.irrInRange)
        {
            goto Exit0;
        }

        nResult = SKILL_RESULT_CODE.srcSuccess;
Exit0:
        return(nResult);
    }
コード例 #4
0
ファイル: KSkill.cs プロジェクト: zuojiashun/src
    int SetupBullet(KSKILL_BULLET pBullet, KCharacter pCaster, ref KTarget rTarget)
    {
        int        nResult     = 0;
        int        nRetCode    = 0;
        float      fCasterX    = 0f;
        float      fCasterZ    = 0f;
        float      fTargetX    = 0f;
        float      fTargetZ    = 0f;
        KCharacter pTarget     = null;
        float      fTouchRange = 0f;
        float      fDistance   = 0f;
        float      fHitDelay   = 0f;

        if (pBullet == null)
        {
            goto Exit0;
        }
        if (pCaster == null)
        {
            goto Exit0;
        }
        if (rTarget == null)
        {
            goto Exit0;
        }

        pBullet.dwBulletID    = FirstFightMgr.Instance().m_SkillManager.m_dwBulletIDIndex++;
        pBullet.pTarget       = rTarget;
        pBullet.pSkillSrc     = pCaster;
        pBullet.dwSkillSrcID  = pCaster.m_dwID;
        pBullet.pSkillPointer = this;
        pBullet.pNext         = null;

        switch (m_pBaseInfo.nCastMode)
        {
        case KSKILL_CAST_MODE.scmTargetSingle:
            break;

        default:
            break;
        }

        pCaster.GetAbsoluteCoordinate(ref fCasterX, ref fCasterZ);

        rTarget.GetTarget(ref fTargetX, ref fTargetZ);

        nRetCode = rTarget.GetTarget(ref pTarget);
        if (pTarget != null)
        {
            fTouchRange = pTarget.m_fTouchRange;
        }

        fDistance = KAI_SEARCH_CHARACTER.s_GetDistance2(fCasterX, fCasterZ, fTargetX, fTargetZ);
        if (fDistance > fTouchRange)
        {
            fDistance -= fTouchRange;
        }

        if (m_fBulletVelocity > 0f)
        {
            fHitDelay = (fDistance / m_fBulletVelocity);
        }

        int nHitDelay = ((int)(fHitDelay * 16)) + (int)FirstFightMgr.Instance().m_nGameLoop + m_pBaseInfo.nHitDelay;

        pBullet.nEndFrame = nHitDelay;

        nResult = 1;
Exit0:
        return(nResult);
    }
コード例 #5
0
ファイル: KSkill.cs プロジェクト: zuojiashun/src
    public SKILL_RESULT_CODE Cast(KCharacter pDisplayCaster, KCharacter pLogicCaster, ref KTarget rTarget)
    {
        SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed;
        int        nRetCode       = 0;
        KCharacter pTarget        = null;

        if (pDisplayCaster == null)
        {
            goto Exit0;
        }

        if (pLogicCaster == null)
        {
            goto Exit0;
        }
        //...

        switch (rTarget.GetTargetType())
        {
        case TARGET_TYPE.ttPlayer:
        case TARGET_TYPE.ttNpc:

            nRetCode = rTarget.GetTarget(ref pTarget);
            if (nRetCode == 0)
            {
                goto Exit0;
            }

            break;

        default:
            break;
        }

        switch (m_pBaseInfo.nCastMode)
        {
        case KSKILL_CAST_MODE.scmSector:    // 扇形范围,扇心固定在自己
            nRetCode = (int)CastOnSector(pDisplayCaster, pLogicCaster);
            break;

        case KSKILL_CAST_MODE.scmCasterArea:    // 以自己为中心的圆形区域
            nRetCode = (int)CastOnCasterArea(pDisplayCaster, pLogicCaster);
            break;

        case KSKILL_CAST_MODE.scmTargetSingle:     // 对单体对象(指定目标)施放
            nRetCode = (int)CastOnTargetSingle(pDisplayCaster, pLogicCaster, ref rTarget);
            break;

        case KSKILL_CAST_MODE.scmCasterSingle:    // 对单体对象(限于自己)施放
            nRetCode = (int)CastOnCasterSingle(pDisplayCaster, pLogicCaster);
            break;

        case KSKILL_CAST_MODE.scmTargetArea:    // 以目标为中心的圆形区域
            nRetCode = (int)CastOnTargetArea(pDisplayCaster, pLogicCaster, ref rTarget);
            break;

        default:
            goto Exit0;
            break;
        }

        if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess)
        {
            return((SKILL_RESULT_CODE)nRetCode);
        }


        nResult = SKILL_RESULT_CODE.srcSuccess;
Exit0:
        return(nResult);
    }