Example #1
0
    public void InflictDamage(float damage)
    {
        _audio.clip = (damage < 80) ? _normDmg : _bigDmg;
        _audio.Play();

        eText.gameObject.SetActive(true);

        BattlePlayer p = GameObject.FindWithTag("Player").GetComponent <BattlePlayer>();

        StartCoroutine(p.ItemDelay());
        eText.SetText(string.Format("Enemy took {0} damage!", damage));

        GameObject  dpObject = Instantiate(_dmgPopup, transform.position, Quaternion.identity);
        DamagePopup dp       = dpObject.GetComponent <DamagePopup>();

        dp.SetText(damage.ToString());

        float shakeMag = (damage / 200f) * 2f;

        StartCoroutine(Shake(0.15f, shakeMag));

        health -= damage;
        hpBar.SetVal(health);
        if (health <= 0)
        {
            battleSys.state = BattleState.PLAYER_WIN;
            StartCoroutine(Reward());
        }
    }
Example #2
0
 public void StartPlayerPhase()
 {
     if (state != BattleState.PLAYER_WIN && state != BattleState.PLAYER_LOSE)
     {
         state = BattleState.PLAYER_PHASE;
         uiManager.ActivateButtons();
         eText.SetText("What will the Adventurer do?");
         actionPanel.SetActive(true);
     }
 }
Example #3
0
    public void Heal(float healValue)
    {
        _audio.clip = _heal;
        _audio.Play();

        health += healValue;
        hpBar.SetVal(health);
        GameManager.GetInstance().humanityValue += (int)(healValue / 2);

        string healText = $"The Adventurer heals for {healValue} HP!\n\n";

        if (healValue > 90)
        {
            healText = healText + "The blissful taste of a delicious meal restores our adventurer's" +
                       " humanity.";
        }
        else if (healValue > 40)
        {
            healText = healText + "The comforting taste of a meal reminds our adventurer of home.";
        }
        else
        {
            healText = healText + "The taste of food keeps our adventurer's sanity in check.";
        }
        eText.SetText(healText);
        if (health > maxHealth)
        {
            health = maxHealth;
        }
    }
Example #4
0
 public void UpdateEventText()
 {
     EventText.SetText($"{MyEvent.EventType.ToString()}({string.Join(", ", MyEvent.Parameters)})");
 }