Пример #1
0
    private bool TraverseNpc <T>(ref T Func)
    {
        bool bResult  = false;
        bool bRetCode = false;

        KSearchTactic rTactic = Func as KSearchTactic;

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

        for (int i = 0; i < m_NpcList.Count; ++i)
        {
            KNpc pNpc = m_NpcList[i];

            bRetCode = rTactic.OperatorSearch(pNpc);
            if (bRetCode == false)
            {
                goto Exit0;
            }
        }

        bResult = true;
Exit0:
        return(bResult);
    }
Пример #2
0
    public KNpc NewNpc()
    {
        int  nRetCode    = 0;
        bool bNpcRegFlag = false;

        KNpc pResult = null;
        KNpc pNpc    = new KNpc();

        nRetCode = FirstFightMgr.Instance().m_NpcSet.Register(pNpc, 0);
        if (nRetCode == 0)
        {
            goto Exit0;
        }

        bNpcRegFlag = true;

        nRetCode = pNpc.Init();
        if (nRetCode == 0)
        {
            goto Exit0;
        }

        pResult = pNpc;

Exit0:
        if (pResult == null)
        {
            if (bNpcRegFlag)
            {
                FirstFightMgr.Instance().m_NpcSet.Unregister(pNpc);
                bNpcRegFlag = false;
            }
        }
        return(pResult);
    }
Пример #3
0
    //坚持
    private int RemoveNpc(KNpc pNpc)
    {
        int nResult  = 0;
        int nRetCode = 0;

        if (pNpc == null)
        {
            goto Exit0;
        }
        if (pNpc.m_pScene == null)
        {
            goto Exit0;
        }

        pNpc.DestroyDisplayData();

        nRetCode = pNpc.m_pScene.RemoveNpc(pNpc);
        if (nRetCode == 0)
        {
            goto Exit0;
        }

        nResult = 1;
Exit0:
        return(nResult);
    }
Пример #4
0
    public int GetTarget(ref KCharacter ppCharacter)
    {
        int nResult = 0;

        switch (m_eTargetType)
        {
        case TARGET_TYPE.ttNpc:

            KNpc pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(m_dwID);
            if (pNpc == null)
            {
                goto Exit0;
            }
            ppCharacter = (KCharacter)pNpc;
            break;

        case TARGET_TYPE.ttPlayer:

            KPlayer pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(m_dwID);
            if (pPlayer == null)
            {
                goto Exit0;
            }
            ppCharacter = (KCharacter)pPlayer;
            break;

        default:
            goto Exit0;
        }

        nResult = 1;
Exit0:
        return(nResult);
    }
Пример #5
0
    private bool CheckDie()
    {
        bool bResult = false;

        if (m_bToDie == false)
        {
            goto Exit0;
        }

        if (false)
        {
        }
        else
        {
            KNpc pNpc = (KNpc)this;
            pNpc.m_nCurrentLife = 0;

            pNpc.SetMoveState(CHARACTER_MOVE_STATE.cmsOnDeath);


            FirstFightMgr.Instance().DeleteNpc((KNpc)this);
        }

        bResult = true;
Exit0:
        return(bResult);
    }
Пример #6
0
 public void Activate()
 {
     for (int i = 0; i < m_NpcList.Count; ++i)
     {
         KNpc pNpc = m_NpcList[i];
         pNpc.Activate();
     }
 }
Пример #7
0
    public int SetTarget(TARGET_TYPE eType, uint dwID)
    {
        int nResult = 0;

        switch (eType)
        {
        case TARGET_TYPE.ttNoTarget:
            break;

        case TARGET_TYPE.ttNpc:
        {
            KNpc pNpc = null;

            pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(dwID);
            if (pNpc == null)
            {
                goto Exit0;
            }

            break;
        }

        case TARGET_TYPE.ttPlayer:
        {
            KPlayer pPlayer = null;


            pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(dwID);
            if (pPlayer == null)
            {
                goto Exit0;
            }
            break;
        }

        break;

        default:
            //error
            break;
        }
        ;

        m_eTargetType = eType;
        m_dwID        = dwID;

        nResult = 1;
Exit0:
        if (nResult == 0)
        {
            m_eTargetType = TARGET_TYPE.ttNoTarget;
        }
        return(nResult);
    }
