Esempio n. 1
0
  void Start()
  {
      if (GameObject.FindGameObjectWithTag("Player") != null)
      {
          playerTransform = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
          PlayerScript    = GameObject.FindGameObjectWithTag("Player").GetComponent <move>();
      }

      pointsScript = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Pontuation>();
      powerScripts = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PowerManager>();
      TypeRead     = type;

      if (gameObject.tag == "EnemyDuplicate")
      {
          spawnDuplicateScript = gameObject.GetComponent <SpawnDuplicate>();
      }

      waitShot = timeShot;
  }
Esempio n. 2
0
  public void OnTriggerEnter(Collider col)
  {
      if (col.gameObject.CompareTag("bullet"))                                                             //check object colliding in tag player
      {
          GameObject explosionprefab = Instantiate(explosion, col.transform.position, transform.rotation); // instantieate a particle system
          Destroy(explosionprefab, 3f);                                                                    //destroy particle

          Destroy(col.gameObject);                                                                         //destroy bullet
          lifeEnemy--;

          if (lifeEnemy <= 0)
          {
              lifeEnemy = 0;
              type      = typeEnemy.dead;
          }
      }

      if (col.gameObject.CompareTag("Player"))
      {
          type = typeEnemy.dead;
          PlayerScript.PlayerDamage();
      }
  }