Exemplo n.º 1
0
    // Token: 0x06000012 RID: 18 RVA: 0x00002348 File Offset: 0x00000748
    private void CreateGameObjects(AnmData anmData)
    {
        Texture2D texture2D  = Resources.Load <Texture2D>(this.pngName);
        Texture2D texture2D2 = new Texture2D(texture2D.width, texture2D.height, TextureFormat.RGB24, false);

        texture2D2 = texture2D;
        int width  = texture2D2.width;
        int height = texture2D2.height;
        int num    = anmData.modules.Length;

        this.modules = new Sprite[num];
        for (int i = 0; i < num; i++)
        {
            AnmModule anmModule = anmData.modules[i];
            int       x         = anmModule.x;
            int       num2      = height - anmModule.y - anmModule.h;
            int       w         = anmModule.w;
            int       h         = anmModule.h;
            Sprite    sprite    = Sprite.Create(texture2D2, new Rect((float)x, (float)num2, (float)w, (float)h), new Vector2(0f, 1f), 100f);
            this.modules[i] = sprite;
        }
        num          = anmData.sprites.Length;
        this.sprites = new GameObject[num];
        for (int j = 0; j < num; j++)
        {
            AnmSprite  anmSprite  = anmData.sprites[j];
            GameObject gameObject = new GameObject(string.Format("Sprite{0}", j));
            gameObject.AddComponent <SpriteRenderer>().sprite = this.modules[anmSprite.module];
            gameObject.transform.parent = base.gameObject.transform;
            float x2 = (float)anmSprite.x / 100f;
            float y  = (float)(-(float)anmSprite.y) / 100f;
            float z  = (float)(-(float)j) / 100f;
            gameObject.transform.position = new Vector3(x2, y, z);
            this.sprites[j] = gameObject;
        }
        this.Deactivate();
    }
Exemplo n.º 2
0
    // Token: 0x06000015 RID: 21 RVA: 0x00002550 File Offset: 0x00000950
    public void Load(byte[] bytes)
    {
        Stream input = new MemoryStream(bytes);

        using (BinaryReader binaryReader = new BigEndianBinaryReader(input))
        {
            int num = (int)binaryReader.ReadByte();
            this.modules = new AnmModule[num];
            for (int i = 0; i < num; i++)
            {
                AnmModule anmModule = default(AnmModule);
                anmModule.x     = (int)binaryReader.ReadByte();
                anmModule.y     = (int)binaryReader.ReadByte();
                anmModule.w     = (int)binaryReader.ReadByte();
                anmModule.h     = (int)binaryReader.ReadByte();
                this.modules[i] = anmModule;
            }
            int num2 = (int)binaryReader.ReadByte();
            for (int j = 0; j < num2; j++)
            {
                int num3 = (int)binaryReader.ReadByte();
                int num4 = (int)binaryReader.ReadByte();
                int num5 = (int)binaryReader.ReadByte();
                if (num4 == 0)
                {
                    AnmModule[] array = this.modules;
                    int         num6  = num3;
                    array[num6].x = (array[num6].x | num5 << 8);
                }
                else if (num4 == 1)
                {
                    AnmModule[] array2 = this.modules;
                    int         num7   = num3;
                    array2[num7].y = (array2[num7].y | num5 << 8);
                }
                else if (num4 == 2)
                {
                    AnmModule[] array3 = this.modules;
                    int         num8   = num3;
                    array3[num8].w = (array3[num8].w | num5 << 8);
                }
                else if (num4 == 3)
                {
                    AnmModule[] array4 = this.modules;
                    int         num9   = num3;
                    array4[num9].h = (array4[num9].h | num5 << 8);
                }
            }
            int num10 = (int)binaryReader.ReadByte();
            this.frames = new AnmFrame[num10];
            for (int k = 0; k < num10; k++)
            {
                AnmFrame anmFrame = default(AnmFrame);
                anmFrame.spriteIndex = (int)binaryReader.ReadUInt16();
                anmFrame.spriteSize  = (int)binaryReader.ReadByte();
                anmFrame.gx          = (int)binaryReader.ReadInt16();
                anmFrame.gy          = (int)binaryReader.ReadInt16();
                anmFrame.gr          = (int)binaryReader.ReadInt16();
                anmFrame.gb          = (int)binaryReader.ReadInt16();
                anmFrame.rx          = (int)binaryReader.ReadInt16();
                anmFrame.ry          = (int)binaryReader.ReadInt16();
                anmFrame.rr          = (int)binaryReader.ReadInt16();
                anmFrame.rb          = (int)binaryReader.ReadInt16();
                this.frames[k]       = anmFrame;
            }
            int num11 = (int)binaryReader.ReadInt16();
            this.sprites = new AnmSprite[num11];
            for (int l = 0; l < num11; l++)
            {
                AnmSprite anmSprite = default(AnmSprite);
                anmSprite.module = (int)binaryReader.ReadByte();
                anmSprite.x      = (int)binaryReader.ReadInt16();
                anmSprite.y      = (int)binaryReader.ReadInt16();
                anmSprite.flip   = (int)binaryReader.ReadByte();
                this.sprites[l]  = anmSprite;
            }
            int num12 = (int)binaryReader.ReadByte();
            this.actions = new AnmAction[num12];
            for (int m = 0; m < num12; m++)
            {
                AnmAction anmAction = default(AnmAction);
                anmAction.sequenceIndex = (int)binaryReader.ReadInt16();
                anmAction.sequenceSize  = (int)binaryReader.ReadChar();
                anmAction.ex1           = (int)binaryReader.ReadChar();
                anmAction.ex2           = (int)binaryReader.ReadChar();
                this.actions[m]         = anmAction;
            }
            int num13 = (int)binaryReader.ReadUInt16();
            this.sequences = new AnmSequence[num13];
            int n = 0;
            while (n < num13)
            {
                int frame = (int)binaryReader.ReadByte();
                int num14 = (int)binaryReader.ReadByte();
                for (int num15 = 0; num15 < num14; num15++)
                {
                    this.sequences[n].frame = frame;
                    n++;
                }
            }
        }
    }