Exemplo n.º 1
0
    /// <summary>
    /// Called from object giving damage. Kills player if health less than or equal to 0
    /// </summary>
    /// <param name="damage">amount damage given</param>
    public void DamagePlayer(int damage)
    {
        health -= damage;
        if (health <= 0 && !hasDied)
        {
            hasDied = true;
            var spawner = GetComponent <VirusSpawner>();
            if (gameObject.tag == "Player")
            {
                FindObjectOfType <Tank>().TriggerDeathAnimation();
            }
            else if (spawner == null)
            {
                enemyText.UpdateEnemyCountText(-1);
                animator.SetTrigger("Death");
            }
            else
            {
                spawner.DestroyVirusSpawner();
            }
        }

        if (gameObject.tag == "Player")
        {
            armorText.UpdateArmorText();
        }
    }
Exemplo n.º 2
0
    public void SpawnVirus()
    {
        Vector3?spawnPosition = FindOpenSpawnPosition();

        if (spawnPosition != null)
        {
            GameObject newVirus = Instantiate(virus, (Vector3)spawnPosition, Quaternion.identity, enemiesParent.transform);
            enemyText.UpdateEnemyCountText(1);
        }
    }