Ejemplo n.º 1
0
    void Spawn()
    {
        Vector3 attemptedSpawnLocation = new Vector3();

        while (!AttemptSpawnLocation(ref attemptedSpawnLocation))
        {
        }
        GameObject spawnedObject = Instantiate(objectToSpawn, attemptedSpawnLocation, Quaternion.identity);

        if (canOnlyHaveOne)
        {
            objectInScene = true;
            CollectableEventFirer eventFirer = spawnedObject.GetComponent <CollectableEventFirer>();
            if (eventFirer)
            {
                eventFirer.onCollection += OnObjectCollected;
            }
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     collider = GetComponent <Collider2D>();
     collectableEventFirer = GetComponent <CollectableEventFirer>();
 }