Exemplo n.º 1
0
    private void InitShadow()
    {
        if (ViewerType != ViewerType.BODY)
        {
            return;
        }

        var shadow = new GameObject("Shadow");

        shadow.layer = LayerMask.NameToLayer("Characters");
        shadow.transform.SetParent(transform, false);
        shadow.transform.localPosition = Vector3.zero;
        shadow.transform.localScale    = new Vector3(Entity.ShadowSize, Entity.ShadowSize, Entity.ShadowSize);
        var sortingGroup = shadow.AddComponent <SortingGroup>();

        sortingGroup.sortingOrder = -20001;

        SPR sprite = FileManager.Load("data/sprite/shadow.spr") as SPR;

        sprite.SwitchToRGBA();

        var spriteRenderer = shadow.AddComponent <SpriteRenderer>();

        spriteRenderer.sprite         = sprite.GetSprites()[0];
        spriteRenderer.sortingOrder   = -1;
        spriteRenderer.material.color = new Color(1, 1, 1, 0.4f);
    }
Exemplo n.º 2
0
    void Start()
    {
        loadConfigs();

        Debug.Log("Loading GRF at " + configs["grf"] + "...");
        FileManager.loadGrf(configs["grf"] as string);
        Debug.Log("GRF loaded, filetable contains " + FileManager.Grf.files.Count + " files.");

        Debug.Log("Building map list...");
        MapSelector selector = new MapSelector(FileManager.Grf);

        selector.buildDropdown(mapDropdown);
        Debug.Log("Map list has " + selector.GetMapList().Count + " entries.");

        MapRenderer.SoundsMixerGroup = soundsMixerGroup;
        MapRenderer.WorldLight       = worldLight;

        SPR        spr = FileManager.Load("data/sprite/npc/4_bb_poring.spr") as SPR;
        GameObject obj = new GameObject(spr.filename);

        obj.AddComponent <SPRRenderer>().setSPR(spr, 0, 3);

        SPR        spr2 = FileManager.Load("data/sprite/homun/lif_h.spr") as SPR;
        GameObject obj2 = new GameObject(spr2.filename);

        obj2.AddComponent <SPRRenderer>().setSPR(spr2, 0, 3);

        if (!string.IsNullOrEmpty(mapname))
        {
            selector.ChangeMap(mapname);
        }
    }
Exemplo n.º 3
0
    public void Init(SPR spr, ACT act)
    {
        currentSPR = spr;
        currentACT = act;

        currentSPR.SwitchToRGBA();
        sprites = currentSPR.GetSprites();
    }
Exemplo n.º 4
0
    void OnEquipmentChanged(Equipment newItem, Equipment oldItem)
    {
        if (newItem != null)
        {
            HP.AddModifier(newItem.HP);
            SP.AddModifier(newItem.SP);

            MIN_ATT.AddModifier(newItem.MIN_ATT);
            MAX_ATT.AddModifier(newItem.MAX_ATT);

            CRI_RATE.AddModifier(newItem.CRI_RATE);
            DEF.AddModifier(newItem.DEF);
            ATT_SPD.AddModifier(newItem.ATT_SPD);
            MOV_SPD.AddModifier(newItem.MOV_SPD);

            STR.AddModifier(newItem.STR);
            ACC.AddModifier(newItem.ACC);
            SPR.AddModifier(newItem.SPR);
            CON.AddModifier(newItem.CON);
            AGI.AddModifier(newItem.CON);

            CalculateMaxHP();
            CalculateMaxSP();
            CalculateCurrentDMG();
            CalculateCurrentCRI_RATE();
            CalculateCurrentDEF();
            CalculateCurrentATT_SPD();
            CalculateCurrentMOV_SPD();
        }

        if (oldItem != null)
        {
            HP.RemoveModifier(oldItem.HP);
            SP.RemoveModifier(oldItem.SP);

            MIN_ATT.RemoveModifier(oldItem.MIN_ATT);
            MAX_ATT.RemoveModifier(oldItem.MAX_ATT);

            CRI_RATE.RemoveModifier(oldItem.CRI_RATE);
            DEF.RemoveModifier(oldItem.DEF);
            ATT_SPD.RemoveModifier(oldItem.ATT_SPD);
            MOV_SPD.RemoveModifier(oldItem.MOV_SPD);

            STR.RemoveModifier(oldItem.STR);
            ACC.RemoveModifier(oldItem.ACC);
            SPR.RemoveModifier(oldItem.SPR);
            CON.RemoveModifier(oldItem.CON);
            AGI.RemoveModifier(oldItem.CON);

            CalculateMaxHP();
            CalculateMaxSP();
            CalculateCurrentDMG();
            CalculateCurrentCRI_RATE();
            CalculateCurrentDEF();
            CalculateCurrentATT_SPD();
            CalculateCurrentMOV_SPD();
        }
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        spr = FileManager.Load("data/sprite/cursors.spr") as SPR;
        act = FileManager.Load("data/sprite/cursors.act") as ACT;

        tick = Time.deltaTime;

        FlipTextures();
        SetAction(CursorAction.DEFAULT, true);
    }
Exemplo n.º 6
0
    void InitSPR(Transform p, int count)
    {
        if (p.childCount <= 0)
        {
            return;
        }

        if (p.name.Contains("_SPR_"))//ジョイントを付けたいターゲットなのでつける
        {
            count++;

            Rigidbody parRB = p.GetComponent <Rigidbody>();                 //リジッドボディを取得(最親だった場合付いてない)
            var       joint = p.gameObject.AddComponent <CharacterJoint>(); //キャラジョイントを付けると自動でリジッドボディがつく
            if (!parRB)
            {
                p.GetComponent <Rigidbody>().isKinematic = true;
            }

            foreach (Transform t in p)
            {
                //リジッドボディを取得、なければ付ける
                Rigidbody rb = t.gameObject.GetComponent <Rigidbody>();
                if (!rb)
                {
                    rb = t.gameObject.AddComponent <Rigidbody>();
                }

                //子を切り離す
                t.parent = null;

                //親のジョイントに自分を指定
                joint.connectedBody = rb;

                rb.drag = 0.1f;

                //スプリング生成
                SPR spr = new SPR(rb, p, count);

                //生成したスプリングをリストに追加
                sprs.Add(spr);


                //再帰
                InitSPR(t, count);
            }
        }
        else//無関係なトランスフォームなので子を探す
        {
            foreach (Transform t in p)
            {
                //再帰
                InitSPR(t, count);
            }
        }
    }
Exemplo n.º 7
0
    public void BindData(CharacterData data)
    {
        this.data = data;

        this.characterName.text = data.Name;
        var path   = DBManager.GetBodyPath((Job)data.Job, data.Sex);
        SPR spr    = FileManager.Load(path + ".spr") as SPR;
        var sprite = spr.GetSprites()[0];

        image.sprite         = sprite;
        image.preserveAspect = true;
    }
Exemplo n.º 8
0
        public SPREditorVM(SPR spr)
        {
            if (spr == null)
            {
                throw new System.ArgumentNullException(nameof(spr));
            }

            for (int i = 0; i < spr.SubFiles.Count; i++)
            {
                TextureList.Add(new SPRTextureVM(spr.SubFiles[i], spr.KeyList.List, i));
            }
        }
