Exemplo 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);
            }
        }
    }
Exemplo n.º 2
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;
    }
Exemplo n.º 3
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));
     }
 }