public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     return new Monster
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         Attack = this.Attack,
         AttackSpeed = this.AttackSpeed,
         CellToMove = this.CellToMove,
         CollisionRect = this.CollisionRect,
         CriticalRate = this.CriticalRate,
         Defense = this.Defense,
         DestPoint = this.DestPoint,
         Dir = this.Dir,
         Height = this.Height,
         Hp = this.Hp,
         IsAttacking = this.IsAttacking,
         IsMouseHover = this.IsMouseHover,
         IsMoving = this.IsMoving,
         Map = this.Map,
         Mp = this.Mp,
         Range = this.Range,
         Rect = this.Rect,
         Speed = this.Speed,
         Width = this.Width,
         X = this.X,
         Y = this.Y,
         HitFrame = this.HitFrame,
         Sight = this.Sight
     };
 }
 public override void Init(ContentManager content)
 {
     _nsprite = 1;
     _sprite = new GameSprite[1];
     _sprite[0] = new GameSprite(content.Load<Texture2D>("img/misc/frog/frog"), 0, 0);
     sf = content.Load<SpriteFont>("sf");
     GlobalVariables.Sf = sf;
 }
 public override void Init(ContentManager content)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(@"Data\XML\menubg.xml");
     //_nsprite = 1;
     _nsprite = int.Parse(doc.SelectSingleNode(@"//NumOfFrames").InnerText);
     string contentname = doc.SelectSingleNode(@"//ContentName").InnerText;
     _sprite = new GameSprite[_nsprite];
     _sprite[0] = new GameSprite(content.Load<Texture2D>(contentname), int.Parse(doc.SelectSingleNode(@"//X").InnerText), int.Parse(doc.SelectSingleNode(@"//Y").InnerText));
 }
 public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     return new GameTitle
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         _x = this._x,
         _y = this._y,
         _delayTime = this._delayTime,
         _width = this._width,
         _height = this._height,
         _rect = this._rect
     };
 }
 public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     return new MapObstacle
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         Height = this.Height,
         IsMouseHover = this.IsMouseHover,
         Rect = this.Rect,
         Width = this.Width,
         X = this.X,
         Y = this.Y,
         StartObstacleX = this.StartObstacleX,
         StartObstacleY = this.StartObstacleY,
         ObstacleWidth = this.ObstacleWidth,
         ObstacleHeight = this.ObstacleHeight,
     };
 }
        public override void Init(ContentManager content)
        {
            _nsprite = 2;

            //XMLUtility xml = new XMLUtility(@".\Data\XML\gametitle.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(@".\Data\XML\gametitle.xml");

            /*int _numofframe = int.Parse(xml.GetElementValue(@"NumOfFrames"));
            string contentname = xml.GetElementValue(@"ContentName");

            _sprite = new GameSprite[_nsprite];
            Texture2D[] _textures = new Texture2D[_numofframe];

            for (int i = 0; i < _numofframe; ++i)
            {
                _textures[i] = content.Load<Texture2D>(contentname + i.ToString("00"));
            }*/
            _sprite = new GameSprite[_nsprite];
            XmlNodeList list = doc.DocumentElement.SelectNodes(@"title");

            for (int i = 0; i < list.Count; i++)
            {
                int _numofframe = int.Parse(list[i].SelectSingleNode(@"NumOfFrames").InnerText);
                string contentname = list[i].SelectSingleNode(@"ContentName").InnerText;

                Texture2D[] _textures = new Texture2D[_numofframe];

                for (int j = 0; j < _numofframe; ++j)
                {
                    _textures[j] = content.Load<Texture2D>(contentname + j.ToString("00"));
                }
                _sprite[i] = new GameSprite(_textures, 0, 0);
            }

            X = float.Parse(doc.DocumentElement.SelectSingleNode(@"X").InnerText);
            Y = float.Parse(doc.DocumentElement.SelectSingleNode(@"Y").InnerText);
            _delayTime = int.Parse((doc.DocumentElement.SelectSingleNode(@"DelayTime").InnerText));
        }
        public override void Init(ContentManager content)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(@".\Data\XML\gamecursor.xml");

                _nsprite = doc.DocumentElement.ChildNodes.Count;
                _sprite = new GameSprite[_nsprite];

                for (int i = 0; i < _nsprite; i++)
                {
                    string contentName = doc.DocumentElement.ChildNodes[i].InnerText;
                    _sprite[i] = new GameSprite(content.Load<Texture2D>(contentName),
                        0,
                        0);
                }
            }
            catch (Exception e)
            {
                return;
            }
        }
        //Lấy vào chuỗi xml định nghĩa một số thông tin riêng của Loading state (hình
        //ảnh backGround, hình ảnh processBar) mảng các objectManager cần load và kiểu
        //của Game state kế tiếp.
        public void GetDataLoading(ContentManager content, string xmlInfo, GameObjectManager[] objectManagerArray, Type type)
        {
            _nObjectManager = objectManagerArray.Length;
            _objectManagerArray = new GameObjectManager[_nObjectManager];

            for (int i = 0; i < _nObjectManager; i++)
            {
                _objectManagerArray[i] = objectManagerArray[i];
                //1 step là 1 doi tuong prototype cần load.
                _stepLengh += _objectManagerArray[i]._nprototype;
            }
            _stepLengh++; // them cai innit cho gamestate tip theo.
            _type = type; //Lưu lại type của state tip theo
            _xmlInfo = xmlInfo; //Lưu lại chuoi XML luu thong tin rieng cua loadind state

            XmlDocument _doc = new XmlDocument();
            _doc.Load(_xmlInfo);

            XmlNode _backGroundNote = _doc.DocumentElement.SelectSingleNode("BackGround");
            XmlNodeList _imageNoteList = _backGroundNote.SelectNodes("//Image");

            _nBackGroundImage = _imageNoteList.Count;
            _backGroundImage = new GameSprite[_nBackGroundImage];
            for (int i = 0; i < _nBackGroundImage; i++)
            {
                Texture2D _temp = content.Load<Texture2D>(_imageNoteList[i].SelectSingleNode("Path").InnerText);
                int _xTemp = int.Parse(_imageNoteList[i].SelectSingleNode("X").InnerText) - (int)GlobalVariables.dX;
                int _yTemp = int.Parse(_imageNoteList[i].SelectSingleNode("Y").InnerText) - (int)GlobalVariables.dY;
                _backGroundImage[i] = new GameSprite(_temp, _xTemp, _yTemp);
                _backGroundImage[i].Xoffset = 0;
                _backGroundImage[i].Yoffset = 0;
            }

            _delayTime = int.Parse(_doc.DocumentElement.SelectSingleNode("DelayTime").InnerText);
            string _processXMLInfo = _doc.DocumentElement.SelectSingleNode("ProcessBar").SelectSingleNode("ContentName").InnerText;

            //Truyền va init tại chỗ vì cái ProcessBarManager chỉ xài cho loading state
            ProcessBarManager pbm = new ProcessBarManager(_processXMLInfo);
            for (int i = 0; i < pbm._nprototype; i++)
            {
                pbm.InitOne(content, i);
            }
            _processBar = (ProcessBar)pbm.CreateObject(0);
        }
 /// <summary>
 /// Hàm tiện ích dùng để load các 8 sprite theo 8 hướng từ một XML node
 /// </summary>
 /// <param name="node"></param>
 /// <param name="content"></param>
 /// <returns></returns>
 public static GameSprite[] LoadSprites(XmlNode node, ContentManager content)
 {
     try
     {
         int xoffset = int.Parse(node.SelectSingleNode(@"XOffset").InnerText);
         int yoffset = int.Parse(node.SelectSingleNode(@"YOffset").InnerText);
         int numofframe = int.Parse(node.SelectSingleNode(@"NumOfFrames").InnerText);
         string contentName = node.SelectSingleNode("ContentName").InnerText;
         GameSprite[] sprite = new GameSprite[8];
         for (int i = 0; i < 8; ++i)
         {
             Texture2D[] textures = new Texture2D[numofframe];
             for (int j = 0; j < numofframe; ++j)
             {
                 textures[j] = content.Load<Texture2D>(contentName + i.ToString("00") + "-" + j.ToString("00"));
             }
             sprite[i] = new GameSprite(textures, 0, 0);
             sprite[i].Xoffset = xoffset;
             sprite[i].Yoffset = yoffset;
             sprite[i].NDelay = 3;
         }
         return sprite;
     }
     catch (Exception e)
     {
         return null;
     }
 }
 public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     return new PlayerCharacter
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         MinDamage = this.MinDamage,
         MaxDamage = this.MaxDamage,
         AttackSpeed = this.AttackSpeed,
         CellToMove = this.CellToMove,
         CollisionRect = this.CollisionRect,
         CriticalRate = this.CriticalRate,
         Defense = this.Defense,
         DestPoint = this.DestPoint,
         Dir = this.Dir,
         Height = this.Height,
         Hp = this.Hp,
         IsAttacking = this.IsAttacking,
         IsMouseHover = this.IsMouseHover,
         IsMoving = this.IsMoving,
         Map = this.Map,
         Mp = this.Mp,
         Range = this.Range,
         Rect = this.Rect,
         Speed = this.Speed,
         Width = this.Width,
         X = this.X,
         Xp = this.Xp,
         Y = this.Y,
         HitFrame = this.HitFrame,
         CastFrame = this.CastFrame,
         MaxHp = this.MaxHp,
         MaxMp = this.MaxMp,
         ChangeToDodge = this.ChangeToDodge,
         NextLevelEXP = this.NextLevelEXP,
         Level = this.Level,
         PassiveSkillCheck = this.PassiveSkillCheck,
     };
 }
 public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     return new Portral
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         Height = this.Height,
         IsMouseHover = this.IsMouseHover,
         Rect = this.Rect,
         Width = this.Width,
         X = this.X,
         Y = this.Y,
         Destination = this.Destination,
         DestX = this.DestX,
         DestY = this.DestY,
     };
 }
 public override VisibleGameObject Clone()
 {
     GameSprite[] _spriteTemp = new GameSprite[_nsprite];
     for (int i = 0; i < _nsprite; ++i)
         _spriteTemp[i] = _sprite[i].Clone();
     MenuFrame _newMenuFrame = new MenuFrame
     {
         _nsprite = this._nsprite,
         _sprite = _spriteTemp,
         Width = this.Width,
         Height = this.Height,
         Rect = this.Rect,
         X = this.X,
         Y = this.Y,
         _motionInfo = this._motionInfo,
         _delayTime = this._delayTime
     };
     _newMenuFrame._motionInfo.Owner = _newMenuFrame;
     return _newMenuFrame;
 }