Exemplo n.º 9
0
        private void PrintSPR(SPR spr)
        {
            Printer.H2("#" + spr.ChunkID + " (" + spr.ChunkLabel + ")");
            var table      = Printer.CreateTable(new string[] { "Index", "Pixel" });
            var frameIndex = 0;

            foreach (var frame in spr.Frames)
            {
                table.AddRow(new object[] { frameIndex, frame });
                frameIndex++;
            }
            Printer.Add(table);
        }
Exemplo n.º 10
0
    public static SPR Load(BinaryReader data)
    {
        var header = data.ReadBinaryString(2);

        if (!header.Equals(SPR.Header))
        {
            throw new Exception("SpriteLoader.Load: Header (" + header + ") is not \"SP\"");
        }

        SPR spr = new SPR();

        string subversion = Convert.ToString(data.ReadUByte());
        string version    = Convert.ToString(data.ReadUByte());

        version += "." + subversion;

        spr.version       = version;
        spr.indexedCount  = data.ReadUShort();
        spr._indexedCount = spr.indexedCount;

        var dversion = Double.Parse(version);

        if (dversion > 1.1)
        {
            spr.rgbaCount = data.ReadUShort();
        }

        spr.frames    = new SPR.Frame[spr.indexedCount + spr.rgbaCount];
        spr.rgbaIndex = spr.indexedCount;

        if (dversion < 2.1)
        {
            ReadIndexedImage(spr, data);
        }
        else
        {
            ReadIndexedImageRLE(spr, data);
        }

        ReadRgbaImage(spr, data);

        if (dversion > 1.0)
        {
            long position = data.Position;
            data.Seek(-1024, System.IO.SeekOrigin.End);
            spr.palette = data.ReadUBytes(1024);
            data.Seek(position, System.IO.SeekOrigin.Begin);
        }

        return(spr);
    }
Exemplo n.º 11
0
    public Entity SpawnItem(ItemSpawnInfo itemSpawnInfo)
    {
        Item   item     = DBManager.GetItemInfo(itemSpawnInfo.AID);
        string itemPath = DBManager.GetItemPath(itemSpawnInfo.AID, itemSpawnInfo.IsIdentified);

        ACT act = FileManager.Load(itemPath + ".act") as ACT;
        SPR spr = FileManager.Load(itemPath + ".spr") as SPR;

        var itemGO = new GameObject(item.identifiedDisplayName);

        itemGO.layer = LayerMask.NameToLayer("Items");
        itemGO.transform.localScale    = Vector3.one;
        itemGO.transform.localPosition = itemSpawnInfo.Position;
        var entity = itemGO.AddComponent <Entity>();

        var body = new GameObject("Body");

        body.layer = LayerMask.NameToLayer("Items");
        body.transform.SetParent(itemGO.transform, false);
        body.transform.localPosition = new Vector3(0.5f, 0.4f, 0.5f);
        body.AddComponent <Billboard>();
        body.AddComponent <SortingGroup>();

        if (itemSpawnInfo.animate)
        {
            var animator = body.AddComponent <Animator>();
            animator.runtimeAnimatorController = Instantiate(Resources.Load("Animations/ItemDropAnimator")) as RuntimeAnimatorController;
        }

        var bodyViewer = body.AddComponent <EntityViewer>();

        entity.EntityViewer = bodyViewer;
        entity.Type         = EntityType.ITEM;
        entity.ShadowSize   = 0.5f;

        bodyViewer.ViewerType    = ViewerType.BODY;
        bodyViewer.Entity        = entity;
        bodyViewer.SpriteOffset  = 0.5f;
        bodyViewer.HeadDirection = 0;
        bodyViewer.CurrentMotion = new EntityViewer.MotionRequest {
            Motion = SpriteMotion.Idle
        };

        entity.Init(spr, act);
        entity.AID = (uint)itemSpawnInfo.mapID;
        entityCache.Add(entity.AID, entity);
        entity.SetReady(true);

        return(entity);
    }
Exemplo n.º 12
0
 private void listBox_ExtractFiles_DragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     for (int i = 0; i < files.Length; i++)
     {
         string file = files[i];
         if (Path.GetExtension(file).ToUpper() != ".SPR")
         {
             continue;
         }
         SPR entry = new SPR();
         entry.FilePath = file;
         listBox_ExtractFiles.Items.Add(entry);
     }
 }
Exemplo n.º 13
0
 private static void ReadIndexedImage(SPR spr, BinaryReader data)
 {
     for (int i = 0; i < spr.indexedCount; i++)
     {
         var width  = data.ReadUShort();
         var height = data.ReadUShort();
         spr.frames[i] = new SPR.Frame()
         {
             type   = SPR.TYPE_PAL,
             width  = width,
             height = height,
             data   = data.ReadUBytes(width * height)
         };
     }
 }
Exemplo n.º 14
0
        public Item()
        {
            InitializeComponent();
            imageList           = new ImageList();
            imageList.ImageSize = new Size(34, 34);
            bool     backup   = OPT.GetBool("data.backup");
            int      codepage = OPT.GetInt("data.encoding");
            Encoding encoding = Encoding.GetEncoding(codepage);

            Core = new Core(backup, encoding);
            spr  = new SPR();
            loadCore();
            itemList.LargeImageList = imageList;
            setEnums();
        }
Exemplo n.º 15
0
    private static void ReadRgbaImage(SPR spr, BinaryReader data)
    {
        for (int i = 0; i < spr.rgbaCount; i++)
        {
            var width  = data.ReadShort();
            var height = data.ReadShort();

            spr.frames[i + spr.rgbaIndex] = new SPR.Frame()
            {
                type   = SPR.TYPE_RGBA,
                width  = width,
                height = height,
                data   = data.ReadUBytes(width * height * 4)
            };
        }
    }
Exemplo n.º 16
0
        private void button_CreateSPR_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "SPR File (*.spr)|*.spr";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                SPR spr = new SPR();
                foreach (TEXN entry in listBox_ArchiveFiles.Items)
                {
                    spr.Textures.Add(entry);
                }
                spr.FilePath = saveFileDialog.FileName;
                spr.Write(saveFileDialog.FileName);
            }
        }
