Esempio n. 1
0
        /// <summary>Создаёт новый экземпляр класса <see cref="Movement"/>.</summary>
        /// <param name="board">Вся доска.</param>
        /// <param name="state">Прямоугольник отрисовки.</param>
        /// <param name="current">Текущая ячейка.</param>
        /// <param name="speed">Скорость перемещения.</param>
        /// <param name="sprite">Анимация объекта.</param>
        /// <param name="animation">Параметры анимации объекта.</param>
        public Movement(Rectangle state, Cell current, int speed, AnimateSprite sprite, PlayerAnimation animation, bool IsMagic)
        {
            IsEnd         = true;
            _CurrentState = state;
            _Current      = current;
            _Speed        = speed;
            _Tile         = sprite;
            _Animation    = animation;
            _Field        = Helper.Field;
            _Field        = new PathNode[Helper.Board.GetLength(0), Helper.Board.GetLength(1)];
            bool pass;

            for (int i = 0; i < Helper.Board.GetLength(0); i++)
            {
                for (int j = 0; j < Helper.Board.GetLength(1); j++)
                {
                    if (IsMagic)
                    {
                        pass = false;
                    }
                    else
                    {
                        pass = (Helper.Board[i, j].Type != CellType.Passable);
                    }
                    _Field[i, j] = new PathNode()
                    {
                        IsWall = pass,
                        X      = Helper.Board[i, j].Rect.X,
                        Y      = Helper.Board[i, j].Rect.Y,
                        i      = i,
                        j      = j,
                    };
                }
            }
        }
Esempio n. 2
0
        /// <summary>Загружаем атрибуты магии</summary>
        private void LoadAttributes(XmlNode node)
        {
            Name       = node.SelectSingleNode("Name").InnerText;
            _Animation = new PlayerAnimation(node.SelectSingleNode("MovementAnimation"));
            _Width     = int.Parse(node.SelectSingleNode("width").InnerText);
            _Speed     = int.Parse(node.SelectSingleNode("MovementAnimation/speed").InnerText);
            _Height    = int.Parse(node.SelectSingleNode("height").InnerText);
            double res = Convert.ToDouble(node.SelectSingleNode("Animation").InnerText);

            _Reload   = Convert.ToInt32(node.SelectSingleNode("Reload").InnerText) * 100;
            Animation = (int)((double)res * 100);
            res       = Convert.ToDouble(node.SelectSingleNode("Delay").InnerText);
            Delay     = (int)((double)res * 100);
            Cost      = Convert.ToInt32(node.SelectSingleNode("Cost").InnerText);
            Effect    = Convert.ToInt32(node.SelectSingleNode("Effect").InnerText);
            var type = node.SelectSingleNode("Direction").InnerText;

            Direction      = (DirectionType)Enum.Parse(typeof(DirectionType), type);
            type           = node.SelectSingleNode("Type").InnerText;
            Type           = (MagicType)Enum.Parse(typeof(MagicType), type);
            Radius         = Convert.ToInt32(node.SelectSingleNode("Radius").InnerText);
            EffectRadius   = Convert.ToInt32(node.SelectSingleNode("EffectRadius").InnerText);
            type           = node.SelectSingleNode("PostEffect").InnerText;
            PostEffect     = (PostEffectType)Enum.Parse(typeof(PostEffectType), type);
            PostEffectTime = Convert.ToInt32(node.SelectSingleNode("PostEffectTime").InnerText);
            Targets        = new List <TargetType>();
            var lst = node.SelectNodes("Targets/Target");

            foreach (XmlNode current in lst)
            {
                Targets.Add((TargetType)Enum.Parse(typeof(TargetType), current.InnerText));
            }
        }
Esempio n. 3
0
 /// <summary>Создаёт новый экземпляр класса <see cref="Movement"/>.</summary>
 /// <param name="board">Вся доска.</param>
 /// <param name="state">Прямоугольник отрисовки.</param>
 /// <param name="current">Текущая ячейка.</param>
 /// <param name="speed">Скорость перемещения.</param>
 /// <param name="sprite">Анимация объекта.</param>
 /// <param name="animation">Параметры анимации объекта.</param>
 public Movement(Rectangle state, Cell current, int speed, AnimateSprite sprite, PlayerAnimation animation, bool IsMagic)
 {
     IsEnd = true;
       _CurrentState = state;
       _Current = current;
       _Speed = speed;
       _Tile = sprite;
       _Animation = animation;
       _Field = Helper.Field;
       _Field = new PathNode[Helper.Board.GetLength(0), Helper.Board.GetLength(1)];
       bool pass;
       for (int i = 0; i < Helper.Board.GetLength(0); i++)
     for (int j = 0; j < Helper.Board.GetLength(1); j++)
     {
       if (IsMagic)
     pass = false;
       else
     pass = (Helper.Board[i, j].Type != CellType.Passable);
       _Field[i, j] = new PathNode()
       {
     IsWall = pass ,
     X = Helper.Board[i, j].Rect.X,
     Y = Helper.Board[i, j].Rect.Y,
     i = i,
     j = j,
       };
     }
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>Загружаем атрибуты магии</summary>
        private void LoadAttributes(XmlNode node)
        {
            Name = node.SelectSingleNode("Name").InnerText;
              _Animation = new PlayerAnimation(node.SelectSingleNode("MovementAnimation"));
              _Width = int.Parse(node.SelectSingleNode("width").InnerText);
              _Speed = int.Parse(node.SelectSingleNode("MovementAnimation/speed").InnerText);
              _Height = int.Parse(node.SelectSingleNode("height").InnerText);
              double res = Convert.ToDouble(node.SelectSingleNode("Animation").InnerText);
              _Reload = Convert.ToInt32(node.SelectSingleNode("Reload").InnerText) * 100;
              Animation = (int)((double)res * 100);
              res = Convert.ToDouble(node.SelectSingleNode("Delay").InnerText);
              Delay = (int)((double)res * 100);
              Cost = Convert.ToInt32(node.SelectSingleNode("Cost").InnerText);
              Effect = Convert.ToInt32(node.SelectSingleNode("Effect").InnerText);
              var type = node.SelectSingleNode("Direction").InnerText;
              Direction = (DirectionType)Enum.Parse(typeof(DirectionType), type);
              type = node.SelectSingleNode("Type").InnerText;
              Type = (MagicType)Enum.Parse(typeof(MagicType), type);
              Radius = Convert.ToInt32(node.SelectSingleNode("Radius").InnerText);
              EffectRadius = Convert.ToInt32(node.SelectSingleNode("EffectRadius").InnerText);
              type = node.SelectSingleNode("PostEffect").InnerText;
              PostEffect = (PostEffectType)Enum.Parse(typeof(PostEffectType), type);
              PostEffectTime = Convert.ToInt32(node.SelectSingleNode("PostEffectTime").InnerText);
              Targets = new List<TargetType>();
              var lst = node.SelectNodes("Targets/Target");

              foreach (XmlNode current in lst)
            Targets.Add((TargetType)Enum.Parse(typeof(TargetType), current.InnerText));
        }
Esempio n. 6
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);
        }