public override bool InitOne(ContentManager content, int id)
        {
            XmlDocument _doc = new XmlDocument();
            _doc.Load(_xmlInfo);
            XmlNode _processbar = _doc.SelectSingleNode(@"//ProcessBar[@id = '" + id.ToString() + "']");

            string _animate = _processbar.SelectSingleNode(@"AnimateProcessBar").InnerText;
            string _stand = _processbar.SelectSingleNode(@"StandingProcessBar").InnerText;

            _prototype[id] = new ProcessBar();
            _prototype[id]._nsprite = 2;
            _prototype[id]._sprite = new GameSprite[_prototype[id]._nsprite];

            Texture2D _animateTex = content.Load<Texture2D>(_animate);
            _prototype[id]._sprite[0] = new GameSprite(_animateTex, 0, 0);

            Texture2D _standTex = content.Load<Texture2D>(_stand);
            _prototype[id]._sprite[1] = new GameSprite(_standTex, 0, 0);

            ((ProcessBar)_prototype[id]).XStartAnimatePro = int.Parse(_processbar.SelectSingleNode(@"StartAnimate").InnerText);
            ((ProcessBar)_prototype[id]).XEndAnimatePro = int.Parse(_processbar.SelectSingleNode(@"EndAnimate").InnerText);
            ((ProcessBar)_prototype[id]).Direction = _processbar.SelectSingleNode(@"Direction").InnerText;
            _prototype[id].X = float.Parse(_processbar.SelectSingleNode(@"X").InnerText);
            _prototype[id].Y = float.Parse(_processbar.SelectSingleNode(@"Y").InnerText);
            _prototype[id].OffSetX = _prototype[id].X;
            _prototype[id].OffSetY = _prototype[id].Y;

            _prototype[id].Width = float.Parse(_processbar.SelectSingleNode(@"Width").InnerText);
            _prototype[id].Height = float.Parse(_processbar.SelectSingleNode(@"Height").InnerText);

            _prototype[id].Rect = new Rectangle((int)_prototype[id].X, (int)_prototype[id].Y, (int)_prototype[id].Width, (int)_prototype[id].Height);

            return true;
        }
        //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);
        }
        public void GetResources(List<GameObjectManager> _resouces)
        {
            HealbarFrame = (GameFrame)_resouces[0].CreateObject(0);
            BloodPro = (ProcessBar)_resouces[1].CreateObject(0);
            ManaPro = (ProcessBar)_resouces[1].CreateObject(1);

            //Button left
            _btLeftCommand = (Button)_resouces[2].CreateObject(0);
            _btLeftCommand.Mouse_Click += new Button.OnMouseClickHandler(LeftCommandButon_Clicked);
            HealbarFrame.AddChild(_btLeftCommand);

            _btRightCommand = (Button)_resouces[2].CreateObject(1);
            _btRightCommand.Mouse_Click += new Button.OnMouseClickHandler(RightCommandButon_Clicked);
            HealbarFrame.AddChild(_btRightCommand);

            _btLefthandSkill = (Button)_resouces[2].CreateObject(14);
            _btLefthandSkill.Owner = _character.ListLeftHandSkill[0];
            _btLefthandSkill.GetNewIdleTexture(_character.ListLeftHandSkill[0].IdleIcon);
            _btLefthandSkill.GetNewClickedTexture(_character.ListLeftHandSkill[0].ClickedIcon);
            _btLefthandSkill.Mouse_Click += new Button.OnMouseClickHandler(LeftSkillButon_Clicked);
            _btLefthandSkill.Mouse_Hover += new Button.OnMouseHoverHandler(LeftSkillButon_Hover);
            _btLefthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(LeftSkillButon_Release);
            HealbarFrame.AddChild(_btLefthandSkill);

            //Button right
            _btRighthandSkill = (Button)_resouces[2].CreateObject(22);
            _btRighthandSkill.Owner = _character.ListRightHandSkill[0];
            _btRighthandSkill.GetNewIdleTexture(_character.ListRightHandSkill[0].IdleIcon);
            _btRighthandSkill.GetNewClickedTexture(_character.ListRightHandSkill[0].ClickedIcon);
            _btRighthandSkill.Mouse_Click += new Button.OnMouseClickHandler(RightSkillButon_Clicked);
            _btRighthandSkill.Mouse_Hover += new Button.OnMouseHoverHandler(RightSkillButon_Hover);
            _btRighthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(RightSkillButon_Release);
            HealbarFrame.AddChild(_btRighthandSkill);

            _coolDownRightSkill = (ProcessBar)_resouces[1].CreateObject(2);
            _healbarFrame.AddChild(_coolDownRightSkill);

            _coolDownLeftSkill = (ProcessBar)_resouces[1].CreateObject(3);
            _healbarFrame.AddChild(_coolDownLeftSkill);

            _levelProcess = (ProcessBar)_resouces[1].CreateObject(4);
            _healbarFrame.AddChild(_levelProcess);

            _btCMUpButton = (Button)_resouces[2].CreateObject(35);
            _btCMUpButton.Mouse_Click += new Button.OnMouseClickHandler(UpCommandbutton_Clicked);
            _healbarFrame.AddChild (_btCMUpButton);

            //item blood, mana, both
            _itemFrame = (GameFrame)_resouces[0].CreateObject(10);
            _itemFrame.X += _healbarFrame.X;
            _itemFrame.Y += _healbarFrame.Y;

            _btBlood = (Button)_resouces[2].CreateObject(47);
            _btBlood.Mouse_Click += new Button.OnMouseClickHandler(BloodButton_Clicked);

            _lbBlood = (Label)_resouces[3].CreateObject(16);
            _lbBlood.StringInfo = _character.HPPortion.Count.ToString();

            _itemFrame.AddChild(_btBlood);
            _itemFrame.AddChild(_lbBlood);
            //mana
            _btMana = (Button)_resouces[2].CreateObject(48);
            _btMana.Mouse_Click += new Button.OnMouseClickHandler(ManaButton_Clicked);

            _lbMana = (Label)_resouces[3].CreateObject(17);
            _lbMana.StringInfo = _character.MPPortion.Count.ToString();

            _itemFrame.AddChild(_btMana);
            _itemFrame.AddChild(_lbMana);

            //both
            _btBloodNMana = (Button)_resouces[2].CreateObject(49);
            _btBloodNMana.Mouse_Click += new Button.OnMouseClickHandler(BloodNManaButton_Clicked);

            _lbBloodNMana = (Label)_resouces[3].CreateObject(18);
            _lbBloodNMana.StringInfo = _character.RestorePortion.Count.ToString();

            _itemFrame.AddChild(_btBloodNMana);
            _itemFrame.AddChild(_lbBloodNMana);

            _rect = new Rectangle((int)_healbarFrame.X, (int)_healbarFrame.Y, (int)_healbarFrame.Width, (int)_healbarFrame.Height);
        }
