Exemple #1
0
 protected virtual void Death()
 {
     if (mSpawnObjects != null)
     {
         mSpawnObjects.Spawn();
     }
     Destroy(gameObject);
 }
Exemple #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (mSpawnObject != null)
     {
         mSpawnObject.Spawn();
     }
     Destroy(gameObject);
 }
Exemple #3
0
 private void Death()
 {
     GameOverText.gameObject.SetActive(true);
     HealthSlider.gameObject.SetActive(false);
     EventManager.TriggerEvent("PlayerDeath");
     mSpawnObjects.Spawn();
     Destroy(gameObject);
 }
Exemple #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();
         playerHealth.GiveHealth(Health);
         mSpawnObject.Spawn();
         Destroy(gameObject);
     }
 }
Exemple #5
0
    void Update()
    {
        // get how far to move and move that far toward the target
        float step = Toolbox.Instance.ScrollSpeed * Time.deltaTime;

        transform.position = Vector2.MoveTowards(transform.position, target.position, step);

        // a distance of 0.1 is effectively inside the other object and
        // provides a margin of error for if the background would overstep
        if (Vector2.Distance(transform.position, target.position) < 0.1f)
        {
            transform.position = Vector2.zero;
            if (spawnObjects != null)
            {
                spawnObjects.Spawn();
            }
        }
    }