Пример #1
0
    public void AddPlayerHealthPoint(int hurtDamage, int caseHeal)
    {
        if (caseHeal == 0)
        {
            cameraController.StopAllCoroutines();
            cameraController.StartCoroutine(cameraController.ShakeCamera(0.1f, 0.05f));
            playerStatistics.AddCharactorHealthPoint(hurtDamage);

            if (playerStatistics.HP > 0)
            {
                CurPlayerStatus(PlayerState.Player_Hurt);
            }
            else if (playerStatistics.HP <= 0)
            {
                playerStatistics.HP = 0;
                playerDeath         = true;
                CurPlayerStatus(PlayerState.Player_Death);
                StartCoroutine(PlayerDeath());
            }
        }
        else if (caseHeal == 1)
        {
            playerStatistics.DrinkPotion(hurtDamage);
        }
        healthBar.UpdateBar(playerStatistics.HP, playerStatistics.hpMax);
        healthBar.transform.GetChild(0).GetComponent <Text>().text = playerStatistics.HP.ToString() + "/" + playerStatistics.hpMax.ToString();
    }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Weapon"))
     {
         hitEffect.Play();
         hitSound.Play();
         godzillaStatistics.AddCharactorHealthPoint(-other.transform.GetComponent <WeaponValue>().damage);
         healthBar.UpdateBar(godzillaStatistics.HP, godzillaStatistics.hpMax);
         healthBar.transform.GetChild(0).GetComponent <Text>().text = godzillaStatistics.HP.ToString() + "/" + godzillaStatistics.hpMax.ToString();
         if (godzillaStatistics.HP <= 0)
         {
             this.transform.GetComponent <GodzillaController>().godzillaDeath = true;
         }
     }
 }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Weapon"))
        {
            playerTransform = other.transform.GetComponent <WeaponValue>().playerTransform;
            Vector3 knockBack = bodyTransform.position - other.transform.position;
            knockBack = knockBack.normalized;
            bodyTransform.GetComponent <Rigidbody>().AddForce(knockBack * nockForce);

            hitEffect.Play();

            if (chractorStat.HP > 0)
            {
                hitText.SetActive(true);
                hitText.transform.position = this.transform.position;
                hitText.GetComponent <Rigidbody>().Sleep();
                hitText.GetComponent <Rigidbody>().AddForce(0, 300f, 0);
                hitText.transform.GetChild(0).GetComponent <TextMesh>().text = (-playerTransform.GetComponent <PlayerStats>().PlayerAttackDamage()).ToString();
                if (chractorStat.HP < chractorStat.hpMax * 0.5f)
                {
                    hitText.transform.GetChild(0).GetComponent <TextMesh>().color = new Color(255, 0, 0);
                }
                chractorStat.AddCharactorHealthPoint(-playerTransform.GetComponent <PlayerStats>().PlayerAttackDamage());
            }
            else
            {
                playerTransform.GetComponent <PlayerInventory>().SetGold(chractorStat.Exp);
                bodyTransform.GetComponent <ScarabController>().SetAnimation(EnemyStatus.enemy_Death);
                if (!scarabDeath)
                {
                    scarabDeath = true;
                    bodyTransform.GetComponent <ScarabController>().sacrabSpawnPoint.CountUI();
                }
            }
        }
        if (other.CompareTag("CarSkill"))
        {
            hitEffect.Play();
            if (chractorStat.HP > 0)
            {
                hitText.SetActive(true);
                hitText.transform.position = this.transform.position;
                hitText.GetComponent <Rigidbody>().Sleep();
                hitText.GetComponent <Rigidbody>().AddForce(0, 300f, 0);
                hitText.transform.GetChild(0).GetComponent <TextMesh>().text = (-other.GetComponent <WeaponValue>().damage).ToString();
                if (chractorStat.HP < chractorStat.hpMax * 0.5f)
                {
                    hitText.transform.GetChild(0).GetComponent <TextMesh>().color = new Color(255, 0, 0);
                }
                chractorStat.AddCharactorHealthPoint(-other.GetComponent <WeaponValue>().damage);
            }
            else
            {
                //playerTransform.GetComponent<PlayerInventory>().SetGold(chractorStat.Exp);
                bodyTransform.GetComponent <ScarabController>().SetAnimation(EnemyStatus.enemy_Death);
                if (!scarabDeath)
                {
                    scarabDeath = true;
                    bodyTransform.GetComponent <ScarabController>().sacrabSpawnPoint.CountUI();
                }
            }
        }
    }