private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
    {
        // 获取框架数据表组件
        DataTableComponent DataTable
            = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>();
        // 获得数据表
        IDataTable <DRheros> dtScene = DataTable.GetDataTable <DRheros>();

        // 获得所有行
        DRheros[] drHeros = dtScene.GetAllDataRows();
        Log.Debug("drHeros:" + drHeros.Length);
        // 根据行号获得某一行
        DRheros drScene = dtScene.GetDataRow(1); // 或直接使用 dtScene[1]

        if (drScene != null)
        {
            // 此行存在,可以获取内容了
            string name = drScene.Name;
            int    atk  = drScene.Atk;
            Log.Debug("name:" + name + ", atk:" + atk);
        }
        else
        {
            // 此行不存在
        }
        // 获得满足条件的所有行
        DRheros[] drScenesWithCondition = dtScene.GetDataRows(x => x.Id > 0);

        // 获得满足条件的第一行
        DRheros drSceneWithCondition = dtScene.GetDataRow(x => x.Name == "mutou");
    }
Exemplo n.º 2
0
    private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
    {
        //获取框架数据表组件
        DataTableComponent DataTable = GameEntry.GetComponent <DataTableComponent>();
        //获得数据表
        IDataTable <DRHero> dtScene = DataTable.GetDataTable <DRHero>();

        //获得所有行
        DRHero[] drHeros = dtScene.GetAllDataRows();
        Log.Debug("drHeros:" + drHeros.Length);
        //根据行号获取某一行
        DRHero drScene = dtScene.GetDataRow(1);

        //DRHero drScene = drHeros[1];
        if (drScene != null)
        {
            string name = drScene.Name;
            int    atk  = drScene.Atk;
            Log.Debug("name:" + name + ",atk:" + atk);
        }
        else
        {
            Log.Debug("index not exist");
        }
        //获取满足条件的所有行
        DRHero[] drScenesWithCondition = dtScene.GetAllDataRows(x => x.Id > 0);

        //获取满足条件的第一行
        DRHero drFirstSceneWithCondition = dtScene.GetDataRow(x => x.Name == "mutou");
    }
Exemplo n.º 3
0
    /// <summary>
    /// /////////////////
    /// </summary>

    private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
    {
        // 获取框架数据表组件
        DataTableComponent DataTable = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>();

        // 获得数据表
        GameFramework.DataTable.IDataTable <ConfigHero> table = DataTable.GetDataTable <ConfigHero>();

        // 获得所有行
        ConfigHero[] rows = table.GetAllDataRows();
        Log.Debug("ConfigHeros:" + rows.Length);

        if (table != null)
        {
            // 根据行号获得某一行
            ConfigHero row = table.GetDataRow(1); // 或直接使用 dtScene[1]
                                                  // 此行存在,可以获取内容了
            string name = table.Name;
            int    hp   = row.Hp;
            Log.Debug("name:" + name + ", hp:" + hp);
        }
        else
        {
            // 此行不存在
        }
        // 获得满足条件的所有行
        ConfigHero[] drScenesWithCondition = table.GetAllDataRows(x => x.Id > 0);

        // 获得满足条件的第一行
        ConfigHero drSceneWithCondition = table.GetDataRow(x => x.Name == "mutou");
    }
    public int PlayUISound(int uiSoundId, object userData = null)
    {
        DataTableComponent     dataTableComponent = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>();
        IDataTable <DRUISound> dtUISound          = dataTableComponent.GetDataTable <DRUISound>();
        DRUISound drUISound = dtUISound.GetDataRow(uiSoundId);

        if (drUISound == null)
        {
            Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString());
            return(-1);
        }

        PlaySoundParams playSoundParams = PlaySoundParams.Create();

        playSoundParams.Priority           = drUISound.Priority;
        playSoundParams.Loop               = false;
        playSoundParams.VolumeInSoundGroup = drUISound.Volume;
        playSoundParams.SpatialBlend       = 0f;
        return(soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Demo15.Constant.AssetPriority.UISoundAsset, playSoundParams, userData));
    }
    public T GetConfig <T>(int Id) where T : IDataRow
    {
        IDataTable <T> config = _data.GetDataTable <T>();

        return(config.GetDataRow(Id));
    }
Exemplo n.º 6
0
 /// <summary>
 /// 获取数据表。
 /// </summary>
 /// <typeparam name="T">数据表行的类型。</typeparam>
 /// <returns>要获取的数据表。</returns>
 public IDataTable <T> GetDataTable <T>() where T : IDataRow
 {
     return(m_DataTableManager.GetDataTable <T>());
 }
Exemplo n.º 7
0
        /// <summary>
        /// 获取一行数据
        /// </summary>
        /// <param name="id">数据表行的编号</param>
        /// <typeparam name="T">数据表类型</typeparam>
        /// <returns></returns>
        public static T GetDataRow <T>(this DataTableComponent dataTableComponent, int id) where T : IDataRow
        {
            IDataTable <T> dt = dataTableComponent.GetDataTable <T> ();

            return(dt.GetDataRow(id));
        }