public void Replace(CSprite sprite)
 {
     m_file_texture = sprite.Texture;
     m_source       = sprite.Source;
     m_image        = sprite.Bitmap;
     m_file_name    = sprite.FileName;
     m_id           = sprite.Id;
     m_type         = sprite.Type;
     m_blocking     = sprite.Blocking;
 }
        public bool isEqual(CSprite against)
        {
            if (m_source == against.Source &&
                m_file == against.FileId)
            {
                return(true);
            }

            return(false);
        }
        public void CreateManagedResources()
        {
            toolStripProgressBar.Value = 0;

            m_draw_sprite = new Sprite(m_dev);

            toolStripProgressBar.Value += 10;

            for (int i = 0; i < m_max_layers; i++)
            {
                m_layer_name.Add(layerCheckBox.Items[i].ToString());
                m_layer_type.Add(2);
                m_tile.Add(new List <CSprite>());
                toolStripProgressBar.Value += 1;
            }

            Texture default_tile        = TextureLoader.FromFile(m_dev, "tile.bmp");
            Bitmap  default_tile_bitmap = new Bitmap("tile.bmp");

            toolStripProgressBar.Value += 10;

            for (int y = 0; y < m_grid_size; y++)
            {
                for (int x = 0; x < m_grid_size; x++)
                {
                    CSprite new_tile = new CSprite(m_dev, default_tile, default_tile_bitmap);
                    new_tile.Location = new Point(x, y);
                    m_base_layer.Add(new_tile);
                }
            }
            toolStripProgressBar.Value += 15;

            for (int l = 0; l < m_max_layers; l++)
            {
                for (int y = 0; y < m_grid_size; y++)
                {
                    for (int x = 0; x < m_grid_size; x++)
                    {
                        CSprite new_tile = new CSprite();
                        new_tile.Location = new Point(x, y);
                        m_tile[l].Add(new_tile);
                    }
                }
                toolStripProgressBar.Value += 5;
            }

            m_default_tile = new CSprite();

            toolStripProgressBar.Value += 5;

            Tile.PictureBox.Image = m_default_tile.Bitmap;
        }
        public void CreateManagedResources()
        {
            toolStripProgressBar.Value = 0;

            m_draw_sprite = new Sprite(m_dev);

            toolStripProgressBar.Value += 10;

            for (int i = 0; i < m_max_layers; i++)
            {
                m_layer_name.Add(layerCheckBox.Items[i].ToString());
                m_layer_type.Add(2);
                m_tile.Add(new List<CSprite>());
                toolStripProgressBar.Value += 1;
            }

            Texture default_tile = TextureLoader.FromFile(m_dev, "tile.bmp");
            Bitmap default_tile_bitmap = new Bitmap("tile.bmp");

            toolStripProgressBar.Value += 10;

            for (int y = 0; y < m_grid_size; y++)
            {
                for (int x = 0; x < m_grid_size; x++)
                {
                    CSprite new_tile = new CSprite(m_dev, default_tile, default_tile_bitmap);
                    new_tile.Location = new Point(x, y);
                    m_base_layer.Add(new_tile);
                }
            }
            toolStripProgressBar.Value += 15;

            for (int l = 0; l < m_max_layers; l++)
            {
                for (int y = 0; y < m_grid_size; y++)
                {
                    for (int x = 0; x < m_grid_size; x++)
                    {
                        CSprite new_tile = new CSprite();
                        new_tile.Location = new Point(x, y);
                        m_tile[l].Add(new_tile);
                    }
                }
                toolStripProgressBar.Value += 5;
            }

            m_default_tile = new CSprite();

            toolStripProgressBar.Value += 5;

            Tile.PictureBox.Image = m_default_tile.Bitmap;
        }
