Example #1
0
    /// 添加GameObject到列表
    public void addGameObject(ClientElementInfo cellVo, GameObject gameobject)
    {
        if (gameobject == null)
        {
            return;
        }

        GameObjectDestroyCallBack gameObjectDestroyCallBack = gameobject.GetComponent <GameObjectDestroyCallBack>(); //用于监听销毁

        if (gameObjectDestroyCallBack == null)
        {
            gameObjectDestroyCallBack = gameobject.AddComponent <GameObjectDestroyCallBack> ();
        }
        gameObjectDestroyCallBack.destroyCallBack = removeGameObject;
        gameObjectDestroyCallBack.cellVo          = cellVo;

        GameObjectCellVo gameObjectCellVo = new GameObjectCellVo();

        gameObjectCellVo.cellVo = cellVo;

        gameobject.transform.position = gameobject.transform.position;
        gameobject.name = cellVo.getSourceName() + "|" + cellVo.model;

        gameObjectCellVo.currentGameObject = gameobject;
        cellList.Add(gameObjectCellVo);

        objId += 1;
    }
Example #2
0
    /// 添加GameObject到列表
    /// id 主要是用于区分怪物
    public void addGameObject(GameObject gameobject, int id)
    {
        if (gameobject == null)
        {
            return;
        }

        ClientElementInfo cellVo           = new ClientElementInfo();
        GameObjectCellVo  gameObjectCellVo = new GameObjectCellVo();

        GameObjectDestroyCallBack gameObjectDestroyCallBack = gameobject.GetComponent <GameObjectDestroyCallBack>();       //用于监听销毁

        if (gameObjectDestroyCallBack == null)
        {
            gameObjectDestroyCallBack = gameobject.AddComponent <GameObjectDestroyCallBack> ();
        }
        gameObjectDestroyCallBack.destroyCallBack = removeGameObject;
        gameObjectDestroyCallBack.cellVo          = cellVo;

        cellVo.setSourceName(gameobject.name);
        cellVo.model = id;
        //cellVo.id = AutoId.id++;
        gameobject.name = cellVo.getSourceName() + "|" + cellVo.model;// objId;
        //cellVo.name = gameobject.name;
        gameObjectCellVo.cellVo            = cellVo;
        gameObjectCellVo.currentGameObject = gameobject;
        cellList.Add(gameObjectCellVo);

        objId += 1;
    }