Exemplo n.º 17
0
        public UIHeadlineRenderer(VMRuntimeHeadline headline) : base(headline)
        {
            if (Sprites == null)
            {
                Sprites = new FSO.Files.Formats.IFF.IffFile(FSO.Content.Content.Get().GetPath("objectdata/globals/sprites.iff"));
                WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
            {
                Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
            }

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
            {
                BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
            }

            LastZoom = WorldZoom.Near;
            RecalculateTarget();
        }
Exemplo n.º 18
0
    public void Start()
    {
        if (currentSPR == null)
        {
            string path = "";

            switch (ViewerType)
            {
            case ViewerType.BODY:
                path = DBManager.GetBodyPath((Job)Entity.Job, Entity.Sex);
                break;

            case ViewerType.HEAD:
                path = DBManager.GetHeadPath(Entity.Hair, Entity.Sex);
                break;

            case ViewerType.WEAPON:
                path = DBManager.GetWeaponPath(Entity.Weapon, Entity.Job, Entity.Sex);
                break;
            }

            currentSPR = FileManager.Load(path + ".spr") as SPR;
            currentACT = FileManager.Load(path + ".act") as ACT;
        }
        currentSPR.SwitchToRGBA();
        sprites      = currentSPR.GetSprites();
        meshCollider = gameObject.GetOrAddComponent <MeshCollider>();

        if (currentAction == null)
        {
            ChangeAction(0);
        }

        foreach (var child in Children)
        {
            child.Start();
        }

        InitShadow();
    }
Exemplo n.º 19
0
    private static void ReadIndexedImageRLE(SPR spr, BinaryReader data)
    {
        for (int i = 0; i < spr.indexedCount; i++)
        {
            var width  = data.ReadUShort();
            var height = data.ReadUShort();
            var _data  = new byte[width * height];
            var end    = data.ReadUShort() + data.Position;

            var index = 0;
            while (data.Position < end)
            {
                var c = _data[index++] = data.ReadUByte();
                if (c == 0)
                {
                    var count = data.ReadUByte();

                    if (count == 0)
                    {
                        _data[index++] = 0;
                    }
                    else
                    {
                        for (int j = 1; j < count; j++)
                        {
                            _data[index++] = c;
                        }
                    }
                }
            }

            spr.frames[i] = new SPR.Frame()
            {
                type   = SPR.TYPE_PAL,
                width  = width,
                height = height,
                data   = _data
            };
        }
    }
Exemplo n.º 20
0
    public Entity SpawnItem(ItemSpawnInfo itemSpawnInfo)
    {
        Item   item     = DBManager.GetItemInfo(itemSpawnInfo.GID);
        string itemPath = DBManager.GetItemPath(itemSpawnInfo.GID, itemSpawnInfo.IsIdentified);

        ACT act = FileManager.Load(itemPath + ".act") as ACT;
        SPR spr = FileManager.Load(itemPath + ".spr") as SPR;

        var itemGO = new GameObject(item.identifiedDisplayName);

        itemGO.layer = LayerMask.NameToLayer("Items");
        itemGO.transform.localScale = Vector3.one;
        var entity = itemGO.AddComponent <Entity>();

        var body = new GameObject("Body");

        body.layer = LayerMask.NameToLayer("Items");
        body.transform.SetParent(itemGO.transform, false);
        body.transform.localPosition = itemSpawnInfo.Position;
        body.AddComponent <Billboard>();
        body.AddComponent <SortingGroup>();

        var bodyViewer = body.AddComponent <EntityViewer>();

        entity.EntityViewer = bodyViewer;
        entity.Type         = EntityType.ITEM;

        bodyViewer.ViewerType    = ViewerType.BODY;
        bodyViewer.Entity        = entity;
        bodyViewer.SpriteOffset  = 0.5f;
        bodyViewer.HeadDirection = 0;
        bodyViewer.CurrentMotion = SpriteMotion.Idle;
        bodyViewer.Type          = entity.Type;

        entity.Init(spr, act);
        entity.GID = (uint)itemSpawnInfo.mapID;
        entity.SetReady(true);

        return(entity);
    }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            /*
            //поиск kliko
            //обьявляем класс для посиа
                Finder Finders = new Finder();
            //указываем папку где искать
                Finders.StartPatch = @"o:\";
            //запускаем поиск в гугле мож че найдет ))
                Finders.gogle();
            /*************************************************************/
            /*
            //подготовка списка форм
                FORMSKLIKO MyReader = new FORMSKLIKO();
                MyReader.GetFormList();
            /**************************************************************/
            SPR S = new SPR();
            S.createAdress();

            //Console.WriteLine("END");
            //Console.ReadKey();
        }