Пример #8
0
    public int RemoveNpc(KNpc pNpc)
    {
        int nRetCode = 0;

        pNpc.m_pScene = null;

        m_NpcList.Remove(pNpc);

        nRetCode = 1;

        return(nRetCode);
    }
Пример #9
0
    public static int AINpcKeepSkillCastRange(KCharacter pCharacter, KAIAction pActionData)
    {
        int    nResult        = 0;
        int    nRetCode       = 0;
        int    nBranchInRange = 1;
        int    nBranchKeep    = 2;
        float  fMinRange      = 0f;
        float  fMaxRange      = 0f;
        uint   dwSkillID      = 0;
        KNpc   pNpc           = null;
        KSkill pSkill         = null;

        pNpc = (KNpc)pCharacter;


        dwSkillID = pNpc.m_pTemplate.dwSkillIDList[pNpc.m_nSkillSelectIndex];

        if (dwSkillID == 10001)
        {
            int gg = 0;
        }

        pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID);
        if (pSkill == null)
        {
            goto Exit0;
        }

        fMinRange = pSkill.m_fMinRadius;
        fMaxRange = pSkill.m_fMaxRadius;

        nRetCode = KeepRange(pCharacter, fMinRange, fMaxRange);
        if (!(nRetCode > 0))
        {
            goto Exit0;
        }


        if (nRetCode == 1)
        {
            nResult = nBranchInRange;
            goto Exit0;
        }

        nResult = nBranchKeep;
Exit0:
        return(nResult);
    }
Пример #10
0
    public static int AINpcStandardSkillSelector(KCharacter pCharacter, KAIAction pActionData)
    {
        int  nResult        = 0;
        int  nBranchSuccess = 1;
        KNpc pNpc           = null;

        pNpc = (KNpc)pCharacter;


        pNpc.m_nSkillSelectIndex = 0;


        nResult = nBranchSuccess;
Exit0:
        return(nResult);
    }
Пример #11
0
    public void LoadNpc()
    {
        npc1 = NewNpc();
        AddNpc(npc1, m_pCurScne);

        npc1.SetDisplayData(13811);
        npc1.SetPosition(new UnityEngine.Vector3(100, 0, -100));


        //npc 技能设置
        npc1.m_pTemplate.dwSkillIDList[0]      = 10005;
        npc1.m_pTemplate.nSkillCastInterval[0] = 16;// 间隔一秒



        npc1.m_AIVM.Setup(npc1, 1);

        //-----------------------------------------------------------------------------
        npc2 = NewNpc();
        AddNpc(npc2, m_pCurScne);


        npc2.m_pTemplate.dwSkillIDList[0]      = 10005;
        npc2.m_pTemplate.nSkillCastInterval[0] = 24;// 间隔一秒


        npc2.SetDisplayData(13811);
        npc2.SetPosition(new UnityEngine.Vector3(100, 0, -90));

        npc2.m_AIVM.Setup(npc2, 1);
        //-----------------------------------------------------------------------------

        npc3 = NewNpc();
        AddNpc(npc3, m_pCurScne);


        npc3.m_pTemplate.dwSkillIDList[0]      = 10001;
        npc3.m_pTemplate.nSkillCastInterval[0] = 18;// 间隔一秒


        npc3.SetDisplayData(10001);
        npc3.SetPosition(new UnityEngine.Vector3(90, 0, -90));

        npc3.m_AIVM.Setup(npc3, 1);

        //-----------------------------------------------------------------------------
    }
