Exemplo n.º 1
0
        /// <summary>
        /// Нанести урон персонажу
        /// </summary>
        public void TakeDamage(AbilityTypes type, int damage)
        {
            HealthSegment healthSegment = GetSegmentForTakeDamage(type);

            if (healthSegment != null)
            {
                //Нанести  урон
                healthSegment.TakeDamage(damage);

                //Обновить UI
                m_UIHealthBarController.UpdateUI(type, healthSegment.CurHealth);

                //Персонаж уничтожен
                if (CreatureIsDestroyed())
                {
                    if (OnDestroy != null)
                    {
                        OnDestroy();
                    }
                }
                else //Нанесен урон
                {
                    if (OnTakeDamage != null)
                    {
                        OnTakeDamage(healthSegment.Type, healthSegment.CurHealth);
                    }
                }
            }
            else //Урон не подходящей способностью
            {
                if (OnWrongAbility != null)
                {
                    OnWrongAbility(type);
                }
            }
        }