Exemplo n.º 4
0
        public void GetResources(List <GameObjectManager> _resouces)
        {
            HealbarFrame = (GameFrame)_resouces[0].CreateObject(0);
            BloodPro     = (ProcessBar)_resouces[1].CreateObject(0);
            ManaPro      = (ProcessBar)_resouces[1].CreateObject(1);

            //Button left
            _btLeftCommand              = (Button)_resouces[2].CreateObject(0);
            _btLeftCommand.Mouse_Click += new Button.OnMouseClickHandler(LeftCommandButon_Clicked);
            HealbarFrame.AddChild(_btLeftCommand);

            _btRightCommand              = (Button)_resouces[2].CreateObject(1);
            _btRightCommand.Mouse_Click += new Button.OnMouseClickHandler(RightCommandButon_Clicked);
            HealbarFrame.AddChild(_btRightCommand);

            _btLefthandSkill       = (Button)_resouces[2].CreateObject(14);
            _btLefthandSkill.Owner = _character.ListLeftHandSkill[0];
            _btLefthandSkill.GetNewIdleTexture(_character.ListLeftHandSkill[0].IdleIcon);
            _btLefthandSkill.GetNewClickedTexture(_character.ListLeftHandSkill[0].ClickedIcon);
            _btLefthandSkill.Mouse_Click    += new Button.OnMouseClickHandler(LeftSkillButon_Clicked);
            _btLefthandSkill.Mouse_Hover    += new Button.OnMouseHoverHandler(LeftSkillButon_Hover);
            _btLefthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(LeftSkillButon_Release);
            HealbarFrame.AddChild(_btLefthandSkill);

            //Button right
            _btRighthandSkill       = (Button)_resouces[2].CreateObject(22);
            _btRighthandSkill.Owner = _character.ListRightHandSkill[0];
            _btRighthandSkill.GetNewIdleTexture(_character.ListRightHandSkill[0].IdleIcon);
            _btRighthandSkill.GetNewClickedTexture(_character.ListRightHandSkill[0].ClickedIcon);
            _btRighthandSkill.Mouse_Click    += new Button.OnMouseClickHandler(RightSkillButon_Clicked);
            _btRighthandSkill.Mouse_Hover    += new Button.OnMouseHoverHandler(RightSkillButon_Hover);
            _btRighthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(RightSkillButon_Release);
            HealbarFrame.AddChild(_btRighthandSkill);

            _coolDownRightSkill = (ProcessBar)_resouces[1].CreateObject(2);
            _healbarFrame.AddChild(_coolDownRightSkill);

            _coolDownLeftSkill = (ProcessBar)_resouces[1].CreateObject(3);
            _healbarFrame.AddChild(_coolDownLeftSkill);

            _levelProcess = (ProcessBar)_resouces[1].CreateObject(4);
            _healbarFrame.AddChild(_levelProcess);

            _btCMUpButton              = (Button)_resouces[2].CreateObject(35);
            _btCMUpButton.Mouse_Click += new Button.OnMouseClickHandler(UpCommandbutton_Clicked);
            _healbarFrame.AddChild(_btCMUpButton);

            //item blood, mana, both
            _itemFrame    = (GameFrame)_resouces[0].CreateObject(10);
            _itemFrame.X += _healbarFrame.X;
            _itemFrame.Y += _healbarFrame.Y;

            _btBlood              = (Button)_resouces[2].CreateObject(47);
            _btBlood.Mouse_Click += new Button.OnMouseClickHandler(BloodButton_Clicked);

            _lbBlood            = (Label)_resouces[3].CreateObject(16);
            _lbBlood.StringInfo = _character.HPPortion.Count.ToString();

            _itemFrame.AddChild(_btBlood);
            _itemFrame.AddChild(_lbBlood);
            //mana
            _btMana              = (Button)_resouces[2].CreateObject(48);
            _btMana.Mouse_Click += new Button.OnMouseClickHandler(ManaButton_Clicked);

            _lbMana            = (Label)_resouces[3].CreateObject(17);
            _lbMana.StringInfo = _character.MPPortion.Count.ToString();

            _itemFrame.AddChild(_btMana);
            _itemFrame.AddChild(_lbMana);

            //both
            _btBloodNMana              = (Button)_resouces[2].CreateObject(49);
            _btBloodNMana.Mouse_Click += new Button.OnMouseClickHandler(BloodNManaButton_Clicked);

            _lbBloodNMana            = (Label)_resouces[3].CreateObject(18);
            _lbBloodNMana.StringInfo = _character.RestorePortion.Count.ToString();

            _itemFrame.AddChild(_btBloodNMana);
            _itemFrame.AddChild(_lbBloodNMana);


            _rect = new Rectangle((int)_healbarFrame.X, (int)_healbarFrame.Y, (int)_healbarFrame.Width, (int)_healbarFrame.Height);
        }