Example #1
0
 // Start is called before the first frame update
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         if (isZombie)
         {
             if (EnemyTasks.isHAttack == true)
             {
                 //Debug.Log("HeavyAttack");
                 playerHealth.DecreaseHealth(8);
             }
             else if (EnemyTasks.isLAttack == true)
             {
                 playerHealth.DecreaseHealth(3);
             }
         }
         else
         {
             if (EnemyTasks.isAttack == true)
             {
                 playerHealth.DecreaseHealth(1);
             }
         }
     }
 }
Example #2
0
        IEnumerator GetDamage()
        {
            EnemyStateEnum currentEnemyState = enemyState.StateOfEnemy;

            enemyState.StateOfEnemy = EnemyStateEnum.Damaging;
            rb.AddRelativeForce(0, 0, 1 /*Insert weapon Knockback*/, ForceMode.Impulse);
            hs.DecreaseHealth(playerInventoryManager.SelectedWeapon.ContainedWeapon.ItemData.weaponDamage);
            if (!hs.IsAlive)
            {
                OnDeath();
            }
            yield return(new WaitForSeconds(0.1f));

            enemyState.StateOfEnemy = currentEnemyState;
        }
Example #3
0
 void DecHealth(int counter, int factor)
 {
     if (counter % 6 == 0)
     {
         go.DecreaseHealth(factor);
     }
 }
Example #4
0
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     /*if (hit.gameObject.CompareTag("Food"))
      * {
      *  var food = hit.gameObject.GetComponent<Food>();
      *  Destroy(hit.gameObject);
      *  healthSystem.IncreaseHealth(food.health);
      *  hungerSystem.DecreaseHungerLevel(food.hunger);
      *
      * }*/
     if (hit.gameObject.CompareTag("Item"))
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             if (backpack.AddItem(hit.gameObject))
             {
                 Destroy(hit.gameObject);
             }
         }
     }
     else if (hit.gameObject.CompareTag("Obstacle"))
     {
         var food = hit.gameObject.GetComponent <Obstacle>();
         healthSystem.DecreaseHealth(food.health);
     }
 }
Example #5
0
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.CompareTag("Obstacle"))
        {
            var obstacle = hit.gameObject.GetComponent <Obstacle>();
            if (obstacle)
            {
                healthSystem.DecreaseHealth(obstacle.health);
            }
        }

        if (hit.gameObject.CompareTag("Item"))
        {
            if (backpack.AddItem(hit.gameObject))
            {
                Destroy(hit.gameObject);
            }
        }

        /*if(hit.gameObject.CompareTag("Food"))
         * {
         *  var food = hit.gameObject.GetComponent<Food>();
         *  if(food)
         *  {
         *      Destroy(hit.gameObject);
         *      healthSystem.IncreaseHealth(food.health);
         *      hungerSystem.DecreaseHungerLevel(food.hunger);
         *  }
         * }*/
    }
Example #6
0
 private void OnTriggerEnter(Collider collision)
 {
     if (collision.CompareTag(GameUtility.PLAYER_TAG) && PlayerAttack.Attacking)
     {
         healthSystem.DecreaseHealth(playerInventoryManager.SelectedWeapon.ContainedWeapon.ItemData.weaponDamage);
     }
 }
 private void UpdateHungerLevel()
 {
     IncreaseHungerLevel(10);
     if (hungerLevel >= 80)
     {
         healthSystem.DecreaseHealth(10);
     }
 }
 /// <summary>
 /// Callback method to handle on colliding event from Asteroid
 /// </summary>
 internal void OnAsteroidColliding()
 {
     playerHealth.DecreaseHealth();
     if (playerHealth.IsAlreadyDead())
     {
         Destroy(gameObject);
     }
 }
 protected override void AttackOnce()
 {
     Collider[] colliders = Physics.OverlapSphere(TransformCache.position, AttackRange, GameUtility.PlayerLayer);
     if (colliders.Length > 0)
     {
         //We've hit the player
         playerHealthSystem.DecreaseHealth(damage);
     }
 }
Example #10
0
 private void HandleHit()
 {
     if (_collider.IsTouchingLayers(LayerMask.GetMask("Enemy")))
     {
         StartCoroutine(BlinkPlayer());
         _healthSystem.DecreaseHealth();
         // Dá um tempo pro jogador fugir dos inimigos antes de levar um hit novamente.
         DisableCollider();
         Invoke(nameof(EnableCollider), 2f);
     }
 }
Example #11
0
    /// <summary>
    /// Callback method to handle on colliding event from Bullet
    /// </summary>
    internal void OnBulletColliding()
    {
        asteroidHealth.DecreaseHealth();

        asteroidSelf.parentSystem.UpdateScore(asteroidHealth.GetHealth());

        Destroy(gameObject);

        if (asteroidHealth.IsAlreadyDead())
        {
            return;
        }

        asteroidSelf.SpawnChildAsteroids();
    }
Example #12
0
    /* void OnControllerColliderHit(ControllerColliderHit hit)
     * {
     *   if (hit.gameObject.CompareTag("pineapple"))
     *   {
     *       Destroy(hit.gameObject);
     *       health += 10;
     *   }
     *
     *   if (hit.gameObject.CompareTag("meat"))
     *   {
     *       Destroy(hit.gameObject);
     *       health += 15;
     *       Debug.Log(health);
     *   }
     *
     *   if (hit.gameObject.CompareTag("cactus"))
     *   {
     *      // Destroy(hit.gameObject);
     *       health -= 1;
     *   }
     * }*/
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.CompareTag("Obstacle"))
        {
            var obstacle = hit.gameObject.GetComponent <Obstacle>();
            if (obstacle)
            {
                healthSystem.DecreaseHealth(obstacle.health);
                Debug.Log("Hit");
            }
        }

        if (hit.gameObject.CompareTag("Food"))
        {
            var food = hit.gameObject.GetComponent <Food>();
            if (food)
            {
                Destroy(hit.gameObject);
                healthSystem.IncreaseHealth(food.health);
                hungerSystem.DecreaseHungerLevel(food.hunger);
            }
        }
    }