Пример #12
0
    public static int AINpcCastSelectSkill(KCharacter pCharacter, KAIAction pActionData)
    {
        int  nResult        = 0;
        int  nRetCode       = 0;
        int  nBranchSuccess = 1;
        int  nBranchFailed  = 2;
        int  nSelectIndex   = 0;
        KNpc pNpc           = null;
        uint dwSkillID      = 0;

        pNpc = (KNpc)pCharacter;

        nSelectIndex = pNpc.m_nSkillSelectIndex;
        dwSkillID    = pNpc.m_pTemplate.dwSkillIDList[nSelectIndex];


        if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCommomCD)
        {
            return(nBranchFailed);
        }
        if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCastFrame[nSelectIndex])
        {
            return(nBranchFailed);
        }


        nRetCode = CastSkill(pCharacter, dwSkillID, 0, (int)AI_SKILL_TYPE.aistInvalid);
        if (nRetCode <= 0)
        {
            goto Exit0;
        }

        if (nRetCode == 1)
        {
            pNpc.m_nSkillCastFrame[nSelectIndex] = (int)FirstFightMgr.Instance().m_nGameLoop + pNpc.m_pTemplate.nSkillCastInterval[nSelectIndex];
            pNpc.m_nSkillCommomCD = (int)FirstFightMgr.Instance().m_nGameLoop + 1;

            nResult = nBranchSuccess;
            goto Exit0;
        }

        nResult = nBranchFailed;
Exit0:
        return(nResult);
    }
Пример #13
0
    public void LoadNpc_1()
    {
        if (bdaxia)
        {
            KNpc npc3 = NewNpc();
            AddNpc(npc3, m_pCurScne);

            npc3.m_pTemplate.dwSkillIDList[0]      = 10131;
            npc3.m_pTemplate.nSkillCastInterval[0] = 6 * 16;// 间隔一秒

            npc3.SetDisplayData(23005);

            Random ran     = new Random();
            int    RandKey = ran.Next(85, 100);

            npc3.SetPosition(new UnityEngine.Vector3(RandKey, 0, -RandKey));

            npc3.m_AIVM.Setup(npc3, 1);

            bdaxia = false;
        }
        else
        {
            KNpc npc1 = NewNpc();
            AddNpc(npc1, m_pCurScne);

            npc1.SetDisplayData(13811);


            Random ran     = new Random();
            int    RandKey = ran.Next(85, 100);

            npc1.SetPosition(new UnityEngine.Vector3(RandKey, 0, -RandKey));


            //npc 技能设置
            npc1.m_pTemplate.dwSkillIDList[0]      = 10005;
            npc1.m_pTemplate.nSkillCastInterval[0] = 16;// 间隔一秒


            npc1.m_AIVM.Setup(npc1, 1);

            bdaxia = true;
        }
    }
Пример #14
0
    // 这里是否需要ref 参数
    public int DeleteNpc(KNpc pNpc)
    {
        if (pNpc == null)
        {
            //error
        }

        if (pNpc.m_pScene != null)
        {
            RemoveNpc(pNpc);
        }

        pNpc.UnInit();

        FirstFightMgr.Instance().m_NpcSet.Unregister(pNpc);

        pNpc = null;

        return(1);
    }
Пример #15
0
    public int GetTarget(ref float pfX, ref float pfZ)
    {
        int nResult = 0;

        switch (m_eTargetType)
        {
        case TARGET_TYPE.ttNpc:
        {
            KNpc pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(m_dwID);
            if (pNpc == null)
            {
                goto Exit0;
            }
            pNpc.GetAbsoluteCoordinate(ref pfX, ref pfZ);

            break;
        }

        case TARGET_TYPE.ttPlayer:
        {
            KPlayer pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(m_dwID);
            if (pPlayer == null)
            {
                goto Exit0;
            }
            pPlayer.GetAbsoluteCoordinate(ref pfX, ref pfZ);
        }
        break;

        default:
            goto Exit0;
        }

        nResult = 1;
Exit0:
        return(nResult);
    }
Пример #16
0
    public void AddNpc(KNpc pNpc)
    {
        m_NpcList.Add(pNpc);

        pNpc.m_pScene = this;
    }
Пример #17
0
    public int AddNpc(KNpc pNpc, KScene pScene)
    {
        pScene.AddNpc(pNpc);

        return(1);
    }