Beispiel #1
0
        public override void LoadContent(ContentManager content)
        {
            // Load the coin animation.
            DrawableSet.LoadDrawableSetXml(this.Drawables, "Animations/Misc/coin.anim", content);

            CoinSound = content.Load <SoundEffect>("Sounds/Coins/coin1");
        }
        public static void LoadRepositoryXml(string filePath, ContentManager content)
        {
            XmlDocument document = new XmlDocument();

            document.Load(filePath);

            foreach (XmlNode itemNode in document.SelectNodes("ItemRepository/Item"))
            {
                Item item = new Item();
                item.Name = XmlExtensions.GetAttributeValue(itemNode, "Name", null, true);

                item.FriendlyName = itemNode.SelectSingleNode("FriendlyName").InnerText;
                item.Description  = itemNode.SelectSingleNode("Description").InnerText;
                item.Weight       = XmlExtensions.GetAttributeValue <float>(itemNode, "Weight", 0);
                item.ItemType     = (ItemType)Enum.Parse(typeof(ItemType), XmlExtensions.GetAttributeValue(itemNode, "ItemType", null, true));

                foreach (XmlNode drawableSetNode in itemNode.SelectNodes("Drawables/Drawable"))
                {
                    string src = XmlExtensions.GetAttributeValue(drawableSetNode, "src");
                    DrawableSet.LoadDrawableSetXml(item.Drawables, src, content);
                }

                GameItems.Add(item.Name, item);
            }
        }
Beispiel #3
0
        public void Draw()
        {
            DrawableSet drawSet = new DrawableSet();

            foreach (var state in TraverseDepthFirst())
            {
                drawSet.UnionWith(state.Drawables);
            }
            drawSet.Draw();
        }
Beispiel #4
0
        public override void LoadContent(ContentManager content)
        {
            double startTimeMS = randomGenerator.NextDouble() * 4000;

            DrawableSet.LoadDrawableSetXml(
                Drawables,
                "Animations/Monsters/bat.anim",
                content, startTimeMS
                );

            CurrentDrawableState = "Left";
        }
        //see Triangle2DDrawTest for a general tutorial of the resource loading pattern
        public override void OnLoad(GameState state)
        {
            base.OnLoad(state);
            var tex = Texture.Allocate();
            tex.LoadImageFile("assets/sprite-example.png");

            var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, VertexBuffer.Allocate());
            //TODO: test depth sorting
            loader.AddSprite(
                tex,
                new Vector2(0, 0),             //sprite position (top-left corner)
                new Rectangle(0, 0, 48, 21)    //source rectangle in sprite sheet
            );

            sprites = new DrawableSet(loader.Load());
        }
Beispiel #6
0
        //see Triangle2DDrawTest for a general tutorial of the resource loading pattern
        public override void OnLoad(GameState state)
        {
            base.OnLoad(state);
            var tex = Texture.Allocate();

            tex.LoadImageFile("assets/sprite-example.png");

            var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, VertexBuffer.Allocate());

            //TODO: test depth sorting
            loader.AddSprite(
                tex,
                new Vector2(0, 0),             //sprite position (top-left corner)
                new Rectangle(0, 0, 48, 21)    //source rectangle in sprite sheet
                );

            sprites = new DrawableSet(loader.Load());
        }
Beispiel #7
0
        public override void LoadContent(ContentManager content)
        {
            // Load the animation
            DrawableSet.LoadDrawableSetXml(Drawables, ANIMATION, content);

            foreach (GameDrawableInstance instance in Drawables.GetByGroup("Body"))
            {
                if (instance.Drawable is Animation)
                {
                    Animation anim = (Animation)instance.Drawable;
                    //anim.onAnimationFinished += new Animation.AnimationFinishedEventHandler(anim_onAnimationFinished);
                }
            }


            CurrentDrawableState = "Idle_" + Direction;

            base.LoadContent(content);
        }
Beispiel #8
0
 public Item()
 {
     Drawables = new DrawableSet();
 }
Beispiel #9
0
        public override void LoadContent(ContentManager content)
        {
            DrawableSet.LoadDrawableSetXml(Drawables, BaseRace, content);

            CurrentDrawableState = "Idle_Left";
        }
Beispiel #10
0
 public override void LoadContent(ContentManager content)
 {
     DrawableSet.LoadDrawableSetXml(Drawables, "Animations/Misc/chests.anim", content);
     CurrentDrawableState = "Closed";
 }