Exemple #1
0
    /// <summary>
    /// Submit changes you've made to the dungeons' to the ROM in memory.
    ///
    /// Note: Sprite writing NOT done.
    /// </summary>
    public void writeToRom()
    {
        SortedList <ushort, List <i_torch> >  l_torch  = new SortedList <ushort, List <i_torch> >();
        SortedList <ushort, List <i_block> >  l_block  = new SortedList <ushort, List <i_block> >();
        SortedList <ushort, List <i_sprite> > l_sprite = new SortedList <ushort, List <i_sprite> >();

        ushort roomNo = 0;

        foreach (List <dungeon_object> l in master_list)
        {
            foreach (dungeon_object o in l)
            {
                switch (o.objectTypeIdentifier)
                {
                case (int)(objectType.torch):
                    if (!l_torch.ContainsKey(roomNo))
                    {
                        l_torch.Add(roomNo, new List <i_torch>());
                    }
                    i_torch t = new i_torch(o.rawX, o.rawY, Convert.ToBoolean(o.BG_number));
                    l_torch[roomNo].Add(t);
                    break;

                case (int)(objectType.block):
                    if (!l_block.ContainsKey(roomNo))
                    {
                        l_block.Add(roomNo, new List <i_block>());
                    }
                    i_block b = new i_block(roomNo, o.rawX, o.rawY);
                    l_block[roomNo].Add(b);
                    break;

                case (int)(objectType.chest):
                    throw new NotImplementedException();

                case (int)(objectType.sprite):
                    if (!l_sprite.ContainsKey(roomNo))
                    {
                        l_sprite.Add(roomNo, new List <i_sprite>());
                    }
                    i_sprite s = new i_sprite(true, (byte)o.spriteID, o.rawX, o.rawY, Convert.ToBoolean(o.BG_number));
                    l_sprite[roomNo].Add(s);
                    break;
                }
            }
            roomNo++;
        }

        dung.block.writeAllBlocks(l_block);
        dung.torches.writeAllTorches(l_torch);
        dung.sprite.writeAllSprites(l_sprite);
    }
Exemple #2
0
    public SortedList <ushort, List <i_sprite> > readAllSprites()
    {
        SortedList <ushort, List <i_sprite> > sprites = new SortedList <ushort, List <i_sprite> >();

        for (ushort i = 0; i < roomPointers.Length; i++)
        {
            sprites.Add(i, new List <i_sprite>());
            List <byte> b = ROM.ReadWithDelim(roomPointers[i], sprite_delim);

            byte spriteSort = b[0];
            b.RemoveAt(0);

            while (b.Count >= i_sprite.bytesPerEntry)
            {
                i_sprite s = new i_sprite(spriteSort, b[0], b[1], b[2]);
                sprites[i].Add(s);

                b.RemoveAt(0);
                b.RemoveAt(0);
                b.RemoveAt(0);
            }
        }
        return(sprites);
    }
Exemple #3
0
 internal bool Equals(i_sprite s)
 {
     return(isLayer2 == s.isLayer2 && rawX == s.rawX && rawY == s.rawY && spriteId == s.spriteId);
 }