Inheritance: IComponentInfo
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new WeaponComponentInfo();
            comp.Weapons = node.Elements("Weapon")
                .Select(x => {
                    var w = new WeaponInfo() {
                        Name = x.GetAttribute<string>("name"),
                        EntityName = x.GetAttribute<string>("entity"),
                        Ammo = x.TryAttribute<int?>("ammo"),
                        Usage = x.TryAttribute<int?>("usage"),
                        Palette = x.TryAttribute<int?>("palette")
                    };

                    var meterNode = x.Element("Meter");
                    if (meterNode != null)
                        w.Meter = _meterReader.LoadMeter(meterNode, project.BaseDir);

                    return w;
                })
                .ToList();

            return comp;
        }
Ejemplo n.º 2
0
 private void LoadWeaponComponent(GameEntity entity, WeaponComponentInfo info)
 {
     var comp = new WeaponComponent();
     entity.AddComponent(comp);
     comp.LoadInfo(info);
 }
Ejemplo n.º 3
0
        public void LoadInfo(WeaponComponentInfo info)
        {
            foreach (var weapon in info.Weapons)
            {
                HealthMeter meter = null;
                if (weapon.Meter != null)
                    meter = HealthMeter.Create(weapon.Meter, true);

                AddWeapon(weapon.Name, weapon.EntityName, weapon.Ammo ?? -1, weapon.Usage ?? 1, meter, weapon.Palette);
            }
        }