예제 #1
0
    public override bool LoadConfig(int id)
    {
        WDBSheetLine line = CDataMgr.Item.GetData(id);

        if (line == null)
        {
            LKDebug.LogError("LoadConfig error: can't find " + id + " in Item table!");
            return(false);
        }

        id_             = line.GetData <int>(WDB_Item.Id);
        name_           = line.GetData <string>(WDB_Item.Name);
        desc_           = line.GetData <string>(WDB_Item.Desc);
        body_           = line.GetData <string>(WDB_Item.Body);
        body_drop_      = line.GetData <string>(WDB_Item.Body_Drop);
        drop_effect_    = line.GetData <int>(WDB_Item.Drop_Effect);
        quality_        = line.GetData <int>(WDB_Item.Quality);
        bag_            = line.GetData <int>(WDB_Item.Bag);
        use_            = line.GetData <int>(WDB_Item.Use);
        autu_gein_      = line.GetData <int>(WDB_Item.AutuGein);
        stack_sum_      = line.GetData <int>(WDB_Item.StackSum);
        is_resolve_     = line.GetData <int>(WDB_Item.IsResolve);
        is_sold_        = line.GetData <int>(WDB_Item.IsSold);
        price_          = line.GetData <int>(WDB_Item.Price);
        is_affirm_sold_ = line.GetData <int>(WDB_Item.IsAffirmSold);
        icon_           = line.GetData <string>(WDB_Item.Icon);
        icon_type_      = line.GetData <int>(WDB_Item.IconType);
        function_       = line.GetData <int>(WDB_Item.Function);
        buff_id_        = line.GetData <int>(WDB_Item.BuffId);
        drop_           = line.GetData <int>(WDB_Item.Drop);
        trun_around_    = line.GetData <int>(WDB_Item.TrunAround);
        gain_effect_    = line.GetData <int>(WDB_Item.GainEffect);

        return(true);
    }
예제 #2
0
    public static AudioClip LoadClip(string path)
    {
        AudioClip clip = ResLoader.Load(path) as AudioClip;

        if (clip == null)
        {
            LKDebug.LogError("can't load audio at path: " + path);
        }
        return(clip);
    }
예제 #3
0
 void ClientHandleMessage(CNetRecvMsg msg)
 {
     if (msg.m_nMsgID >= 0 && msg.m_nMsgID < m_HandleMap.Length)
     {
         OnHandleOneMessage handler = m_HandleMap[msg.m_nMsgID];
         if (handler != null)
         {
             handler(msg);
         }
         else
         {
             LKDebug.LogError("This Message could not be processed :" + msg.m_nMsgID);
         }
     }
 }
예제 #4
0
    public static T Instantiate <T>(string path) where T : UnityEngine.Object
    {
        T obj = null;

        if (!string.IsNullOrEmpty(path))
        {
            UnityEngine.Object res = ResLoader.Load(path);
            if (res == null)
            {
                LKDebug.LogError("Can't find :" + path);
                return(null);
            }
            obj = GameObject.Instantiate(res) as T;
        }

        return(obj);
    }
예제 #5
0
    public bool OpenData(byte[] data, string ndbName)
    {
        /*
         * FileStream fs = new FileStream(path, FileMode.Open);
         * if (fs.CanRead == false)
         *      return false;
         * mData = new byte[fs.Length];
         * fs.Read(mData, 0, (int)fs.Length);
         * fs.Close();
         */
        mData = data;
        // read header
        mHeader = (WDBHeader)GemType.RawDeserialize(mData, typeof(WDBHeader));
        if (mHeader.nId != WDBConst.HeadMark)
        {
            return(false);
        }
        mDataOffset = Marshal.SizeOf(typeof(WDBHeader));

        // read filed name
        int bufLen = mHeader.nNameBufLen * sizeof(short);

        if (bufLen > 0)
        {
            int index = mDataOffset;
            mFieldName = new Dictionary <string, int> ();
            for (int i = 0; i < mHeader.nFields; i++)
            {
                int nextindex = 0, count = 0;
                if (GetNDBStrLen(mData, index, ref nextindex, ref count))
                {
                    string fieldName = Encoding.Unicode.GetString(mData, index, count);
                    index = nextindex;
                    if (mFieldName.ContainsKey(fieldName))
                    {
                        LKDebug.LogError(fieldName + " Have Exist.In table:" + ndbName);
                        continue;
                    }

                    mFieldName.Add(fieldName, i);
                }
                else
                {
                    return(false);
                }
            }
            mDataOffset = index;
        }
        else
        {
            return(true);
        }

        if (mDataOffset % 4 != 0)
        {
            mDataOffset += 2;
        }
        if (mDataOffset % 4 != 0)
        {
            mDataOffset += 2;
        }

        // read the first data as field type
        mFieldType = new int[mHeader.nFields];
        for (int j = 0; j < mHeader.nFields; j++)
        {
            mFieldType[j] = BitConverter.ToInt32(mData, mDataOffset + j * sizeof(int));
        }

        for (int j = 0; j < mHeader.nFields; j++)
        {
            mDataOffset += sizeof(int);
        }

        // string offset
        mStringOffset = mDataOffset + mHeader.nRecords * mHeader.nRecordSize;

        // create index
        int indexfield = -1;

        for (int i = 0; i < GetFieldCount(); i++)
        {
            int type = GetFieldType(i);
            if (type == (int)EWDB_FIELD_TYPE.WFT_V_INDEX)
            {
                indexfield = i;
            }
        }
        if (indexfield >= 0)
        {
            mIndex = new Dictionary <int, int> ();
            //MaybeEmpty
            for (int i = 0; i < GetRecordCount(); i++)
            {
                int activeIndex = (int)GetDataByNumber(i, indexfield);
                if (mIndex.ContainsKey(activeIndex))
                {
                    LKDebug.LogError(activeIndex + " Have Exist.In table:" + ndbName);
                    continue;
                }
                mIndex.Add(activeIndex, i);
            }
        }

        return(true);
    }