示例#1
0
 /// <summary>Создаёт новый экземпляр класса <see cref="Magic"/>.</summary>
 /// <param name="node">Xml-запись</param>
 /// <param name="game">Ссылка на игру.</param>
 public Magic(XmlNode node, SourceryGame game)
 {
     _Node = node;
       LoadAttributes(node);
       _Executed = false;
       LoadSprites(game);
       _ShowText = false;
       _Movement = new Movement(new Rectangle(0,0,0,0),null,_Speed,_Sprite,_Animation,true);
 }
示例#2
0
        /// <summary>Загружает параметры игрока из XML-файла</summary>
        /// <param name="node">Запись об игроке.</param>
        /// <param name="game">Ссылка на игру.</param>
        public void LoadPlayerParameters(XmlNode node, SourceryGame game)
        {
            //Читаем параметры из *.lvl
              string playerName = node.SelectSingleNode("Name").InnerText;
              string fileName = node.SelectSingleNode("File").InnerText;

              int x = Convert.ToInt32(node.SelectSingleNode("x").InnerText);
              int y = Convert.ToInt32(node.SelectSingleNode("y").InnerText);
              int startAnimation = Convert.ToInt32(node.SelectSingleNode("StartAnimation").InnerText);
              var type = node.SelectSingleNode("Type").InnerText;
              PlayerType playerType = (PlayerType)Enum.Parse(typeof(PlayerType), type);
              type = node.SelectSingleNode("Color").InnerText;
              Colors color = (Colors)Enum.Parse(typeof(Colors), type);

              //Читаем параметры героя
              XmlDocument doc = new XmlDocument();
              doc.Load("data/players/" + fileName);
              string textureName = doc.SelectSingleNode("Player/Texture").InnerText;
              int width = int.Parse(doc.SelectSingleNode("Player/width").InnerText);
              int height = int.Parse(doc.SelectSingleNode("Player/height").InnerText);
              int speed = int.Parse(doc.SelectSingleNode("Player/speed").InnerText);
              _Animation = new PlayerAnimation(doc.SelectSingleNode("Player/Animation"));

              //Задаем начальные параметры
              _Tile = new AnimateSprite(game.Content.Load<Texture2D>("animation/" + textureName), 8, 24);
              _Tile.CurrentFrame = startAnimation;
              LoadColor(color);
              _CurrentState = new Rectangle(x-width/2, y-height/2, width, height);
              _Type = playerType;
              if (playerName == "")
            Name = game.PlayerName;
              else
            Name = playerName;
              foreach (Cell cell in Helper.Board)
            if (cell.Rect.Contains(x, y))
            {
              _CurrentCell = cell;
              break;
            }
              CurrentMagic = MaxMagic;
              _Movement = new Movement(_CurrentState, _CurrentCell, speed, _Tile, _Animation,false);
        }