示例#1
0
    /// <summary>
    /// Cause this object to damage another object.
    /// </summary>
    /// <param name="obj">Which GameObject to damage. To work, the object must have a HealthAndRespawn behavior.</param>
    void DoDamage(GameObject obj)
    {
        HealthAndRespawn health = obj.GetComponent <HealthAndRespawn>();

        if (health)
        {
            health.TakeDamage(damageAmount);
        }
    }
示例#2
0
 /// <summary>
 /// When a collider hits this object, set the object's respawn position in its HealthAndRespawn script.
 /// </summary>
 /// <param name="other">The collider that hit this object.</param>
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         HealthAndRespawn health = other.GetComponent <HealthAndRespawn>();
         if (health)
         {
             health.SetSpawn(worldSpawnPosition);
         }
         if (health && fillPlayerHP)
         {
             health.FillHP();
         }
     }
 }
示例#3
0
    /// <summary>
    /// Checks if the object has fallen past the yKillThreshold. If so, kill the object.
    /// </summary>
    void Update()
    {
        if (transform.position.y < yKillThreshold)
        {
            //print("fell into void...");
            HealthAndRespawn health = GetComponent <HealthAndRespawn>();

            if (health)
            {
                health.Die();
            }
            else
            {
                Destroy(gameObject);
            }
        }
    } // ends Update()
示例#4
0
 public void SetPlayer(PlayerController player)
 {
     this.player   = player;
     this.playerHP = player.GetComponent <HealthAndRespawn>();
     this.jetpack  = player.GetComponent <Jetpack>();
 }