Example #1
0
        public Entity(
            string tag, string group, string behavior,
            double health,
            int speed, int skill,
            TileLayer layer, Point position, 
            Texture2D texture, Texture2D iconTexture, Texture2D healthbarTexture)
        {
            if (!init)
            {
                initializeBehaviors();
                init = true;
            }

            Tag = tag;
            Group = group;

            Health = new StatBar(health);

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

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

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

            this.texture = texture;
            this.iconTexture = iconTexture;
            this.healthbarTexture = healthbarTexture;

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

            if (behaviors.ContainsKey(behavior))
                Behavior += behaviors[behavior];
        }
Example #2
0
        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];
        }