예제 #1
0
    /// <summary>
    /// 初始化接口
    /// </summary>
    public static void Init()
    {
        mAttrib2Item = LPCMapping.Empty;
        mItem2Attrib = LPCMapping.Empty;

        // 载入字段配置表
        mFieldsCsv = CsvFileMgr.Load("fields");
        int itemClassId;

        foreach (CsvRow data in mFieldsCsv.rows)
        {
            // 获取属性对应的item_class_id
            itemClassId = data.Query <LPCValue>("item_class_id").AsInt;

            // 该属性没有绑定道具
            if (itemClassId == 0)
            {
                continue;
            }

            // 记录数据
            mAttrib2Item.Add(data.Query <string>("field"), itemClassId);
            mItem2Attrib.Add(itemClassId, data.Query <string>("field"));
        }
    }
예제 #2
0
    /// <summary>
    /// 两个mapping相加(不改变原来的值)
    /// </summary>
    public static LPCValue MappingAdd(LPCMapping m1, LPCMapping m2)
    {
        LPCValue v = LPCValue.CreateMapping();

        foreach (object k in m1.Keys)
        {
            if (k is string)
            {
                v.AsMapping [k as string] = m1 [k as string];
            }
            else
            {
                v.AsMapping [(int)k] = m1 [(int)k];
            }
        }
        foreach (object k in m2.Keys)
        {
            if (k is string)
            {
                v.AsMapping [k as string] = m2 [k as string];
            }
            else
            {
                v.AsMapping [(int)k] = m2 [(int)k];
            }
        }
        return(v);
    }
예제 #3
0
    // 转换成lpcvalue
    public LPCValue ConvertLpc()
    {
        LPCMapping lpcMap = LPCMapping.Empty;

        foreach (KeyValuePair <string, int> c in mOwner.columns)
        {
            lpcMap.Add(c.Key, properties[c.Value]);
        }

        return(LPCValue.Create(lpcMap));
    }
예제 #4
0
    /// <summary>
    /// 取得配置成LPCMAPPING属性的字段
    /// </summary>
    /// <returns>The field in mapping.</returns>
    /// <param name="field_map">Field_map.</param>
    public static string GetFieldInMapping(LPCMapping field_map)
    {
        if (field_map == null)
        {
            return(string.Empty);
        }

        foreach (string field in field_map.Keys)
        {
            if (!string.IsNullOrEmpty(field))
            {
                return(field);
            }
        }

        return(string.Empty);
    }
예제 #5
0
    /// <summary>
    /// 获取时间详细数据
    /// year 包括纪元的四位数的年份
    /// month 月份数字,一位数的月份有一个前导零
    /// day 月中的某一天,一位数的日期有一个前导零
    /// hour : 24小时制
    /// minute : 分钟
    /// Second : 秒
    /// </summary>
    public static LPCMapping GetTimeDetail(int sec, bool show24)
    {
        // 转换为DateTime
        DateTime   dt   = TimeMgr.ConvertIntDateTime(sec);
        LPCMapping data = LPCMapping.Empty;

        // 2018-10-12 24:00:00
        // 不需要修正向下修正格式化后2018-10-13 00:00:00
        // 向下修正后显示2018-10-12 24:00:00
        if (!show24)
        {
            data.Add("year", dt.Year);
            data.Add("month", dt.Month);
            data.Add("day", dt.Day);
            data.Add("hour", dt.Hour);
            data.Add("minute", dt.Minute);
            data.Add("Second", dt.Second);
            return(data);
        }

        // 如果时间不是00:00:00, 直接返回当前时间
        if (dt.Hour != 0 || dt.Minute != 0 || dt.Second != 0)
        {
            data.Add("year", dt.Year);
            data.Add("month", dt.Month);
            data.Add("day", dt.Day);
            data.Add("hour", dt.Hour);
            data.Add("minute", dt.Minute);
            data.Add("Second", dt.Second);
            return(data);
        }

        // 转换为DateTime,在原来时间减1秒让时间推移到上一天
        DateTime dt1 = TimeMgr.ConvertIntDateTime(sec - 1);

        // 构建数据
        data.Add("year", dt1.Year);
        data.Add("month", dt1.Month);
        data.Add("day", dt1.Day);
        data.Add("hour", 24);
        data.Add("minute", 0);
        data.Add("Second", 0);

        // 返回格式化后数据
        return(data);
    }