Beispiel #1
0
    public EA_CCharNPC GetNPC(EAObjID _id)
    {
        EA_CCharNPC pNPC = null;

        m_mapNPCList.TryGetValue(_id, out pNPC);

        return(pNPC);
    }
Beispiel #2
0
    public EA_CCharNPC      GetNpcFromIndex(EATblID _index)
    {
        if (m_mapNPCList.Count > 0)
        {
            EA_CCharNPC nPC = null;

            m_mapNPCList.TryGetValue(_index, out nPC);
        }

        return(null);
    }
Beispiel #3
0
    public EA_CCharNPC CreateNPC(ObjectInfo GameObjInfo, NPCInfo npcInfo)
    {
        GameObjInfo.m_eObjType = eObjectType.CT_NPC;
        EA_CCharNPC pNpc = (EA_CCharNPC)CreateGameObject(GameObjInfo);

        if (pNpc != null)
        {
            pNpc.SetNPCInfo(npcInfo);
            pNpc.PosInit();
        }

        return(pNpc);
    }
Beispiel #4
0
    public EA_CObjectBase RemoveNPC(EAObjID _id)
    {
        EA_CCharNPC pNPC = GetNPC(_id);

        if (pNPC != null)
        {
            pNPC.ResetInfo(eObjectState.CS_DEAD);
            m_mapNPCList.Remove((uint)_id);
            m_pIDGenerator.FreeID(_id);
        }

        return(pNPC);
    }
Beispiel #5
0
    /// <summary>
    /// The game object from the server is applied first and the Cry Entity is created by FirstUpdate ().
    /// </summary>
    /// <param name="GameObjInfo"></param>
    /// <returns></returns>
    public EA_CObjectBase CreateGameObject(ObjectInfo GameObjInfo)
    {
        EA_CObjectBase pReturnObject = null;

        GameObjInfo.m_eObjState = eObjectState.CS_SETENTITY;

        //	Temporarily specify ObjId (sometimes temporary use by external system)
        bool bCreateTempId = false;

        if (CObjGlobal.InvalidObjID == GameObjInfo.m_GDObjId)
        {
            GameObjInfo.m_GDObjId = (EAObjID)m_pIDGenerator.GenerateID();
            bCreateTempId         = true;
        }

        switch (GameObjInfo.m_eObjType)
        {
        case eObjectType.CT_MYPLAYER:
        {
            if (GetMainPlayer() != null)
            {
                //	My character is created at startup so I don't need to create it
                GetMainPlayer().SetObjInfo(GameObjInfo);

                pReturnObject = GetMainPlayer();
            }
        }
        break;

        case eObjectType.CT_PLAYER:
        {
            EA_CCharUser pCharPlayer = null;

            //	First check if it exists
            if (bCreateTempId == false)
            {
                pCharPlayer = GetPlayer(GameObjInfo.m_GDObjId);
            }

            //	If not, create a new one
            if (pCharPlayer == null)
            {
                pCharPlayer = new EA_CCharUser();

                if (pCharPlayer != null)
                {
                    m_mapPlayerList.Add(GameObjInfo.m_GDObjId, pCharPlayer);
                }
            }

            //	Enter the information of the created object and apply it
            if (pCharPlayer != null)
            {
                pCharPlayer.SetObjInfo(GameObjInfo);
            }

            pReturnObject = pCharPlayer;
        }
        break;

        case eObjectType.CT_NPC:
        {
            EA_CCharNPC pCharNPC = null;

            //	First check if it exists
            if (bCreateTempId == false)
            {
                pCharNPC = GetNPC(GameObjInfo.m_GDObjId);
            }

            //	If not, create a new one
            if (pCharNPC == null)
            {
                pCharNPC = new EA_CCharNPC();

                if (pCharNPC != null)
                {
                    m_mapNPCList.Add(GameObjInfo.m_GDObjId, pCharNPC);
                }
            }

            //	Apply the information to the generated number
            if (pCharNPC != null)
            {
                pCharNPC.SetObjInfo(GameObjInfo);
            }

            pReturnObject = pCharNPC;
        }
        break;

        case eObjectType.CT_MONSTER:
        {
            EA_CCharMob pCharPlayer = null;

            //	First check if it exists
            if (bCreateTempId == false)
            {
                pCharPlayer = GetMob(GameObjInfo.m_GDObjId);
            }

            //	If not, create a new one
            if (pCharPlayer == null)
            {
                pCharPlayer = new EA_CCharMob();

                if (pCharPlayer != null)
                {
                    m_mapMonsterList.Add(GameObjInfo.m_GDObjId, pCharPlayer);
                }
            }

            //	Apply the information to the generated number
            //			assert( pCharInfo && "No Character Info" );
            if (pCharPlayer != null)
            {
                pCharPlayer.SetObjInfo(GameObjInfo);
            }

            pReturnObject = pCharPlayer;
        }
        break;

        case eObjectType.CT_ITEMOBJECT:
        {
            EA_CItem pItem = null;

            //	First check if it exists
            if (bCreateTempId == false)
            {
                pItem = GetItemObject(GameObjInfo.m_GDObjId);
            }

            //	If not, create a new one
            if (pItem == null)
            {
                pItem = new EA_CItem();

                if (pItem != null)
                {
                    m_mapItemList.Add(GameObjInfo.m_GDObjId, pItem);
                }
            }

            //	Apply the information to the generated number
            if (pItem != null)
            {
                pItem.SetObjInfo(GameObjInfo);
            }

            pReturnObject = pItem;
        }
        break;

        case eObjectType.CT_MAPOBJECT:
        {
            EA_CMapObject pObject = null;

            //	First check if it exists
            if (bCreateTempId == false)
            {
                pObject = GetMapObject(GameObjInfo.m_GDObjId);
            }

            //	If not, create a new one
            if (pObject == null)
            {
                pObject = new EA_CMapObject();

                if (pObject != null)
                {
                    m_mapObjectList.Add(GameObjInfo.m_GDObjId, pObject);
                }
            }

            //	Apply the information to the generated number
            if (pObject != null)
            {
                pObject.SetObjInfo(GameObjInfo);
            }

            pReturnObject = pObject;
        }
        break;

            /*
             * case CT_QUEST:
             *  {
             *      //	First check if it exists
             *      if( false == bCreateTempId )
             *          pReturnObject = GetQuestItem(GameObjInfo.m_DiaObjId);
             *
             *      //	If not, create a new one
             *      if( NULL == pReturnObject )
             *      {
             *          pReturnObject = new IfDia_CObjectBase;
             *          assert( pReturnObject && "Not Create ItemObject" );
             *          if( pReturnObject )
             *              m_mapQuestList.insert( TQuestListMap::value_type(GameObjInfo.m_DiaObjId,pReturnObject) );
             *      }
             *
             *       //	Apply the information to the generated number
             *      if( pReturnObject )
             *      {
             *          pReturnObject->SetObjInfo(GameObjInfo);
             *      }
             *  }
             *  break;
             * /**/
        }

        //assert( pReturnObject );

        //	Apply the information to the generated number
        if (pReturnObject != null)
        {
            m_entityList.Add(pReturnObject);
        }

        return(pReturnObject);
    }