Ejemplo n.º 1
0
        public ConditionalSprite(XElement element, ISerializableEntity target, string path = "", string file = "", bool lazyLoad = false)
        {
            Target = target;
            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "conditional":
                    foreach (XAttribute attribute in subElement.Attributes())
                    {
                        if (PropertyConditional.IsValid(attribute))
                        {
                            conditionals.Add(new PropertyConditional(attribute));
                        }
                    }
                    break;

                case "sprite":
                    Sprite = new Sprite(subElement, path, file, lazyLoad: lazyLoad);
                    break;

                case "deformablesprite":
                    DeformableSprite = new DeformableSprite(subElement, filePath: path, lazyLoad: lazyLoad);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public DecorativeSprite(XElement element, string path = "", string file = "", bool lazyLoad = false)
        {
            Sprite = new Sprite(element, path, file, lazyLoad: lazyLoad);
            SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
            // load property conditionals
            foreach (XElement subElement in element.Elements())
            {
                //choose which list the new conditional should be placed to
                List <PropertyConditional> conditionalList = null;
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "conditional":
                case "isactiveconditional":
                    conditionalList = IsActiveConditionals;
                    break;

                case "animationconditional":
                    conditionalList = AnimationConditionals;
                    break;

                default:
                    continue;
                }
                foreach (XAttribute attribute in subElement.Attributes())
                {
                    if (PropertyConditional.IsValid(attribute))
                    {
                        conditionalList.Add(new PropertyConditional(attribute));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public ConditionalSprite(XElement element, ISerializableEntity target, string file = "", bool lazyLoad = false)
        {
            Target    = target;
            Exclusive = element.GetAttributeBool("exclusive", Exclusive);
            string comparison = element.GetAttributeString("comparison", null);

            if (comparison != null)
            {
                Enum.TryParse(comparison, ignoreCase: true, out Comparison);
            }
            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "conditional":
                    foreach (XAttribute attribute in subElement.Attributes())
                    {
                        if (PropertyConditional.IsValid(attribute))
                        {
                            conditionals.Add(new PropertyConditional(attribute));
                        }
                    }
                    break;

                case "sprite":
                    Sprite = new Sprite(subElement, file: file, lazyLoad: lazyLoad);
                    break;

                case "deformablesprite":
                    DeformableSprite = new DeformableSprite(subElement, filePath: file, lazyLoad: lazyLoad);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public Attack(XElement element, string parentDebugName)
        {
            Deserialize(element);

            if (element.Attribute("damage") != null ||
                element.Attribute("bluntdamage") != null ||
                element.Attribute("burndamage") != null ||
                element.Attribute("bleedingdamage") != null)
            {
                DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Define damage as afflictions instead of using the damage attribute (e.g. <Affliction identifier=\"internaldamage\" strength=\"10\" />).");
            }

            InitProjSpecific(element);

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "statuseffect":
                    statusEffects.Add(StatusEffect.Load(subElement, parentDebugName));
                    break;

                case "affliction":
                    AfflictionPrefab afflictionPrefab;
                    if (subElement.Attribute("name") != null)
                    {
                        DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - define afflictions using identifiers instead of names.");
                        string afflictionName = subElement.GetAttributeString("name", "").ToLowerInvariant();
                        afflictionPrefab = AfflictionPrefab.List.FirstOrDefault(ap => ap.Name.Equals(afflictionName, System.StringComparison.OrdinalIgnoreCase));
                        if (afflictionPrefab == null)
                        {
                            DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionName + "\" not found.");
                            continue;
                        }
                    }
                    else
                    {
                        string afflictionIdentifier = subElement.GetAttributeString("identifier", "").ToLowerInvariant();
                        afflictionPrefab = AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier.Equals(afflictionIdentifier, System.StringComparison.OrdinalIgnoreCase));
                        if (afflictionPrefab == null)
                        {
                            DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionIdentifier + "\" not found.");
                            continue;
                        }
                    }
                    break;

                case "conditional":
                    foreach (XAttribute attribute in subElement.Attributes())
                    {
                        if (PropertyConditional.IsValid(attribute))
                        {
                            Conditionals.Add(new PropertyConditional(attribute));
                        }
                    }
                    break;
                }
            }
        }