예제 #1
0
        protected override void LoadContent()
        {
            //use base.Content to load your game content here
            //load map0 layers and backbuffer
            base.Maps[0].CollisionLayer      = CollisionLayer.FromFile("Content/layers/map1/collision.lyr");
            base.Maps[0].TacticalLayer       = TileLayer.FromFile(Content, "Content/layers/map1/tactical_map.lyr");
            base.Maps[0].TacticalLayer.Alpha = 1.0f;
            base.Maps[0].Layers.Add(TileLayer.FromFile(Content, "Content/layers/map1/map1.lyr"));
            base.Maps[0].Layers[0].Alpha = 1f;

            //player setup
            AnimatedSprite pas = new AnimatedSprite(base.Content.Load <Texture2D>("sprites/ship_ani"), null);

            pas.AddAnimation(2, 64, 64, 0, 0, 10, "Idle");
            pas.Animations["Idle"].UpdateType = UpdateType.Looped;
            pas.CurrentAnimationName          = "Idle";
            PlayerObject player = new PlayerObject
                                  (
                "Player",
                new Vector2(64, 64),
                pas,
                base.Content.Load <Texture2D>("particles/particle1"),
                base.Content.Load <Texture2D>("particles/particle_base")
                                  );

            player.CurrentMap = CurrentMap;
        }
예제 #2
0
파일: Game1.cs 프로젝트: hunter497/MonoGame
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            tileLayer = TileLayer.FromFile(Content, "Content/Layers/Layer1.layer");

            tileLayer2 = TileLayer.FromFile(Content, "Content/Layers/Layer2.layer");

            tileLayer3       = TileLayer.FromFile(Content, "Content/Layers/Layer3.layer");
            tileLayer3.Alpha = .5f;

            playerLayer = TileLayer.FromFile(Content, "Content/Layers/PlayerLayer.layer");
        }
예제 #3
0
파일: Game1.cs 프로젝트: NQNStudios/JamLib
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            ScreenHelper.Initialize(GraphicsDevice, graphics);
            ScreenHelper.Camera = new Camera(new Vector2(ScreenHelper.Viewport.Width, ScreenHelper.Viewport.Height), null);
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            layer = TileLayer.FromFile(Content, "layer.txt");

            layer.Entities.BloodTexture   = Content.Load <Texture2D>("Sprites/Blood");
            layer.Entities.HealingTexture = Content.Load <Texture2D>("Sprites/Healing");

            Texture2D cursorTexture  = Content.Load <Texture2D>("UI/Cursor_1");
            Texture2D arrowTexture   = Content.Load <Texture2D>("UI/Arrows");
            Texture2D overlayTexture = Content.Load <Texture2D>("UI/Tile Overlays");

            Texture2D rogue  = Content.Load <Texture2D>("Sprites/Rogue");
            Texture2D knight = Content.Load <Texture2D>("Sprites/Knight");
            Texture2D priest = Content.Load <Texture2D>("Sprites/Priest");

            Texture2D iconTexture      = Content.Load <Texture2D>("UI/Phase Icons");
            Texture2D healthbarTexture = Content.Load <Texture2D>("UI/Health Bar");

            SpriteFont font = Content.Load <SpriteFont>("Fonts/Font1");

            ScreenHelper.Font = font;

            cursor = new Cursor(layer, cursorTexture, arrowTexture, overlayTexture, TimeSpan.FromSeconds(0.1), new Point(20, 20), "Player");

            entity = new Entity("", "Enemy", "Healer", 20, 5, 1, layer, new Point(15, 17), priest, iconTexture, healthbarTexture);
            Weapon w = new Weapon("Healing", "Enemy", 3.0, 1, 1, true);

            entity.Items.Add(w);
            entity.EquippedWeapon = w;
            layer.Entities.Add(entity);
            entity = new Entity("", "Enemy", "Default", 20, 5, 3, layer, new Point(22, 20), knight, iconTexture, healthbarTexture);
            entity.EquippedWeapon = Item.FromFile("Sword.txt", "Enemy") as Weapon;
            layer.Entities.Add(entity);
            entity = new Entity("", "Enemy", "Default", 20, 5, 3, layer, new Point(15, 16), knight, iconTexture, healthbarTexture);
            entity.EquippedWeapon = new Weapon("Sword", "Enemy", 2.0, 1, 1);
            layer.Entities.Add(entity);

            layer.Pathfind = new Pathfinder(layer);
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter      = "Map File|*.map";
            openFileDialog1.Multiselect = false;

            //tileMap = null;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                layerDict.Clear();
                collDict.Clear();
                textureDict.Clear();
                previewDict.Clear();


                CollLayerListBox.Items.Clear();
                TilelayerListBox.Items.Clear();
                textureListBox.Items.Clear();

                tileMap.tile.Clear();
                tileMap.coll.Clear();

                tileMap.Layers.Clear();
                tileMap.colLayers.Clear();

                Logic();
                Render();

                currentLayer          = null;
                currentCollisionLayer = null;


                string filename = openFileDialog1.FileName;

                string[] textureNames;

                tileMap.OpenTileFile(filename);

                foreach (string tile in tileMap.tile) // Loop through List with foreach
                {
                    TileLayer tileLayer = TileLayer.FromFile(contentPathTextBox.Text + "/" + tile, out textureNames);

                    layerDict.Add(Path.GetFileName(contentPathTextBox.Text + "/" + tile), tileLayer);

                    tileMap.Layers.Add(tileLayer);

                    TilelayerListBox.Items.Add(Path.GetFileName(contentPathTextBox.Text + "/" + tile));

                    foreach (string textureName in textureNames)
                    {
                        if (textureDict.ContainsKey(textureName))
                        {
                            tileLayer.AddTexture(textureDict[textureName]);
                            continue;
                        }

                        string fullPath = contentPathTextBox.Text + "/" + textureName;

                        foreach (string ext in imageExtensions)
                        {
                            if (File.Exists(fullPath + ext))
                            {
                                fullPath += ext;
                                break;
                            }
                        }

                        Texture2D tex;

                        using (Stream stream = File.OpenRead(fullPath))
                        {
                            tex = Texture2D.FromStream(GraphicsDevice, stream);
                        }

                        Image image = Image.FromFile(fullPath);
                        textureDict.Add(textureName, tex);
                        previewDict.Add(textureName, image);

                        textureListBox.Items.Add(textureName);
                        tileLayer.AddTexture(tex);
                    }
                }

                foreach (string coll in tileMap.coll) // Loop through List with foreach
                {
                    CollisionLayer collLayer = CollisionLayer.FromFile(contentPathTextBox.Text + "/" + coll);
                    collDict.Add(Path.GetFileName(contentPathTextBox.Text + "/" + coll), collLayer);

                    tileMap.colLayers.Add(collLayer);
                    CollLayerListBox.Items.Add(Path.GetFileName(contentPathTextBox.Text + "/" + coll));
                }

                AdjustScrollBars();
            }
        }