Esempio n. 1
0
    protected void Update()
    {
        isActive = self.GetCurrentHealth() > self.GetMaxHealth() * healthMinRatio;

        foreach (BaseHealth i in inside)
        {
            if (!isActive)
            {
                return;
            }
            if (timers.ContainsKey(i))
            {
                timers[i] -= Time.deltaTime;
                if (timers[i] <= 0)
                {
                    timers[i] = tickTime;

                    float amountToHeal = (i.GetCurrentHealth() + healRate >= i.GetMaxHealth()) ? i.GetMaxHealth() - i.GetCurrentHealth() : healRate;

                    i.Heal(healRate, gameObject, self.gameObject);

                    self.Damage(amountToHeal * selfDamageRatio, gameObject, i.gameObject);
                }
            }
            else
            {
                timers.Add(i, tickTime);
            }
        }
    }
    private void Awake()
    {
        m_ShipHealth = GetComponent <BaseHealth>();

        m_ShipHealth.TakeDamageEvent += m_HealthBarController.ReduceHealth;
        m_ShipHealth.TakeDamageEvent += m_EnemyAnimation.DoOnTakeDamageAnimation;

        m_HealthBarController.SetMaxHealth(m_ShipHealth.GetMaxHealth());
    }
Esempio n. 3
0
    public void Initialize(GameObject g)
    {
        UIActive.SetActive(true);
        player = g;

        playerHealth  = Lib.FindInHierarchy <BaseHealth>(player);
        currentHealth = playerHealth.GetCurrentHealth();
        maxHealth     = playerHealth.GetMaxHealth();
        playerHealth.healthValueUpdateEvent += UpdateCachedHealthValues;
        playerHealth.healthChangeEvent      += HealthChange;

        playerAbilities = Lib.FindInHierarchy <PlayerAbilities>(player);
        playerAbilities.initializedEvent += OnAbilityInitialized;
    }
Esempio n. 4
0
 public override void OnInspectorGUI()
 {
     if (EditorApplication.isPlaying || EditorApplication.isPaused)
     {
         EditorGUILayout.LabelField(string.Format("{0}/{1}", baseHealth.GetCurrentHealth(), baseHealth.GetMaxHealth()));
         if (GUILayout.Button("Take 1 Damage"))
         {
             baseHealth.Damage(1, null, null);
         }
         return;
     }
     if (statBlock == null || !statBlock.HasStat(StatName.Toughness))
     {
         base.OnInspectorGUI();
     }
     else
     {
         EditorGUILayout.LabelField("Max Health is being set by the StatBlock");
         EditorGUILayout.LabelField("Value: " + statBlock.GetValue(StatName.Toughness));
     }
 }
Esempio n. 5
0
 public void Start()
 {
     m_IslandHealth = gameObject.GetComponent <IslandHealth>();
     m_IslandHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ReduceHealth;
     UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.SetMaxHealth(m_IslandHealth.GetMaxHealth());
     m_IslandHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ResetHealth;
 }
Esempio n. 6
0
 public void Start()
 {
     m_PlayersHealth = GetComponent <BaseHealth>();
     m_PlayersHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ReduceHealth;
     UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.SetMaxHealth(m_PlayersHealth.GetMaxHealth());
     m_PlayersHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ResetHealth;
 }