/// <summary>
        /// 创建加载数据表成功事件。
        /// </summary>
        /// <param name="e">内部事件。</param>
        /// <returns>创建的加载数据表成功事件。</returns>
        public static LoadDataTableSuccessEventArgs Create(ReadDataSuccessEventArgs e)
        {
            LoadDataTableSuccessEventArgs loadDataTableSuccessEventArgs = ReferencePool.Acquire <LoadDataTableSuccessEventArgs>();

            loadDataTableSuccessEventArgs.DataTableAssetName = e.DataAssetName;
            loadDataTableSuccessEventArgs.Duration           = e.Duration;
            loadDataTableSuccessEventArgs.UserData           = e.UserData;
            return(loadDataTableSuccessEventArgs);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建加载数据表成功事件。
        /// </summary>
        /// <param name="e">内部事件。</param>
        /// <returns>创建的加载数据表成功事件。</returns>
        public static LoadDataTableSuccessEventArgs Create(GameFramework.DataTable.LoadDataTableSuccessEventArgs e)
        {
            LoadDataTableInfo             loadDataTableInfo             = (LoadDataTableInfo)e.UserData;
            LoadDataTableSuccessEventArgs loadDataTableSuccessEventArgs = ReferencePool.Acquire <LoadDataTableSuccessEventArgs>();

            loadDataTableSuccessEventArgs.DataRowType        = loadDataTableInfo.DataRowType;
            loadDataTableSuccessEventArgs.DataTableName      = loadDataTableInfo.DataTableName;
            loadDataTableSuccessEventArgs.DataTableAssetName = e.DataTableAssetName;
            loadDataTableSuccessEventArgs.Duration           = e.Duration;
            loadDataTableSuccessEventArgs.UserData           = loadDataTableInfo.UserData;
            ReferencePool.Release(loadDataTableInfo);
            return(loadDataTableSuccessEventArgs);
        }
    private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
    {
        UnityGameFramework.Runtime.LoadDataTableSuccessEventArgs eventArgs
            = e as UnityGameFramework.Runtime.LoadDataTableSuccessEventArgs;

        Log.Debug("加载成功:" + eventArgs.DataRowType);

        // 获取框架数据表组件
        DataTableComponent DataTable
            = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>();

        // 获得数据表
        IDataTable <DRHero> dtScene = DataTable.GetDataTable <DRHero>();

        // 获得所有行
        DRHero[] drHeros = dtScene.GetAllDataRows();

        Log.Debug("drHeros:" + drHeros.Length);

        // 根据行号获得某一行
        DRHero drScene = dtScene.GetDataRow(1);         // 或直接使用 dtScene[1]

        if (drScene != null)
        {
            // 此行存在,可以获取内容了
            string name = drScene.Name;
            int    atk  = drScene.Atk;

            Log.Debug("name:" + name + ", atk:" + atk);
        }
        else
        {
            // 此行不存在
        }

        // 获得满足条件的所有行
        DRHero[] drScenesWithCondition = dtScene.GetAllDataRows(x => x.Id > 0);

        // 获得满足条件的第一行
        DRHero drSceneWithCondition = dtScene.GetDataRow(x => x.Name == "mutou");
    }
Esempio n. 4
0
    private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
    {
        // 数据表加载成功事件
        UnityGameFramework.Runtime.LoadDataTableSuccessEventArgs ne = e as UnityGameFramework.Runtime.LoadDataTableSuccessEventArgs;
        Debug.Log(string.Format("Load data table '{0}' success.", ne.DataTableName));

        // 获取框架数据表组件
        // 获得数据表
        IDataTable <DRHero> dtScene = GameEntry.DataTable.GetDataTable <DRHero>();

        // 获得所有行
        DRHero[] drHeros = dtScene.GetAllDataRows();
        Debug.Log("drHeros:" + drHeros.Length);
        // 根据行号获得某一行,即IDataRow中的id,自定义,而不是根据顺序
        DRHero drScene = dtScene.GetDataRow(1); //或直接使用 dtScene[1]

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

        // 获得满足条件的第一行
        DRHero drSceneWithCondition = dtScene.GetDataRow(x => x.Name == "enemy");

        if (drSceneWithCondition != null)
        {
            // 此行存在,可以获取内容了
            string name = drSceneWithCondition.Name;
            int    HP   = drSceneWithCondition.HP;
            Debug.Log("name:" + name + ", HP:" + HP);
        }
    }
Esempio n. 5
0
 private void OnLoadDataTableSuccess(object sender, GameFramework.DataTable.LoadDataTableSuccessEventArgs e)
 {
     m_EventComponent.Fire(this, LoadDataTableSuccessEventArgs.Create(e));
 }
 private void OnReadDataSuccess(object sender, ReadDataSuccessEventArgs e)
 {
     m_EventComponent.Raise(this, LoadDataTableSuccessEventArgs.Create(e));
 }