public override void Update(GameTime gameTime)
        {
            if (_listPoisonDamage.Count != 0)
                IsPoisoning = true;
            else
                IsPoisoning = false;
            for (int i = 0; i < _listPoisonDamage.Count; ++i)
            {
                if (_listPoisonDamage[i].Duration % _listPoisonDamage[i].EffectMoment == 0)
                    RecentHPLost += _listPoisonDamage[i].DamageValue;
                _listPoisonDamage[i].Duration -= 1;
                if (_listPoisonDamage[i].Duration == 0)
                    _listPoisonDamage.Remove(_listPoisonDamage[i]);
            }
            if (CheckForDisplayDamage == 0)
            {
                if (RecentHPLost != 0)
                {
                    StateOwner._displayMessageLayer.MessageArray.Add(new DisplayMessageLayer.Message
                    {
                        X = this.X,
                        Y = this.Y - 2 * GlobalVariables.MapCollisionDim,
                        Owner = this,
                        DeltaY = -1,
                        LifeTime = 45,
                        MessageContent = RecentHPLost.ToString(),
                        TextColor = Color.Red,
                        MinY = (int)this.Y - 2 * GlobalVariables.MapCollisionDim - 30,
                    });
                }

                Hp += RecentHPLost;
                RecentHPLost = 0;
                CheckForDisplayDamage = 30;
            }
            else
            {
                --CheckForDisplayDamage;
            }
            if (IsDying || IsDyed)
            {
                BashTime = 0;
            }
            for (int i = 0; i < AdditionnalEffect.Count; ++i)
            {
                AdditionnalEffect[i].Update(gameTime);

                if (AdditionnalEffect[i].IsCollisionWith(this) && AdditionnalEffect[i].HitFrames.Contains(AdditionnalEffect[i]._sprite[0].Itexture2D) && AdditionnalEffect[i]._sprite[0].Check == 0 && !this.EffectedSkill.Contains(AdditionnalEffect[i].SkillOwner))
                {

                    this.BeHit(GlobalVariables.GlobalRandom.Next(AdditionnalEffect[i].MinDamage, AdditionnalEffect[i].MaxDamage));
                    if (AdditionnalEffect[i].SkillOwner != null)
                        AdditionnalEffect[i].SkillOwner.DoAdditionalEffect(this);
                    this.EffectedSkill.Add(AdditionnalEffect[i].SkillOwner);
                }
                else
                    if (AdditionnalEffect[i]._sprite[0].Itexture2D == AdditionnalEffect[i]._sprite[0].Ntexture2D - 2)
                        this.EffectedSkill.Remove(AdditionnalEffect[i].SkillOwner);

                if (AdditionnalEffect[i]._sprite[0].Itexture2D == AdditionnalEffect[i]._sprite[0].Ntexture2D - 1)
                    AdditionnalEffect.Remove(AdditionnalEffect[i]);
            }
            if (BashTime > 0)
            {
                --BashTime;
                return;
            }

            _sprite[Dir].Update(gameTime);

            if (this.Hp <= 0 && !IsDying && !IsDyed)
                IsDying = true;

            if (IsDying)
            {
                UpdateDirection(X, Y);
                if (Target != null)
                {
                    Target = null;
                }
                if (_sprite[Dir].Itexture2D == _sprite[Dir].Ntexture2D - 1)
                {
                    IsDyed = true;
                    GlobalVariables.PlayEffectSound("monster" + GlobalVariables.GlobalRandom.Next(1, 17).ToString());
                    int dropItemRate = GlobalVariables.GlobalRandom.Next(0, 100);
                    if (dropItemRate < 35)
                    {
                        int portionKindRate = GlobalVariables.GlobalRandom.Next(0, 100);
                        Portion portion = new Portion();
                        portion.PlayerOwner = StateOwner._char;
                        if (portionKindRate < 40)
                        {
                            portion.HP = 1500;
                            portion.MP = 0;
                            StateOwner._char.HPPortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain HP portion",
                                LifeTime = 120,
                                TextColor = Color.LightCoral,
                            });
                        }
                        if (40 <= portionKindRate && portionKindRate < 80)
                        {
                            portion.HP = 0;
                            portion.MP = 1000;
                            StateOwner._char.MPPortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain MP portion",
                                LifeTime = 120,
                                TextColor = Color.LightBlue,
                            });
                        }
                        if (80 <= portionKindRate)
                        {
                            portion.HP = 1500;
                            portion.MP = 1000;
                            StateOwner._char.RestorePortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain Restore portion",
                                LifeTime = 120,
                                TextColor = Color.Violet,
                            });
                        }

                    }
                    StateOwner._char.CurrentEXP += ExpReward;

                    StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                    {
                        MessageContent = "Gain " + ExpReward.ToString() + " exp",
                        LifeTime = 120,
                        TextColor = Color.Wheat,
                    });
                    if (StateOwner._char.CurrentEXP >= StateOwner._char.NextLevelEXP)
                    {
                        StateOwner._char.DoLevelUp();
                    }
                }
                return;
            }

            if (IsDyed)
            {
                return;
            }
            if (_target != null && IsAttacking && this.IsCollisionWith(_target))
            {
                UpdateDirection(_target.X, _target.Y);
                return;
            }
            if (_target == null)
            {
                if (!IsCasting)
                {
                    Move();
                    UpdateDirection(DestPoint.X, DestPoint.Y);
                }
            }
            else
            {
                if (this.IsCollisionWith(_target))
                {
                    if (!IsAttacking)
                    {
                        IsAttacking = true;
                        UpdateDirection(_target.X, _target.Y);
                        DestPoint = new Point((int)X, (int)Y);
                        CellToMove = new List<Point>();
                    }
                }
                else
                {
                    CellToMove = Utility.FindPath(Map.Matrix, Map.PointToCell(new Point((int)X, (int)Y)), Map.PointToCell(new Point((int)Target.X, (int)Target.Y)));
                    if (CellToMove.Count >= 1)
                    {
                        IsMoving = true;
                        Move();
                        UpdateDirection(DestPoint.X, DestPoint.Y);
                    }
                    else
                    {
                        IsAttacking = true;
                        UpdateDirection(_target.X, _target.Y);
                        CellToMove = new List<Point>();
                    }
                }
            }

            if (Hp <= 0 && !(IsDying || IsDyed))
            {
                IsDying = true;
                UpdateDirection(this.X, this.Y);
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (_listPoisonDamage.Count != 0)
            {
                IsPoisoning = true;
            }
            else
            {
                IsPoisoning = false;
            }
            for (int i = 0; i < _listPoisonDamage.Count; ++i)
            {
                if (_listPoisonDamage[i].Duration % _listPoisonDamage[i].EffectMoment == 0)
                {
                    RecentHPLost += _listPoisonDamage[i].DamageValue;
                }
                _listPoisonDamage[i].Duration -= 1;
                if (_listPoisonDamage[i].Duration == 0)
                {
                    _listPoisonDamage.Remove(_listPoisonDamage[i]);
                }
            }
            if (CheckForDisplayDamage == 0)
            {
                if (RecentHPLost != 0)
                {
                    StateOwner._displayMessageLayer.MessageArray.Add(new DisplayMessageLayer.Message
                    {
                        X              = this.X,
                        Y              = this.Y - 2 * GlobalVariables.MapCollisionDim,
                        Owner          = this,
                        DeltaY         = -1,
                        LifeTime       = 45,
                        MessageContent = RecentHPLost.ToString(),
                        TextColor      = Color.Red,
                        MinY           = (int)this.Y - 2 * GlobalVariables.MapCollisionDim - 30,
                    });
                }

                Hp                   += RecentHPLost;
                RecentHPLost          = 0;
                CheckForDisplayDamage = 30;
            }
            else
            {
                --CheckForDisplayDamage;
            }
            if (IsDying || IsDyed)
            {
                BashTime = 0;
            }
            for (int i = 0; i < AdditionnalEffect.Count; ++i)
            {
                AdditionnalEffect[i].Update(gameTime);

                if (AdditionnalEffect[i].IsCollisionWith(this) && AdditionnalEffect[i].HitFrames.Contains(AdditionnalEffect[i]._sprite[0].Itexture2D) && AdditionnalEffect[i]._sprite[0].Check == 0 && !this.EffectedSkill.Contains(AdditionnalEffect[i].SkillOwner))
                {
                    this.BeHit(GlobalVariables.GlobalRandom.Next(AdditionnalEffect[i].MinDamage, AdditionnalEffect[i].MaxDamage));
                    if (AdditionnalEffect[i].SkillOwner != null)
                    {
                        AdditionnalEffect[i].SkillOwner.DoAdditionalEffect(this);
                    }
                    this.EffectedSkill.Add(AdditionnalEffect[i].SkillOwner);
                }
                else
                if (AdditionnalEffect[i]._sprite[0].Itexture2D == AdditionnalEffect[i]._sprite[0].Ntexture2D - 2)
                {
                    this.EffectedSkill.Remove(AdditionnalEffect[i].SkillOwner);
                }

                if (AdditionnalEffect[i]._sprite[0].Itexture2D == AdditionnalEffect[i]._sprite[0].Ntexture2D - 1)
                {
                    AdditionnalEffect.Remove(AdditionnalEffect[i]);
                }
            }
            if (BashTime > 0)
            {
                --BashTime;
                return;
            }

            _sprite[Dir].Update(gameTime);

            if (this.Hp <= 0 && !IsDying && !IsDyed)
            {
                IsDying = true;
            }

            if (IsDying)
            {
                UpdateDirection(X, Y);
                if (Target != null)
                {
                    Target = null;
                }
                if (_sprite[Dir].Itexture2D == _sprite[Dir].Ntexture2D - 1)
                {
                    IsDyed = true;
                    GlobalVariables.PlayEffectSound("monster" + GlobalVariables.GlobalRandom.Next(1, 17).ToString());
                    int dropItemRate = GlobalVariables.GlobalRandom.Next(0, 100);
                    if (dropItemRate < 35)
                    {
                        int     portionKindRate = GlobalVariables.GlobalRandom.Next(0, 100);
                        Portion portion         = new Portion();
                        portion.PlayerOwner = StateOwner._char;
                        if (portionKindRate < 40)
                        {
                            portion.HP = 1500;
                            portion.MP = 0;
                            StateOwner._char.HPPortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain HP portion",
                                LifeTime       = 120,
                                TextColor      = Color.LightCoral,
                            });
                        }
                        if (40 <= portionKindRate && portionKindRate < 80)
                        {
                            portion.HP = 0;
                            portion.MP = 1000;
                            StateOwner._char.MPPortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain MP portion",
                                LifeTime       = 120,
                                TextColor      = Color.LightBlue,
                            });
                        }
                        if (80 <= portionKindRate)
                        {
                            portion.HP = 1500;
                            portion.MP = 1000;
                            StateOwner._char.RestorePortion.Add(portion);
                            StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                            {
                                MessageContent = "Gain Restore portion",
                                LifeTime       = 120,
                                TextColor      = Color.Violet,
                            });
                        }
                    }
                    StateOwner._char.CurrentEXP += ExpReward;

                    StateOwner._displayMessageLayer.InfoMessageArray.Add(new DisplayMessageLayer.InfoMessage
                    {
                        MessageContent = "Gain " + ExpReward.ToString() + " exp",
                        LifeTime       = 120,
                        TextColor      = Color.Wheat,
                    });
                    if (StateOwner._char.CurrentEXP >= StateOwner._char.NextLevelEXP)
                    {
                        StateOwner._char.DoLevelUp();
                    }
                }
                return;
            }

            if (IsDyed)
            {
                return;
            }
            if (_target != null && IsAttacking && this.IsCollisionWith(_target))
            {
                UpdateDirection(_target.X, _target.Y);
                return;
            }
            if (_target == null)
            {
                if (!IsCasting)
                {
                    Move();
                    UpdateDirection(DestPoint.X, DestPoint.Y);
                }
            }
            else
            {
                if (this.IsCollisionWith(_target))
                {
                    if (!IsAttacking)
                    {
                        IsAttacking = true;
                        UpdateDirection(_target.X, _target.Y);
                        DestPoint  = new Point((int)X, (int)Y);
                        CellToMove = new List <Point>();
                    }
                }
                else
                {
                    CellToMove = Utility.FindPath(Map.Matrix, Map.PointToCell(new Point((int)X, (int)Y)), Map.PointToCell(new Point((int)Target.X, (int)Target.Y)));
                    if (CellToMove.Count >= 1)
                    {
                        IsMoving = true;
                        Move();
                        UpdateDirection(DestPoint.X, DestPoint.Y);
                    }
                    else
                    {
                        IsAttacking = true;
                        UpdateDirection(_target.X, _target.Y);
                        CellToMove = new List <Point>();
                    }
                }
            }

            if (Hp <= 0 && !(IsDying || IsDyed))
            {
                IsDying = true;
                UpdateDirection(this.X, this.Y);
            }
        }