Esempio n. 5
0
        public void ReadGraphics(Device dev, List <CSprite> sprite_list, System.Windows.Forms.TabControl tab)
        {
            //The documnet reader itself
            XmlDocument doc = new XmlDocument();

            doc.Load(m_graphics_location);
            XmlElement  root  = doc.DocumentElement;
            XmlNodeList nodes = root.SelectNodes("//FileList");

            //Get the file nodes
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode file in node)
                {
                    if (file.NodeType == XmlNodeType.Element && file.Name == "file")
                    {
                        m_file_nodes.Add(file);

                        String tab_title = file.InnerText;
                        tab_title = tab_title.Substring(0, tab_title.LastIndexOf("."));

                        TabPage tp = new TabPage();
                        tp.Name = file.InnerText;
                        tp.Text = tab_title;
                        tab.TabPages.Add(tp);
                        m_button_list.Add(new CButtonContainer());
                    }
                }
            }

            //Get the sprite nodes
            nodes = root.SelectNodes("//SpriteList");
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode sprite in node)
                {
                    if (sprite.NodeType == XmlNodeType.Element && sprite.Name == "sprite")
                    {
                        m_sprite_nodes.Add(sprite);
                        foreach (XmlNode file in m_file_nodes)
                        {
                            if (file.Attributes["id"].Value == sprite.Attributes["file"].Value)
                            {
                                CSprite new_sprite    = new CSprite(dev, file, sprite);
                                bool    is_new_sprite = true;
                                foreach (CSprite sp in sprite_list)
                                {
                                    if (sp.isEqual(new_sprite))
                                    {
                                        is_new_sprite = false;
                                    }
                                }

                                if (is_new_sprite)
                                {
                                    sprite_list.Add(new_sprite);
                                    CButton new_button = new CButton(sprite_list.Count - 1, sprite_list);
                                    int     tab_id     = 0;
                                    while (tab.TabPages[file.InnerText] != tab.TabPages[tab_id])
                                    {
                                        tab_id++;
                                    }
                                    m_button_list[tab_id].Add(new_button, tab.TabPages[tab_id]);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            //Get the animation nodes
            nodes = root.SelectNodes("//AnimationList");
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode anim in node)
                {
                    if (anim.NodeType == XmlNodeType.Element && anim.Name == "animation")
                    {
                        m_animation_nodes.Add(anim);
                    }
                }
            }
        }
        public void ReadGraphics(Device dev, List<CSprite> sprite_list, System.Windows.Forms.TabControl tab)
        {
            //The documnet reader itself
            XmlDocument doc = new XmlDocument();
            doc.Load(m_graphics_location);
            XmlElement root = doc.DocumentElement;
            XmlNodeList nodes = root.SelectNodes("//FileList");

            //Get the file nodes
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode file in node)
                {
                    if (file.NodeType == XmlNodeType.Element && file.Name == "file")
                    {
                        m_file_nodes.Add(file);

                        String tab_title = file.InnerText;
                        tab_title = tab_title.Substring(0, tab_title.LastIndexOf("."));

                        TabPage tp = new TabPage();
                        tp.Name = file.InnerText;
                        tp.Text = tab_title;
                        tab.TabPages.Add(tp);
                        m_button_list.Add(new CButtonContainer());
                    }
                }
            }

            //Get the sprite nodes
            nodes = root.SelectNodes("//SpriteList");
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode sprite in node)
                {
                    if (sprite.NodeType == XmlNodeType.Element && sprite.Name == "sprite")
                    {
                        m_sprite_nodes.Add(sprite);
                        foreach( XmlNode file in m_file_nodes )
                        {
                            if (file.Attributes["id"].Value == sprite.Attributes["file"].Value)
                            {
                                CSprite new_sprite = new CSprite(dev, file, sprite);
                                bool is_new_sprite = true;
                                foreach (CSprite sp in sprite_list)
                                    if (sp.isEqual(new_sprite)) is_new_sprite = false;

                                if (is_new_sprite)
                                {
                                    sprite_list.Add(new_sprite);
                                    CButton new_button = new CButton(sprite_list.Count - 1, sprite_list);
                                    int tab_id = 0;
                                    while (tab.TabPages[file.InnerText] != tab.TabPages[tab_id])
                                        tab_id++;
                                    m_button_list[tab_id].Add(new_button, tab.TabPages[tab_id]);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            //Get the animation nodes
            nodes = root.SelectNodes("//AnimationList");
            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode anim in node)
                {
                    if (anim.NodeType == XmlNodeType.Element && anim.Name == "animation")
                    {
                        m_animation_nodes.Add(anim);
                    }
                }
            }
        }
 public void Replace(CSprite sprite)
 {
     m_file_texture = sprite.Texture;
     m_source = sprite.Source;
     m_image = sprite.Bitmap;
     m_file_name = sprite.FileName;
     m_id = sprite.Id;
     m_type = sprite.Type;
     m_blocking = sprite.Blocking;
 }
        public bool isEqual(CSprite against)
        {
            if (m_source == against.Source &&
                m_file == against.FileId)
                return true;

            return false;
        }