Esempio n. 1
0
    public KAIAction NewAction(int nActionID, int nActionKey)
    {
        if (nActionID <= KAIAction.KAI_ACTION_ID_NONE)
        {
            //error
            goto Exit0;
        }

        if (nActionKey <= (int)KAI_ACTION_KEY.eakInvalid)
        {
            //error
            goto Exit0;
        }

        if (nActionKey < KAIAction.KAI_USER_ACTION)
        {
            KAIManager.KAI_ACTION_FUNC pFucAction = null;

            pFucAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey);

            if (pFucAction == null)
            {
                //error
                goto Exit0;
            }
        }
        else
        {
            //error
            goto Exit0;
        }

        if (m_ActionTable.ContainsKey(nActionID))
        {
            //error
            goto Exit0;
        }

        KAIAction pAIAction = new KAIAction();

        pAIAction.m_nKey = nActionKey;

        m_ActionTable.Add(nActionID, pAIAction);

        return(pAIAction);

Exit0:
        return(null);
    }
Esempio n. 2
0
    public KAIActionHandle CallAction(KCharacter pCharacter, KAIActionHandle pActionKey)
    {
        KAIActionHandle pResult     = new KAIActionHandle();
        KAIActionHandle pNextAction = new KAIActionHandle();

        KAIAction pAction    = pActionKey.pAIAction;
        int       nActionKey = 0;

        if (pAction == null)
        {
            pAction = GetAction(pActionKey.nAIActionID);
        }

        if (pAction == null)
        {
            //error
            goto Exit0;
        }

        nActionKey = pAction.m_nKey;

        if (nActionKey < KAIAction.KAI_USER_ACTION)
        {
            int   nBranchIndex    = 0;
            ulong ulPrevTickCount = 0;
            ulong ulPostTickCount = 0;
            KAIManager.KAI_ACTION_FUNC PAction = null;

            PAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey);
            if (PAction == null)
            {
                //error
                goto Exit0;
            }


            nBranchIndex = PAction(pCharacter, pAction);

            if (nBranchIndex > 0 && nBranchIndex <= KAIAction.KAI_ACTION_BRANCH_NUM)
            {
                int       nNextActionID   = pAction.m_nBranch[nBranchIndex - 1];
                KAIAction pNextActionTemp = pAction.m_pBranch[nBranchIndex - 1];

                if (pNextActionTemp == null)
                {
                    pNextActionTemp = GetAction(nNextActionID);
                    pAction.m_pBranch[nBranchIndex - 1] = pNextActionTemp;
                }
                pNextAction.nAIActionID = nNextActionID;
                pNextAction.pAIAction   = pNextActionTemp;
            }
            if (nBranchIndex == -1)
            {
                pNextAction.nAIActionID = KAIAction.KAI_ACTION_ID_NONE;
                pNextAction.pAIAction   = null;
            }
        }
        else
        {
            // 没做
            //error
        }


        pResult = pNextAction;
Exit0:
        return(pResult);
    }