Пример #1
0
        public override void AddSprite(GameSprite sprite)
        {
            if (sprite != null && sprite.AnimationKeys.Contains("Activate"))
            {
                throw new NotImplementedException();
            }

            base.AddSprite(sprite);
        }
Пример #2
0
        public override void XmlDeserialize(XElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            XAttribute nameAtt = element.Attribute("name");
            if (nameAtt != null)
            {
                this.Name = nameAtt.Value;
            }

            this.MovementSpeed = ExtensionMethods.XmlDeserializeVector2(element.Element("MovementSpeed"));

            // Create GameSprites out of the Deserialze functions in GameSprite
            foreach (XElement gameSpriteEle in element.Element("Sprites").Elements("GameSprite"))
            {
                GameSprite gameSprite = new GameSprite();
                gameSprite.XmlDeserialize(gameSpriteEle);
                this.sprites.Add(gameSprite.SpriteName, gameSprite);
            }

            // ----------------------
            // Find the Body element
            XElement bodyElement = element.Element("BodyInfo");
            if (bodyElement != null)
            {
                var bodyData = XmlBodyFactory.DeserializeBody(this.World, this.Map.Height, bodyElement.Elements().ElementAt(0));
                this.Body = bodyData.Item1;
                this.bodyInfo = bodyData.Item2;
            }

            this.PathManager = new PathManager(this);
            this.PathManager.Screen = this.Screen;
            XElement pathManagerEle = element.Element("PathManager");
            if (pathManagerEle != null)
            {
                this.PathManager.XmlDeserialize(pathManagerEle);
            }

            // ----------------------------------
            // Assign the new values to the Actor
            this.Health = int.Parse(element.Attribute("health").Value, CultureInfo.CurrentCulture);
            this.Rotation = float.Parse(element.Attribute("rotation").Value, CultureInfo.CurrentCulture);
            this.IsEnabled = bool.Parse(element.Attribute("isEnabled").Value);

            this.VisibleState = (Visibility)Enum.Parse(typeof(Visibility), element.Attribute("visibleState").Value);
        }
Пример #3
0
        public virtual void AddSprite(GameSprite sprite)
        {
            if (sprite == null)
            {
                throw new ArgumentNullException("sprite");
            }

            this.Sprites.Add(sprite.SpriteName, sprite);
        }