Exemplo n.º 1
0
 public void AddPrefab(string viewId, GameObject prefab)
 {
     if (Contains(viewId))
     {
         throw new Exception("ViewManager: already contains such key");
     }
     ResourceManager.AddAsset(viewId, prefab);
 }
Exemplo n.º 2
0
        /// <summary>
        /// save the asset to the manager
        /// </summary>
        public override void Save()
        {
            StringBuilder sb = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(sb))
                Animation.Save(writer);

            string      xml = sb.ToString();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            ResourceManager.AddAsset <Animation>(Animation.Name, doc.DocumentElement);
        }
Exemplo n.º 3
0
        /// <summary>
        /// save the asset to the manager
        /// </summary>
        public override void Save()
        {
            StringBuilder sb = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(sb))
                StringTable.Save(writer);

            string      xml = sb.ToString();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            ResourceManager.AddAsset <ArcEngine.Asset.StringTable>(StringTable.Name, doc.DocumentElement);
        }
Exemplo n.º 4
0
        /// <summary>
        /// save the asset to the manager
        /// </summary>
        public override void Save()
        {
            Model.Source = ScriptTxt.Text;

            StringBuilder sb = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(sb))
                Model.Save(writer);

            string      xml = sb.ToString();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            ResourceManager.AddAsset <ScriptModel>(Model.Name, doc.DocumentElement);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Process GIF to animation
        /// </summary>
        void Process()
        {
            if (Image == null)
            {
                MessageBox.Show("Load an image first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (string.IsNullOrEmpty(TileSetNameBox.Text))
            {
                MessageBox.Show("Invalid TileSet name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (string.IsNullOrEmpty(AnimationNameBox.Text))
            {
                MessageBox.Show("Invalid Animation name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (string.IsNullOrEmpty(TextureNameBox.Text))
            {
                MessageBox.Show("Invalid Texture name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            // The texture
            Texture2D texture = new Texture2D(ComputeTextureSize());

            // The tileset
            TileSet tileset = new TileSet();

            tileset.Name        = TileSetNameBox.Text;
            tileset.TextureName = TextureNameBox.Text + ".png";
            tileset.Texture     = texture;

            // The animation
            Animation animation = new Animation();

            animation.Name = AnimationNameBox.Text;
            animation.SetTileSet(TileSetNameBox.Text);
            SetFrame(0);
            //Bitmap bm = new Bitmap(Image);
            animation.FrameRate = TimeSpan.FromMilliseconds(BitConverter.ToInt32(Image.GetPropertyItem(20736).Value, 0) * 10);
            if (animation.FrameRate < TimeSpan.FromMilliseconds(100))
            {
                animation.FrameRate = TimeSpan.FromMilliseconds(100);
            }
            if (BitConverter.ToInt16(Image.GetPropertyItem(20737).Value, 0) != 1)
            {
                animation.Type = AnimationType.Loop;
            }



            Point location = Point.Empty;
            int   id       = 0;

            for (int f = int.Parse(FirstFrameBox.Value.ToString()); f < int.Parse(LastFrameBox.Value.ToString()); f++)
            {
                // Select the frame
                SetFrame(f);
                Bitmap bm = new Bitmap(Image);

                if (location.X + bm.Width > texture.Size.Width)
                {
                    location.X  = 0;
                    location.Y += bm.Height;
                }

                //
                // Blit the frame to the texture
                texture.SetData(bm, location);

                // Add in the tileset
                tileset.AddTile(id, new Rectangle(location, bm.Size));

                // Move to the next free location
                location.Offset(bm.Width, 0);

                animation.AddFrame(id);

                // Next id
                id++;
            }



            //
            // Save assets to the manager
            //texture.SaveToBank("", TextureNameBox.Text + ".png");
            ResourceManager.AddAsset <TileSet>(TileSetNameBox.Text, tileset);
            ResourceManager.AddAsset <Animation>(AnimationNameBox.Text, animation);

            texture.Dispose();

            Close();
        }
Exemplo n.º 6
0
 /// <summary>
 /// Saves the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <Hero>(HeroBox.Hero.Name, ResourceManager.ConvertAsset(HeroBox.Hero));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Save the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <DecorationSet>(DecorationSet.Name, ResourceManager.ConvertAsset(DecorationSet));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Saves the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <Item>(Item.Name, ResourceManager.ConvertAsset(Item));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Saves the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <Spell>(Spell.Name, ResourceManager.ConvertAsset(Spell));
 }
Exemplo n.º 10
0
 /// <summary>
 /// save the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <Monster>(Monster.Name, ResourceManager.ConvertAsset(Monster));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Save the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <TileSet>(TileSet.Name, ResourceManager.ConvertAsset(TileSet));
 }
Exemplo n.º 12
0
 /// <summary>
 /// save the asset to the manager
 /// </summary>
 public override void Save()
 {
     ResourceManager.AddAsset <Dungeon>(Dungeon.Name, ResourceManager.ConvertAsset(Dungeon));
 }