Beispiel #1
0
        public override void SetData(byte[] buf, int offset)
        {
            Type        = buf[offset];
            Index       = buf[offset + 1] & 0xFF;
            _frameCount = buf[offset + 2] & 0xFF;
            _imageCount = buf[offset + 3] & 0xFF;
            _startFrame = buf[offset + 4] & 0xFF;
            _endFrame   = buf[offset + 5] & 0xFF;

            int ptr = offset + 6;

            _frameHeader = new int[_frameCount, 5];

            for (int i = 0; i < _frameCount; i++)
            {
                _frameHeader[i, 0] = buf[ptr++] & 0xFF; // x
                _frameHeader[i, 1] = buf[ptr++] & 0xFF; // y
                _frameHeader[i, 2] = buf[ptr++] & 0xFF; // Show
                _frameHeader[i, 3] = buf[ptr++] & 0xFF; // nShow
                _frameHeader[i, 4] = buf[ptr++] & 0xFF; // 图号
            }

            // 读入_imageCount个ResImage
            _images = new ResImage[_imageCount];
            for (int i = 0; i < _imageCount; i++)
            {
                _images[i] = new ResImage(Context);
                _images[i].SetData(buf, ptr);
                ptr += _images[i].GetBytesCount();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取资源
        /// </summary>
        /// <param name="resType">资源文件类型号1-12</param>
        /// <param name="type">资源类型</param>
        /// <param name="index">资源索引号</param>
        /// <returns>资源对象,不存在则返回</returns>
        public ResBase GetRes(int resType, int type, int index)
        {
            ResBase rtn    = null;
            int     offset = GetDataOffset(resType, type, index);

            //TODO 超过索引的资源直接不处理???
            if (offset != -1 && offset < _data.Length)
            {
                switch (resType)
                {
                case RES_GUT:
                    rtn = new ResGut(Context);
                    break;

                case RES_MAP:
                    rtn = new ResMap(Context);
                    break;

                case RES_ARS:
                    switch (type)
                    {
                    case 1:         // 玩家角色
                        rtn = new PlayerCharacter(Context);
                        break;

                    case 2:         // NPC角色
                        rtn = new NPC(Context);
                        break;

                    case 3:         // 敌人角色
                        rtn = new Monster(Context);
                        break;

                    case 4:         // 场景对象
                        rtn = new SceneObj(Context);
                        break;

                    default:
                        rtn = null;
                        break;
                    }
                    break;

                case RES_MRS:
                    rtn = InternalGetMagic(type, index);
                    break;

                case RES_SRS:
                    rtn = new ResSrs(Context);
                    break;

                case RES_GRS:
                    rtn = InternalGetGoods(type, index);
                    break;

                case RES_TIL:
                case RES_ACP:
                case RES_GDP:
                case RES_GGJ:
                case RES_PIC:
                    rtn = new ResImage(Context);
                    break;

                case RES_MLR:
                    if (type == 1)
                    {
                        rtn = new ResMagicChain(Context);
                    }
                    else if (type == 2)
                    {
                        rtn = new ResLevelupChain(Context);
                    }
                    break;
                }
                rtn.SetData(_data, offset);
            }
            else
            { // 资源不存在
              //Log.e("Context.LibData.GetRes", "resType:" + resType + " type:" + type + " index:" + index + " not found.");
            }

            return(rtn);
        }