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");
    }
    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");
    }
Example #3
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);
        }
    }
Example #4
0
    public HeroData(int entityId, int typeId, CampType camp) : base(entityId, typeId, camp)
    {
        IDataTable <DRHero> dtHero = GameEntry.DataTable.GetDataTable <DRHero> ();
        DRHero drHero = dtHero.GetDataRow(typeId);

        if (drHero == null)
        {
            return;
        }

        Name                  = drHero.Name;
        HP                    = drHero.HP;
        MaxMP                 = drHero.MP;
        MaxHP                 = HP;
        MP                    = 0;
        MoveSpeed             = drHero.MoveSpeed;
        RotateSpeed           = drHero.RotateSpeed;
        Atk                   = drHero.Atk;
        AtkAnimTime           = drHero.AtkAnimTime;
        AtkRange              = drHero.AtkRange;
        Def                   = drHero.Def;
        AtkSpeed              = drHero.AtkSpeed;
        HPAbsorbPercent       = drHero.HPAbsorbPercent;
        DefAbsorbPercent      = drHero.DefAbsorbPercent;
        AtkAbsorbPercent      = drHero.AtkAbsorbPercent;
        AtkSpeedAbsorbPercent = drHero.AtkSpeedAbsorbPercent;
        HPMinAbsorb           = drHero.HPMinAbsorb;
        DefMinAbsorb          = drHero.DefMinAbsorb;
        AtkMinAbsorb          = drHero.AtkMinAbsorb;
        AtkSpeedMinAbsorb     = drHero.AtkSpeedMinAbsorb;

        for (int i = 0; i < drHero.GetWeaponCount(); i++)
        {
            weaponDatas.Add(new WeaponData(EntityExtension.GenerateSerialId(), drHero.GetWeaponID(i), Id, Camp));
        }
    }