Example #1
0
        public override void Update(GameTime gameTime)
        {
            _healbarFrame.Update(gameTime);

            //Update của left button skill
            Skill _currentLeftSkill = (Skill)_btLefthandSkill.Owner;

            if ((_currentLeftSkill.ListLevel[_currentLeftSkill.Level].ListSkillInfo[0].Mp * -1) <= _character.Mp)
            {
                _btLefthandSkill.ColorToDraw = Color.White;
            }
            else
            {
                _btLefthandSkill.ColorToDraw = new Color(0, 130, 185);
            }

            if (_currentLeftSkill.CheckCoolDown != 0)
            {
                float _cooldownLeftRate = (float)_currentLeftSkill.CheckCoolDown / (float)_currentLeftSkill.CoolDownTime;
                _coolDownLeftSkill.UpdateDrawRect(_cooldownLeftRate);
            }
            else
            {
                _coolDownLeftSkill.UpdateDrawRect(0);
            }

            //Update cua tight button skill
            Skill _currentRightSkill = (Skill)_btRighthandSkill.Owner;

            if (_currentRightSkill != null)
            {
                if ((_currentRightSkill.ListLevel[_currentRightSkill.Level].ListSkillInfo[0].Mp * -1) <= _character.Mp)
                {
                    _btRighthandSkill.ColorToDraw = Color.White;
                }
                else
                {
                    _btRighthandSkill.ColorToDraw = new Color(0, 130, 185);
                }

                if (_currentRightSkill.CheckCoolDown != 0)
                {
                    float _cooldownRightRate = (float)_currentRightSkill.CheckCoolDown / (float)_currentRightSkill.CoolDownTime;
                    _coolDownRightSkill.UpdateDrawRect(_cooldownRightRate);
                }
                else
                {
                    _coolDownRightSkill.UpdateDrawRect(0);
                }
            }

            //Update của ống máu
            float _bloodRate = (float)_character.Hp / (float)_character.MaxHp;

            _bloodPro.UpdateDrawRect(_bloodRate);
            //update của ống mana
            float _manaRate = (float)_character.Mp / (float)_character.MaxMp;

            _manaPro.UpdateDrawRect(_manaRate);
            //update ống level
            float _levelRate = (float)_character.CurrentEXP / (float)_character.NextLevelEXP;

            _levelProcess.UpdateDrawRect(_levelRate);
            //Update so luong item
            _itemFrame.Update(gameTime); //trong cai update này co san~ cai update cua nhung button
            _lbBlood.StringInfo      = _character.HPPortion.Count.ToString();
            _lbMana.StringInfo       = _character.MPPortion.Count.ToString();
            _lbBloodNMana.StringInfo = _character.RestorePortion.Count.ToString();
            //update main rect
            _rect = new Rectangle((int)_healbarFrame.X, (int)_healbarFrame.Y, (int)_healbarFrame.Width, (int)_healbarFrame.Height);
            if (_rect.Contains(GlobalVariables.CurrentMouseState.X, GlobalVariables.CurrentMouseState.Y))
            {
                GlobalVariables.AlreadyUseLeftMouse  = true;
                GlobalVariables.AlreadyUseRightMouse = true;
            }

            //Update chỗ này chỉ để chặn con chuột -> khá dỡ.
            _bloodPro.Update(gameTime);
            _manaPro.Update(gameTime);
        }