Example #1
0
        private void LoadHealthComponent(GameEntity entity, HealthComponentInfo info)
        {
            var comp = new HealthComponent();

            entity.AddComponent(comp);
            comp.LoadInfo(info);
        }
        public void LoadInfo(HealthComponentInfo info)
        {
            maxHealth   = info.Max;
            StartHealth = info.StartValue ?? info.Max;
            flashtime   = info.FlashFrames;

            if (info.Meter != null)
            {
                meter          = HealthMeter.Create(info.Meter, true);
                meter.MaxValue = maxHealth;
                meter.IsPlayer = (Parent.Name == "Player");
            }
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new HealthComponentInfo();

            comp.Max = node.TryAttribute <float>("max", node.TryElementValue <float>("Max"));

            comp.StartValue = node.TryAttribute <float?>("startValue");

            XElement meterNode = node.Element("Meter");

            if (meterNode != null)
            {
                comp.Meter = _meterReader.LoadMeter(meterNode, project.BaseDir);
            }

            comp.FlashFrames = node.TryAttribute("flash", node.TryElementValue <int>("Flash"));

            return(comp);
        }