Ejemplo n.º 1
0
Archivo: Unit.cs Proyecto: rio900/voins
        /// <summary>
        /// Получение урона
        /// </summary>
        /// <param name="phisic">физический</param>
        /// <param name="magic">магический</param>
        /// <param name="pure">чистый</param>
        public IUnit GatDamage(int phisic, int magic, int pure, IUnit demagedUnit)
        {
            Player playerDemaged = demagedUnit as Player;

            int magicDemagePlus = magic;

            ///Действие аганима
            if (playerDemaged != null)
            {
                foreach (var item in playerDemaged.Items)
                {
                    if (item.BonusMagicDemage > 0)
                    {
                        magicDemagePlus = magicDemagePlus + (int)(magic * item.BonusMagicDemage);
                    }
                }
            }

            int demage = StaticVaribl.DemageAndArmor(phisic, Arrmor) + StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor) + pure;

            Health -= demage;

            IUnitControl chpView = GameObject.View as IUnitControl;

            if (chpView != null)
            {
                chpView.ShowHealth(Health, MaxHealth);
            }

            if (GetDemageEvent != null)
            {
                GetDemageEvent(StaticVaribl.DemageAndArmor(phisic, Arrmor),
                               StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor),
                               pure, this);
            }

            IGameControl control = (this.GameObject.View as IGameControl);

            if (control != null)
            {
                ///Отображаем сколько урона получил юнит
                control.GetDemage("-" + demage);
            }

            if (Health <= 0)
            {///Значит объект унечтожен
                return(RemoveUnit(demagedUnit));
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Получение урона
        /// </summary>
        /// <param name="phisic">физический</param>
        /// <param name="magic">магический</param>
        /// <param name="pure">чистый</param>
        public IUnit GatDamage(int phisic, int magic, int pure, IUnit demagedUnit)
        {
            IUnit removedUnit = null;

            if (!Invulnerability)
            {
                Player playerDemaged = demagedUnit as Player;

                int magicDemagePlus = magic;
                ///Действие аганима
                if (playerDemaged != null)
                {
                    foreach (var item in playerDemaged.Items)
                    {
                        if (item.BonusMagicDemage > 0)
                        {
                            magicDemagePlus = magicDemagePlus + (int)(magic * item.BonusMagicDemage);
                        }
                    }
                }

                int demage = StaticVaribl.DemageAndArmor(phisic, Arrmor) + StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor) + pure;

                #region Statistic
                StatisticData.DemageSelfs += demage;

                if (playerDemaged != null)
                {
                    playerDemaged.StatisticData.Demage += demage;
                }
                #endregion
                Health -= demage;

                IUnitControl chpView = GameObject.View as IUnitControl;
                if (chpView != null)
                {
                    chpView.ShowHealth(Health, MaxHealth);
                }

                if (GetDemageEvent != null)
                {
                    GetDemageEvent(StaticVaribl.DemageAndArmor(phisic, Arrmor),
                                   StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor),
                                   pure, this);
                }

                ///Отображаем сколько урона получил юнит
                (this.GameObject.View as IGameControl).GetDemage("-" + demage);

                if (Health <= 0)
                {///Значит объект унечтожен
                    removedUnit = RemoveUnit(demagedUnit);
                }

                UpdateView();
            }
            else
            {
                (this.GameObject.View as IGameControl).GetDemage("Invulnerability");
            }

            return(removedUnit);
        }