예제 #1
0
파일: Game1.cs 프로젝트: Natman64/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);
        }
예제 #2
0
파일: Weapon.cs 프로젝트: Natman64/JamLib
        public static Weapon FromFile(string filename, string group)
        {
            string name;
            double amount;
            int min;
            int max;

            using (StreamReader sr = new StreamReader(filename))
            {
                if (sr.ReadLine() != "[Weapon]")
                    throw new ArgumentException("Not a Weapon file");

                sr.ReadLine();
                name = sr.ReadLine();
                sr.ReadLine();
                amount = double.Parse(sr.ReadLine());
                sr.ReadLine();
                min = int.Parse(sr.ReadLine());
                sr.ReadLine();
                max = int.Parse(sr.ReadLine());

                sr.Close();
            }

            Weapon w = new Weapon(name, group, amount, min, max);
            return w;
        }
예제 #3
0
파일: Entity.cs 프로젝트: Natman64/JamLib
        public Entity(string tag, string group, TileLayer layer, Point position, EntityInfo info, ContentManager content)
        {
            if (!init)
            {
                initializeBehaviors();
                init = true;
            }

            Tag = tag;
            Group = group;

            Health = new StatBar(info.health);

            this.speed = info.speed;
            this.skill = info.skill;

            this.inventory = new Inventory(5, this);

            this.layer = layer;
            this.position = position;

            texture = content.Load<Texture2D>("Sprites/" + info.texture);
            iconTexture = content.Load<Texture2D>("UI/" + info.icon);
            healthbarTexture = content.Load<Texture2D>("UI/" + info.healthbar);

            animation = new FrameAnimation(2, 32, 32, 0, 0);
            animation.FramesPerSecond = 2;

            foreach (string item in info.items)
            {
                Item i = Item.FromFile(item, Group);
                inventory.Add(i);
                if (i is Weapon)
                    weapon = i as Weapon;
            }

            if (behaviors.ContainsKey(info.behavior))
                Behavior += behaviors[info.behavior];
        }