Beispiel #1
0
 // Drop the carried flag at the specified position
 public void DropFlag(Vector3 pos)
 {
     if (flag != null)
     {
         flag.Drop(pos);
         flag = null;
     }
 }
Beispiel #2
0
    public void Die()
    {
        Debug.Log($"{this.Team} ninja died!");
        this.isAlive = false;
        if (carriedFlag != null)
        {
            this.speed += this.carriedFlag.playerSpeedReduceWhenGrabbed;
            carriedFlag.Drop(transform.position);
            carriedFlag = null;
        }

        ninjaAnimation.DieAnimation();
        StartCoroutine(DieCoroutine());
    }
    /// <summary>
    /// Damages this enemy.
    /// </summary>
    /// <param name="amount">The amount to damage by.</param>
    public void Damage(float amount)
    {
        // Subtract health from this knight
        health -= amount;

        // Adjust health bar
        healthBar.GetComponent <RectTransform>().sizeDelta = new Vector2(Mathf.Max(health / 100.0f, 0), 0.05f);

        // If health is below 0, die
        if (health <= 0.0f && !onlySpawnOne)
        {
            // Create ragdoll
            onlySpawnOne = true;

            // If holding flag, drop it
            if (isHoldingFlag)
            {
                otherTeamFlag.Drop();
                // Show message
                gameManager.eventText.text = name.Replace("(Clone)", "") + " died and dropped your flag!";
            }
            else
            {
                gameManager.eventText.text = name.Replace("(Clone)", "") + " died!";
            }


            // Play death scream
            AudioSource.PlayClipAtPoint(death, transform.position);

            // Remove from enemies list
            gameManager.enemies.Remove(gameObject);

            // Drop gun
            gun.DropGun();

            // Create ragdoll
            GameObject ragdoll = Instantiate(deathRagdoll, transform.position, transform.rotation);
            Destroy(ragdoll, 7.0f);

            // Destroy self
            Destroy(gameObject);
        }
    }