Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (spawnTimer.Finished)
     {
         spawnTimer.Run();
         spawnLocation.x = Random.Range(spawnMinX, spawnMaxX);
         Instantiate(prefabBat, spawnLocation, Quaternion.identity);
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (explodeTimer.Finished)
        {
            explodeTimer.Run();

            // blow up C4 teddy bear
            GameObject Batboy = GameObject.FindWithTag("C4 bat");
            if (Batboy != null)
            {
                Instantiate <GameObject>(prefabExplosion,
                                         Batboy.transform.position, Quaternion.identity);
                Destroy(Batboy);
            }
        }
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject    tempBat   = Instantiate(prefabBat) as GameObject;
        BoxCollider2D collider  = tempBat.GetComponent <BoxCollider2D>();
        float         batWidth  = collider.size.x;
        float         batHeight = collider.size.y;

        Destroy(tempBat);

        spawnMinX       = ScreenUtils.ScreenLeft + batWidth / 2;
        spawnMaxX       = ScreenUtils.ScreenRight - batWidth / 2;
        spawnLocation.y = ScreenUtils.ScreenTop + batHeight / 2;

        // start spawn timer
        spawnTimer          = gameObject.AddComponent <timer>();
        spawnTimer.Duration = SpawnDelaySec;
        spawnTimer.Run();
    }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     explodeTimer          = gameObject.AddComponent <timer>();
     explodeTimer.Duration = 1;
     explodeTimer.Run();
 }