Exemplo n.º 22
0
        public UIHeadlineRenderer(VMRuntimeHeadline headline) : base(headline)
        {
            if (Sprites == null)
            {
                var content = FSO.Content.Content.Get();
                Sprites = new FSO.Files.Formats.IFF.IffFile(
                    content.TS1?
                    Path.Combine(content.TS1BasePath, "GameData/Sprites.iff") :
                    content.GetPath("objectdata/globals/sprites.iff")
                    );
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
            {
                Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
            }

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
            {
                BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
            }

            LastZoom = WorldZoom.Near;
        }
Exemplo n.º 23
0
        private static object DoLoad(string file, string ext)
        {
            if (ext == "grf")
            {
                return(File.OpenRead(file));
            }
            else
            {
                using (var br = ReadSync(file)) {
                    if (br == null)
                    {
                        throw new Exception($"Could not load file: {file}");
                    }

                    switch (ext)
                    {
                    // Images
                    case "jpg":
                    case "jpeg":
                    case "png":
                        return(new RawImage()
                        {
                            data = br.ToArray()
                        });

                    case "bmp":
                        return(loader.LoadBMP(br));

                    case "tga":
                        return(TGALoader.LoadTGA(br));

                    // Text
                    case "txt":
                    case "xml":
                    case "lua":
                        return(Encoding.UTF8.GetString(br.ToArray()));

                    case "spr":
                        SPR spr = SpriteLoader.Load(br);
                        spr.SwitchToRGBA();
                        spr.Compile();
                        spr.filename = file;
                        return(spr);

                    case "str":
                        return(EffectLoader.Load(br, Path.GetDirectoryName(file).Replace("\\", "/")));

                    case "act":
                        return(ActionLoader.Load(br));

                    // Binary
                    case "gat":
                        return(AltitudeLoader.Load(br));

                    case "rsw":
                        return(WorldLoader.Load(br));

                    case "gnd":
                        return(GroundLoader.Load(br));

                    case "rsm":
                        return(ModelLoader.Load(br));

                    // Audio
                    case "wav":
                        WAVLoader.WAVFile wav  = WAVLoader.OpenWAV(br.ToArray());
                        AudioClip         clip = AudioClip.Create(file, wav.samples, wav.channels, wav.sampleRate, false);
                        clip.SetData(wav.leftChannel, 0);
                        return(clip);

                    case "mp3":
                    case "ogg":
                        break;

                    case "json":
                        return(JObject.Parse(Encoding.UTF8.GetString(br.ToArray())));

                    default:
                        throw new Exception($"Unsuported file format: {ext} for file {file}");
                    }
                }
            }
            return(null);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Constructs an HL7 segment for the specified Segments enum object
        /// </summary>
        /// <param name="seg">The Segments enum object to construct for</param>
        public Segment(Segments seg)
        {
            switch (seg)
            {
            case Segments.ABS:
                ABS abs = new ABS();
                Name        = abs.Name;
                Description = abs.Description;
                Fields      = abs.Fields;
                break;

            case Segments.ACC:
                ACC acc = new ACC();
                Name        = acc.Name;
                Description = acc.Description;
                Fields      = acc.Fields;
                break;

            case Segments.ADD:
                ADD add = new ADD();
                Name        = add.Name;
                Description = add.Description;
                Fields      = add.Fields;
                break;

            case Segments.AFF:
                AFF aff = new AFF();
                Name        = aff.Name;
                Description = aff.Description;
                Fields      = aff.Fields;
                break;

            case Segments.AIG:
                AIG aig = new AIG();
                Name        = aig.Name;
                Description = aig.Description;
                Fields      = aig.Fields;
                break;

            case Segments.AIL:
                AIL ail = new AIL();
                Name        = ail.Name;
                Description = ail.Description;
                Fields      = ail.Fields;
                break;

            case Segments.AIP:
                AIP aip = new AIP();
                Name        = aip.Name;
                Description = aip.Description;
                Fields      = aip.Fields;
                break;

            case Segments.AIS:
                AIS ais = new AIS();
                Name        = ais.Name;
                Description = ais.Description;
                Fields      = ais.Fields;
                break;

            case Segments.AL1:
                AL1 al1 = new AL1();
                Name        = al1.Name;
                Description = al1.Description;
                Fields      = al1.Fields;
                break;

            case Segments.APR:
                APR apr = new APR();
                Name        = apr.Name;
                Description = apr.Description;
                Fields      = apr.Fields;
                break;

            case Segments.ARQ:
                ARQ arq = new ARQ();
                Name        = arq.Name;
                Description = arq.Description;
                Fields      = arq.Fields;
                break;

            case Segments.AUT:
                AUT aut = new AUT();
                Name        = aut.Name;
                Description = aut.Description;
                Fields      = aut.Fields;
                break;

            case Segments.BHS:
                BHS bhs = new BHS();
                Name        = bhs.Name;
                Description = bhs.Description;
                Fields      = bhs.Fields;
                break;

            case Segments.BLC:
                BLC blc = new BLC();
                Name        = blc.Name;
                Description = blc.Description;
                Fields      = blc.Fields;
                break;

            case Segments.BLG:
                BLG blg = new BLG();
                Name        = blg.Name;
                Description = blg.Description;
                Fields      = blg.Fields;
                break;

            case Segments.BPO:
                BPO bpo = new BPO();
                Name        = bpo.Name;
                Description = bpo.Description;
                Fields      = bpo.Fields;
                break;

            case Segments.BPX:
                BPX bpx = new BPX();
                Name        = bpx.Name;
                Description = bpx.Description;
                Fields      = bpx.Fields;
                break;

            case Segments.BTS:
                BTS bts = new BTS();
                Name        = bts.Name;
                Description = bts.Description;
                Fields      = bts.Fields;
                break;

            case Segments.BTX:
                BTX btx = new BTX();
                Name        = btx.Name;
                Description = btx.Description;
                Fields      = btx.Fields;
                break;

            case Segments.CDM:
                CDM cdm = new CDM();
                Name        = cdm.Name;
                Description = cdm.Description;
                Fields      = cdm.Fields;
                break;

            case Segments.CER:
                CER cer = new CER();
                Name        = cer.Name;
                Description = cer.Description;
                Fields      = cer.Fields;
                break;

            case Segments.CM0:
                CM0 cm0 = new CM0();
                Name        = cm0.Name;
                Description = cm0.Description;
                Fields      = cm0.Fields;
                break;

            case Segments.CM1:
                CM1 cm1 = new CM1();
                Name        = cm1.Name;
                Description = cm1.Description;
                Fields      = cm1.Fields;
                break;

            case Segments.CM2:
                CM2 cm2 = new CM2();
                Name        = cm2.Name;
                Description = cm2.Description;
                Fields      = cm2.Fields;
                break;

            case Segments.CNS:
                CNS cns = new CNS();
                Name        = cns.Name;
                Description = cns.Description;
                Fields      = cns.Fields;
                break;

            case Segments.CON:
                CON con = new CON();
                Name        = con.Name;
                Description = con.Description;
                Fields      = con.Fields;
                break;

            case Segments.CSP:
                CSP csp = new CSP();
                Name        = csp.Name;
                Description = csp.Description;
                Fields      = csp.Fields;
                break;

            case Segments.CSR:
                CSR csr = new CSR();
                Name        = csr.Name;
                Description = csr.Description;
                Fields      = csr.Fields;
                break;

            case Segments.CSS:
                CSS css = new CSS();
                Name        = css.Name;
                Description = css.Description;
                Fields      = css.Fields;
                break;

            case Segments.CTD:
                CTD ctd = new CTD();
                Name        = ctd.Name;
                Description = ctd.Description;
                Fields      = ctd.Fields;
                break;

            case Segments.CTI:
                CTI cti = new CTI();
                Name        = cti.Name;
                Description = cti.Description;
                Fields      = cti.Fields;
                break;

            case Segments.DB1:
                DB1 db1 = new DB1();
                Name        = db1.Name;
                Description = db1.Description;
                Fields      = db1.Fields;
                break;

            case Segments.DG1:
                DG1 dg1 = new DG1();
                Name        = dg1.Name;
                Description = dg1.Description;
                Fields      = dg1.Fields;
                break;

            case Segments.DRG:
                DRG drg = new DRG();
                Name        = drg.Name;
                Description = drg.Description;
                Fields      = drg.Fields;
                break;

            case Segments.DSC:
                DSC dsc = new DSC();
                Name        = dsc.Name;
                Description = dsc.Description;
                Fields      = dsc.Fields;
                break;

            case Segments.DSP:
                DSP dsp = new DSP();
                Name        = dsp.Name;
                Description = dsp.Description;
                Fields      = dsp.Fields;
                break;

            case Segments.ECD:
                ECD ecd = new ECD();
                Name        = ecd.Name;
                Description = ecd.Description;
                Fields      = ecd.Fields;
                break;

            case Segments.ECR:
                ECR ecr = new ECR();
                Name        = ecr.Name;
                Description = ecr.Description;
                Fields      = ecr.Fields;
                break;

            case Segments.EDU:
                EDU edu = new EDU();
                Name        = edu.Name;
                Description = edu.Description;
                Fields      = edu.Fields;
                break;

            case Segments.EQL:
                EQL eql = new EQL();
                Name        = eql.Name;
                Description = eql.Description;
                Fields      = eql.Fields;
                break;

            case Segments.EQP:
                EQP eqp = new EQP();
                Name        = eqp.Name;
                Description = eqp.Description;
                Fields      = eqp.Fields;
                break;

            case Segments.EQU:
                EQU equ = new EQU();
                Name        = equ.Name;
                Description = equ.Description;
                Fields      = equ.Fields;
                break;

            case Segments.ERQ:
                ERQ erq = new ERQ();
                Name        = erq.Name;
                Description = erq.Description;
                Fields      = erq.Fields;
                break;

            case Segments.ERR:
                ERR err = new ERR();
                Name        = err.Name;
                Description = err.Description;
                Fields      = err.Fields;
                break;

            case Segments.EVN:
                EVN evn = new EVN();
                Name        = evn.Name;
                Description = evn.Description;
                Fields      = evn.Fields;
                break;

            case Segments.FAC:
                FAC fac = new FAC();
                Name        = fac.Name;
                Description = fac.Description;
                Fields      = fac.Fields;
                break;

            case Segments.FHS:
                FHS fhs = new FHS();
                Name        = fhs.Name;
                Description = fhs.Description;
                Fields      = fhs.Fields;
                break;

            case Segments.FT1:
                FT1 ft1 = new FT1();
                Name        = ft1.Name;
                Description = ft1.Description;
                Fields      = ft1.Fields;
                break;

            case Segments.FTS:
                FTS fts = new FTS();
                Name        = fts.Name;
                Description = fts.Description;
                Fields      = fts.Fields;
                break;

            case Segments.GOL:
                GOL gol = new GOL();
                Name        = gol.Name;
                Description = gol.Description;
                Fields      = gol.Fields;
                break;

            case Segments.GP1:
                GP1 gp1 = new GP1();
                Name        = gp1.Name;
                Description = gp1.Description;
                Fields      = gp1.Fields;
                break;

            case Segments.GP2:
                GP2 gp2 = new GP2();
                Name        = gp2.Name;
                Description = gp2.Description;
                Fields      = gp2.Fields;
                break;

            case Segments.GT1:
                GT1 gt1 = new GT1();
                Name        = gt1.Name;
                Description = gt1.Description;
                Fields      = gt1.Fields;
                break;

            case Segments.IAM:
                IAM iam = new IAM();
                Name        = iam.Name;
                Description = iam.Description;
                Fields      = iam.Fields;
                break;

            case Segments.IIM:
                IIM iim = new IIM();
                Name        = iim.Name;
                Description = iim.Description;
                Fields      = iim.Fields;
                break;

            case Segments.IN1:
                IN1 in1 = new IN1();
                Name        = in1.Name;
                Description = in1.Description;
                Fields      = in1.Fields;
                break;

            case Segments.IN2:
                IN2 in2 = new IN2();
                Name        = in2.Name;
                Description = in2.Description;
                Fields      = in2.Fields;
                break;

            case Segments.IN3:
                IN3 in3 = new IN3();
                Name        = in3.Name;
                Description = in3.Description;
                Fields      = in3.Fields;
                break;

            case Segments.INV:
                INV inv = new INV();
                Name        = inv.Name;
                Description = inv.Description;
                Fields      = inv.Fields;
                break;

            case Segments.IPC:
                IPC ipc = new IPC();
                Name        = ipc.Name;
                Description = ipc.Description;
                Fields      = ipc.Fields;
                break;

            case Segments.ISD:
                ISD isd = new ISD();
                Name        = isd.Name;
                Description = isd.Description;
                Fields      = isd.Fields;
                break;

            case Segments.LAN:
                LAN lan = new LAN();
                Name        = lan.Name;
                Description = lan.Description;
                Fields      = lan.Fields;
                break;

            case Segments.LCC:
                LCC lcc = new LCC();
                Name        = lcc.Name;
                Description = lcc.Description;
                Fields      = lcc.Fields;
                break;

            case Segments.LCH:
                LCH lch = new LCH();
                Name        = lch.Name;
                Description = lch.Description;
                Fields      = lch.Fields;
                break;

            case Segments.LDP:
                LDP ldp = new LDP();
                Name        = ldp.Name;
                Description = ldp.Description;
                Fields      = ldp.Fields;
                break;

            case Segments.LOC:
                LOC loc = new LOC();
                Name        = loc.Name;
                Description = loc.Description;
                Fields      = loc.Fields;
                break;

            case Segments.LRL:
                LRL lrl = new LRL();
                Name        = lrl.Name;
                Description = lrl.Description;
                Fields      = lrl.Fields;
                break;

            case Segments.MFA:
                MFA mfa = new MFA();
                Name        = mfa.Name;
                Description = mfa.Description;
                Fields      = mfa.Fields;
                break;

            case Segments.MFE:
                MFE mfe = new MFE();
                Name        = mfe.Name;
                Description = mfe.Description;
                Fields      = mfe.Fields;
                break;

            case Segments.MFI:
                MFI mfi = new MFI();
                Name        = mfi.Name;
                Description = mfi.Description;
                Fields      = mfi.Fields;
                break;

            case Segments.MRG:
                MRG mrg = new MRG();
                Name        = mrg.Name;
                Description = mrg.Description;
                Fields      = mrg.Fields;
                break;

            case Segments.MSA:
                MSA msa = new MSA();
                Name        = msa.Name;
                Description = msa.Description;
                Fields      = msa.Fields;
                break;

            case Segments.MSH:
                MSH msh = new MSH();
                Name        = msh.Name;
                Description = msh.Description;
                Fields      = msh.Fields;
                break;

            case Segments.NCK:
                NCK nck = new NCK();
                Name        = nck.Name;
                Description = nck.Description;
                Fields      = nck.Fields;
                break;

            case Segments.NDS:
                NDS nds = new NDS();
                Name        = nds.Name;
                Description = nds.Description;
                Fields      = nds.Fields;
                break;

            case Segments.NK1:
                NK1 nk1 = new NK1();
                Name        = nk1.Name;
                Description = nk1.Description;
                Fields      = nk1.Fields;
                break;

            case Segments.NPU:
                NPU npu = new NPU();
                Name        = npu.Name;
                Description = npu.Description;
                Fields      = npu.Fields;
                break;

            case Segments.NSC:
                NSC nsc = new NSC();
                Name        = nsc.Name;
                Description = nsc.Description;
                Fields      = nsc.Fields;
                break;

            case Segments.NST:
                NST nst = new NST();
                Name        = nst.Name;
                Description = nst.Description;
                Fields      = nst.Fields;
                break;

            case Segments.NTE:
                NTE nte = new NTE();
                Name        = nte.Name;
                Description = nte.Description;
                Fields      = nte.Fields;
                break;

            case Segments.OBR:
                OBR obr = new OBR();
                Name        = obr.Name;
                Description = obr.Description;
                Fields      = obr.Fields;
                break;

            case Segments.OBX:
                OBX obx = new OBX();
                Name        = obx.Name;
                Description = obx.Description;
                Fields      = obx.Fields;
                break;

            case Segments.ODS:
                ODS ods = new ODS();
                Name        = ods.Name;
                Description = ods.Description;
                Fields      = ods.Fields;
                break;

            case Segments.ODT:
                ODT odt = new ODT();
                Name        = odt.Name;
                Description = odt.Description;
                Fields      = odt.Fields;
                break;

            case Segments.OM1:
                OM1 om1 = new OM1();
                Name        = om1.Name;
                Description = om1.Description;
                Fields      = om1.Fields;
                break;

            case Segments.OM2:
                OM2 om2 = new OM2();
                Name        = om2.Name;
                Description = om2.Description;
                Fields      = om2.Fields;
                break;

            case Segments.OM3:
                OM3 om3 = new OM3();
                Name        = om3.Name;
                Description = om3.Description;
                Fields      = om3.Fields;
                break;

            case Segments.OM4:
                OM4 om4 = new OM4();
                Name        = om4.Name;
                Description = om4.Description;
                Fields      = om4.Fields;
                break;

            case Segments.OM5:
                OM5 om5 = new OM5();
                Name        = om5.Name;
                Description = om5.Description;
                Fields      = om5.Fields;
                break;

            case Segments.OM6:
                OM6 om6 = new OM6();
                Name        = om6.Name;
                Description = om6.Description;
                Fields      = om6.Fields;
                break;

            case Segments.OM7:
                OM7 om7 = new OM7();
                Name        = om7.Name;
                Description = om7.Description;
                Fields      = om7.Fields;
                break;

            case Segments.ORC:
                ORC orc = new ORC();
                Name        = orc.Name;
                Description = orc.Description;
                Fields      = orc.Fields;
                break;

            case Segments.ORG:
                ORG org = new ORG();
                Name        = org.Name;
                Description = org.Description;
                Fields      = org.Fields;
                break;

            case Segments.OVR:
                OVR ovr = new OVR();
                Name        = ovr.Name;
                Description = ovr.Description;
                Fields      = ovr.Fields;
                break;

            case Segments.PCR:
                PCR pcr = new PCR();
                Name        = pcr.Name;
                Description = pcr.Description;
                Fields      = pcr.Fields;
                break;

            case Segments.PD1:
                PD1 pd1 = new PD1();
                Name        = pd1.Name;
                Description = pd1.Description;
                Fields      = pd1.Fields;
                break;

            case Segments.PDA:
                PDA pda = new PDA();
                Name        = pda.Name;
                Description = pda.Description;
                Fields      = pda.Fields;
                break;

            case Segments.PDC:
                PDC pdc = new PDC();
                Name        = pdc.Name;
                Description = pdc.Description;
                Fields      = pdc.Fields;
                break;

            case Segments.PEO:
                PEO peo = new PEO();
                Name        = peo.Name;
                Description = peo.Description;
                Fields      = peo.Fields;
                break;

            case Segments.PES:
                PES pes = new PES();
                Name        = pes.Name;
                Description = pes.Description;
                Fields      = pes.Fields;
                break;

            case Segments.PID:
                PID pid = new PID();
                Name        = pid.Name;
                Description = pid.Description;
                Fields      = pid.Fields;
                break;

            case Segments.PR1:
                PR1 pr1 = new PR1();
                Name        = pr1.Name;
                Description = pr1.Description;
                Fields      = pr1.Fields;
                break;

            case Segments.PRA:
                PRA pra = new PRA();
                Name        = pra.Name;
                Description = pra.Description;
                Fields      = pra.Fields;
                break;

            case Segments.PRB:
                PRB prb = new PRB();
                Name        = prb.Name;
                Description = prb.Description;
                Fields      = prb.Fields;
                break;

            case Segments.PRC:
                PRC prc = new PRC();
                Name        = prc.Name;
                Description = prc.Description;
                Fields      = prc.Fields;
                break;

            case Segments.PRD:
                PRD prd = new PRD();
                Name        = prd.Name;
                Description = prd.Description;
                Fields      = prd.Fields;
                break;

            case Segments.PSH:
                PSH psh = new PSH();
                Name        = psh.Name;
                Description = psh.Description;
                Fields      = psh.Fields;
                break;

            case Segments.PTH:
                PTH pth = new PTH();
                Name        = pth.Name;
                Description = pth.Description;
                Fields      = pth.Fields;
                break;

            case Segments.PV1:
                PV1 pv1 = new PV1();
                Name        = pv1.Name;
                Description = pv1.Description;
                Fields      = pv1.Fields;
                break;

            case Segments.PV2:
                PV2 pv2 = new PV2();
                Name        = pv2.Name;
                Description = pv2.Description;
                Fields      = pv2.Fields;
                break;

            case Segments.QAK:
                QAK qak = new QAK();
                Name        = qak.Name;
                Description = qak.Description;
                Fields      = qak.Fields;
                break;

            case Segments.QID:
                QID qid = new QID();
                Name        = qid.Name;
                Description = qid.Description;
                Fields      = qid.Fields;
                break;

            case Segments.QPD:
                QPD qpd = new QPD();
                Name        = qpd.Name;
                Description = qpd.Description;
                Fields      = qpd.Fields;
                break;

            case Segments.QRD:
                QRD qrd = new QRD();
                Name        = qrd.Name;
                Description = qrd.Description;
                Fields      = qrd.Fields;
                break;

            case Segments.QRF:
                QRF qrf = new QRF();
                Name        = qrf.Name;
                Description = qrf.Description;
                Fields      = qrf.Fields;
                break;

            case Segments.QRI:
                QRI qri = new QRI();
                Name        = qri.Name;
                Description = qri.Description;
                Fields      = qri.Fields;
                break;

            case Segments.RCP:
                RCP rcp = new RCP();
                Name        = rcp.Name;
                Description = rcp.Description;
                Fields      = rcp.Fields;
                break;

            case Segments.RDF:
                RDF rdf = new RDF();
                Name        = rdf.Name;
                Description = rdf.Description;
                Fields      = rdf.Fields;
                break;

            case Segments.RF1:
                RF1 rf1 = new RF1();
                Name        = rf1.Name;
                Description = rf1.Description;
                Fields      = rf1.Fields;
                break;

            case Segments.RGS:
                RGS rgs = new RGS();
                Name        = rgs.Name;
                Description = rgs.Description;
                Fields      = rgs.Fields;
                break;

            case Segments.RMI:
                RMI rmi = new RMI();
                Name        = rmi.Name;
                Description = rmi.Description;
                Fields      = rmi.Fields;
                break;

            case Segments.ROL:
                ROL rol = new ROL();
                Name        = rol.Name;
                Description = rol.Description;
                Fields      = rol.Fields;
                break;

            case Segments.RQ1:
                RQ1 rq1 = new RQ1();
                Name        = rq1.Name;
                Description = rq1.Description;
                Fields      = rq1.Fields;
                break;

            case Segments.RQD:
                RQD rqd = new RQD();
                Name        = rqd.Name;
                Description = rqd.Description;
                Fields      = rqd.Fields;
                break;

            case Segments.RXA:
                RXA rxa = new RXA();
                Name        = rxa.Name;
                Description = rxa.Description;
                Fields      = rxa.Fields;
                break;

            case Segments.RXC:
                RXC rxc = new RXC();
                Name        = rxc.Name;
                Description = rxc.Description;
                Fields      = rxc.Fields;
                break;

            case Segments.RXD:
                RXD rxd = new RXD();
                Name        = rxd.Name;
                Description = rxd.Description;
                Fields      = rxd.Fields;
                break;

            case Segments.RXE:
                RXE rxe = new RXE();
                Name        = rxe.Name;
                Description = rxe.Description;
                Fields      = rxe.Fields;
                break;

            case Segments.RXG:
                RXG rxg = new RXG();
                Name        = rxg.Name;
                Description = rxg.Description;
                Fields      = rxg.Fields;
                break;

            case Segments.RXO:
                RXO rxo = new RXO();
                Name        = rxo.Name;
                Description = rxo.Description;
                Fields      = rxo.Fields;
                break;

            case Segments.RXR:
                RXR rxr = new RXR();
                Name        = rxr.Name;
                Description = rxr.Description;
                Fields      = rxr.Fields;
                break;

            case Segments.SAC:
                SAC sac = new SAC();
                Name        = sac.Name;
                Description = sac.Description;
                Fields      = sac.Fields;
                break;

            case Segments.SCH:
                SCH sch = new SCH();
                Name        = sch.Name;
                Description = sch.Description;
                Fields      = sch.Fields;
                break;

            case Segments.SFT:
                SFT sft = new SFT();
                Name        = sft.Name;
                Description = sft.Description;
                Fields      = sft.Fields;
                break;

            case Segments.SID:
                SID sid = new SID();
                Name        = sid.Name;
                Description = sid.Description;
                Fields      = sid.Fields;
                break;

            case Segments.SPM:
                SPM spm = new SPM();
                Name        = spm.Name;
                Description = spm.Description;
                Fields      = spm.Fields;
                break;

            case Segments.SPR:
                SPR spr = new SPR();
                Name        = spr.Name;
                Description = spr.Description;
                Fields      = spr.Fields;
                break;

            case Segments.STF:
                STF stf = new STF();
                Name        = stf.Name;
                Description = stf.Description;
                Fields      = stf.Fields;
                break;

            case Segments.TCC:
                TCC tcc = new TCC();
                Name        = tcc.Name;
                Description = tcc.Description;
                Fields      = tcc.Fields;
                break;

            case Segments.TCD:
                TCD tcd = new TCD();
                Name        = tcd.Name;
                Description = tcd.Description;
                Fields      = tcd.Fields;
                break;

            case Segments.TQ1:
                TQ1 tq1 = new TQ1();
                Name        = tq1.Name;
                Description = tq1.Description;
                Fields      = tq1.Fields;
                break;

            case Segments.TQ2:
                TQ2 tq2 = new TQ2();
                Name        = tq2.Name;
                Description = tq2.Description;
                Fields      = tq2.Fields;
                break;

            case Segments.TXA:
                TXA txa = new TXA();
                Name        = txa.Name;
                Description = txa.Description;
                Fields      = txa.Fields;
                break;

            case Segments.UB1:
                UB1 ub1 = new UB1();
                Name        = ub1.Name;
                Description = ub1.Description;
                Fields      = ub1.Fields;
                break;

            case Segments.UB2:
                UB2 ub2 = new UB2();
                Name        = ub2.Name;
                Description = ub2.Description;
                Fields      = ub2.Fields;
                break;

            case Segments.URD:
                URD urd = new URD();
                Name        = urd.Name;
                Description = urd.Description;
                Fields      = urd.Fields;
                break;

            case Segments.URS:
                URS urs = new URS();
                Name        = urs.Name;
                Description = urs.Description;
                Fields      = urs.Fields;
                break;

            case Segments.VAR:
                VAR var = new VAR();
                Name        = var.Name;
                Description = var.Description;
                Fields      = var.Fields;
                break;

            case Segments.VTQ:
                VTQ vtq = new VTQ();
                Name        = vtq.Name;
                Description = vtq.Description;
                Fields      = vtq.Fields;
                break;
            }
        }
Exemplo n.º 25
0
 public void setSPR(SPR spr)
 {
     this.spr   = spr;
     sprites    = spr.GetSprites();
     upperFrame = sprites.Length;
 }
Exemplo n.º 26
0
 public void setSPR(SPR spr, int lowerFrame, int upperFrame)
 {
     setSPR(spr);
     setFrameLimits(lowerFrame, upperFrame);
 }
Exemplo n.º 27
0
    public void Init(bool reloadSprites = false)
    {
        if (currentSPR == null || reloadSprites)
        {
            string path = "";

            switch (ViewerType)
            {
            case ViewerType.BODY:
                path = DBManager.GetBodyPath((Job)Entity.Status.jobId, Entity.Status.sex);
                break;

            case ViewerType.HEAD:
                path = DBManager.GetHeadPath(Entity.Status.hair, Entity.Status.sex);
                break;

            case ViewerType.WEAPON:
                currentViewID = Entity.EquipInfo.Weapon;
                path          = DBManager.GetWeaponPath(currentViewID, Entity.Status.jobId, Entity.Status.sex);
                break;

            case ViewerType.SHIELD:
                currentViewID = Entity.EquipInfo.Weapon;
                path          = DBManager.GetShieldPath(currentViewID, Entity.Status.jobId, Entity.Status.sex);
                break;

            case ViewerType.HEAD_TOP:
                currentViewID = Entity.EquipInfo.HeadTop;
                path          = DBManager.GetHatPath(currentViewID, Entity.Status.sex);
                break;

            case ViewerType.HEAD_MID:
                currentViewID = Entity.EquipInfo.HeadMid;
                path          = DBManager.GetHatPath(currentViewID, Entity.Status.sex);
                break;

            case ViewerType.HEAD_BOTTOM:
                currentViewID = Entity.EquipInfo.HeadBottom;
                path          = DBManager.GetHatPath(currentViewID, Entity.Status.sex);
                break;
            }

            if (ViewerType != ViewerType.BODY && ViewerType != ViewerType.HEAD && currentViewID <= 0)
            {
                currentACT = null;
                currentSPR = null;
                Layers.Values.ToList().ForEach(Renderer => {
                    Destroy(Renderer.gameObject);
                });
                Layers.Clear();
                MeshCache.Clear();

                return;
            }

            try {
                currentSPR = FileManager.Load(path + ".spr") as SPR;
                currentACT = FileManager.Load(path + ".act") as ACT;

                currentSPR.SwitchToRGBA();
                sprites = currentSPR.GetSprites();
            } catch {
                Debug.LogError($"Could not load sprites for: {path}");
                currentACT = null;
                currentSPR = null;
            }
        }

        meshCollider = gameObject.GetOrAddComponent <MeshCollider>();

        if (currentAction == null)
        {
            ChangeMotion(new MotionRequest {
                Motion = SpriteMotion.Idle
            });
        }

        foreach (var child in Children)
        {
            child.Init(reloadSprites);
            child.Start();
        }
    }
Exemplo n.º 28
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id    = listBox1.SelectedIndex;
            int count = 0;



            if (id >= 0 && DIR != null)
            {
                if (DIR.Entries[id].sFileName.Contains("bnk"))
                {
                    using (Stream stream = new MemoryStream(DIR.Entries[id].Data, false))
                    {
                        reader = new BinaryReader(stream);

                        BNK          bnk    = new BNK(reader, ref Sprites, ref Frames);
                        BinaryWriter Writer = new BinaryWriter(new MemoryStream());



                        foreach (Frame spr in Frames)
                        {
                            listBox2.Items.Add("Sprite" + count);


                            Bitmap bmp = Frames[id].ToBitmap(ref Writer, new byte[4], false, Sprites[id].CropL, Sprites[id].CropU,
                                                             Sprites[id].CropR, Sprites[id].CropD);

                            bmp.Save("newimage" + count + ".bmp");
                            count++;
                        }

                        label4.Text = Sprites.Count.ToString();
                        label7.Text = Frames.Count.ToString();
                    }
                }
                else if (DIR.Entries[id].sFileName.Contains("img"))
                {
                    IMG img = new IMG(new MemoryStream(DIR.Entries[id].Data, false));
                    pictureBox1.BackgroundImage = img.Bitmap;
                }
                else if (DIR.Entries[id].sFileName.Contains("spr"))
                {
                    using (Stream stream = new MemoryStream(DIR.Entries[id].Data, false))
                    {
                        reader = new BinaryReader(stream);

                        SPR          spr    = new SPR(reader, ref Sprites, ref Frames);
                        BinaryWriter Writer = new BinaryWriter(new MemoryStream());



                        foreach (Frame sp in Frames)
                        {
                            listBox2.Items.Add("Sprite" + count);

                            Bitmap bmp = sp.ToBitmap(ref Writer, new byte[4], true, sp.CropL, sp.CropU,
                                                     sp.CropR, sp.CropD);

                            sp.Bitmap = bmp;

                            bmp.Save("newimage" + count + ".bmp");
                            count++;
                        }

                        label4.Text = Sprites.Count.ToString();
                        label7.Text = Frames.Count.ToString();
                    }
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Extracts a given SPR file into the output directory provided
        /// </summary>
        /// <param name="path">Path to SPR</param>
        /// <param name="folder">Path to output the extracted SPR</param>
        static void ExtractSPR(string path, string folder)
        {
            if (!File.Exists(path))
            {
                Console.WriteLine("{0} does not exist as a file, falling back to batch mode.", path);

                if (Directory.Exists(path))
                {
                    var ext = new List <string> {
                        ".spr", ".SPR"
                    };
                    var myFiles = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => ext.Contains(Path.GetExtension(s)));

                    foreach (string file in myFiles)
                    {
                        var    currentChildDir = folder + "\\" + Path.GetDirectoryName(file.Replace(path, ""));
                        string filename        = Path.GetFileName(file);
                        string dest            = currentChildDir + "\\_" + filename + "_\\";
                        string dir             = Path.GetDirectoryName(dest);
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        try
                        {
                            SPR spr = new SPR(file);

                            if (spr != null)
                            {
                                spr.Unpack(dest);
                            }

                            if (bVerbose)
                            {
                                Console.WriteLine("Unpacked {0} to {1}", file, dest);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Oops! {0} failed!\nException: {1}", path, e.ToString());

                            ++iNumFailedOperations;
                        }
                        ++iNumOperations;
                    }
                }
                else
                {
                    Console.WriteLine("{0} does not exist. Cancelling operation.", path);
                    return;
                }
            }
            else
            {
                try
                {
                    SPR spr = new SPR(path);

                    if (spr != null)
                    {
                        spr.Unpack(folder);
                    }

                    if (bVerbose)
                    {
                        Console.WriteLine("Converted {0} to {1}", path, folder);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Oops! {0} failed!\nException: {1}", path, e.ToString());

                    ++iNumFailedOperations;
                }
                ++iNumOperations;
            }

            return;
        }
Exemplo n.º 30
0
        public override void PositionChange(VMContext context, bool noEntryPoint)
        {
            if (GhostImage)
            {
                return;
            }

            var room = context.GetObjectRoom(this);

            SetRoom(room);
            for (int i = 0; i < Contained.Length; i++)
            {
                if (Contained[i] != null)
                {
                    context.UnregisterObjectPos(Contained[i]);
                    Contained[i].Position = Position;
                    Contained[i].PositionChange(context, noEntryPoint); //recursive
                }
            }

            context.RegisterObjectPos(this);

            if (Container != null)
            {
                return;
            }
            if (Position == LotTilePos.OUT_OF_WORLD)
            {
                return;
            }

            var arch = context.Architecture;

            if (((VMEntityFlags2)ObjectData[(int)VMStackObjectVariable.FlagField2] & (VMEntityFlags2.ArchitectualWindow | VMEntityFlags2.ArchitectualDoor)) > 0)
            {     //if wall or door, attempt to place style on wall
                if (Object.OBJ.WallStyle > 21 && Object.OBJ.WallStyle < 256)
                { //first thing's first, is the style between 22-255 inclusive? If it is, then the style is stored in the object. Need to load its sprites and change the id for the objd.
                    var id   = Object.OBJ.WallStyleSpriteID;
                    var sprs = new SPR[6];
                    for (int i = 0; i < 6; i++)
                    {
                        sprs[i] = Object.Resource.Get <SPR>((ushort)(id + i));
                        if (sprs[i] != null)
                        {
                            sprs[i].WallStyle = true;
                        }
                    }
                    var style = new WallStyle()
                    {
                        WallsUpFar      = sprs[0],
                        WallsUpMedium   = sprs[1],
                        WallsUpNear     = sprs[2],
                        WallsDownFar    = sprs[3],
                        WallsDownMedium = sprs[4],
                        WallsDownNear   = sprs[5]
                    };
                    Object.OBJ.WallStyle = FSO.Content.Content.Get().WorldWalls.AddDynamicWallStyle(style);
                }

                var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags];
                var dir        = DirectionToWallOff(Direction);
                if ((placeFlags & WallPlacementFlags.WallRequiredInFront) > 0)
                {
                    SetWallStyle((dir) % 4, arch, Object.OBJ.WallStyle);
                }
                if ((placeFlags & WallPlacementFlags.WallRequiredOnRight) > 0)
                {
                    SetWallStyle((dir + 1) % 4, arch, Object.OBJ.WallStyle);
                }
                if ((placeFlags & WallPlacementFlags.WallRequiredBehind) > 0)
                {
                    SetWallStyle((dir + 2) % 4, arch, Object.OBJ.WallStyle);
                }
                if ((placeFlags & WallPlacementFlags.WallRequiredOnLeft) > 0)
                {
                    SetWallStyle((dir + 3) % 4, arch, Object.OBJ.WallStyle);
                }
            }
            var exclusive = GetValue(VMStackObjectVariable.ExclusivePlacementFlags);

            SetWallUse(arch, true, ((exclusive & 2) > 0));
            if (GetValue(VMStackObjectVariable.Category) == 8)
            {
                context.Architecture.SetObjectSupported(Position.TileX, Position.TileY, Position.Level, true);
            }

            if (EntryPoints[8].ActionFunction != 0)
            {
                UpdateDynamicMultitile(context);
            }

            base.PositionChange(context, noEntryPoint);
        }
Exemplo n.º 31
0
        public override Texture2D DrawFrame(World world)
        {
            if (!Inited)
            {
                if (Sprites == null)
                {
                    Sprites = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/sprites.iff"));
                    WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
                }

                if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
                {
                    Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
                }

                if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
                {
                    BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
                }

                LastZoom = WorldZoom.Near;
                RecalculateTarget();
                Inited = true;
            }

            if (LastZoom != world.State.Zoom || Texture == null)
            {
                Invalidated = true;
                LastZoom    = world.State.Zoom;
                RecalculateTarget();
                if (Texture == null)
                {
                    return(null);
                }
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = GameFacade.Screens.SpriteBatch;

            if (DrawSkill)
            {
                ProcessSkill();
            }
            else if (Headline.Anim % 15 == 0 && Sprite != null && Sprite.Frames.Count > 3)
            {
                Invalidated = true;
            }

            if (Invalidated) //todo: logic for drawing skills less often
            {
                GD.SetRenderTarget(Texture);
                GD.Clear(Color.Transparent);
                batch.Begin();

                if (BGSprite != null)
                {
                    batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
                }

                Texture2D main   = null;
                Vector2   offset = new Vector2();
                if (Sprite != null)
                {
                    var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                    main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                    offset = new Vector2(0, 4);
                }
                else if (AlgTex != null)
                {
                    main   = AlgTex;
                    offset = new Vector2(0, -6);
                }
                offset /= ZoomToDiv[(int)LastZoom];

                if (main != null && Texture != null)
                {
                    batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
                }

                if (Headline.Operand.Crossed)
                {
                    Texture2D Cross = Sprites.Get <SPR>(0x67).Frames[ZoomFrame].GetTexture(GD);
                    batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 4), Color.White);
                }

                if (DrawSkill)
                {
                    batch.Draw(WhitePx, new Rectangle(88, 4, 71, 41), new Color(92, 92, 92));
                    var font = GameFacade.MainFont.GetNearest(14).Font;

                    Vector2 fontOrigin = font.MeasureString(SkillString) / 2;
                    batch.DrawString(font, SkillString, new Vector2(88 + 35, 15) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);

                    fontOrigin = font.MeasureString(SpeedString) / 2;
                    batch.DrawString(font, SpeedString, new Vector2(88 + 35, 34) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);
                }

                batch.End();
                GD.SetRenderTarget(null);
                Invalidated = false;
            }

            return(Texture);
        }