Esempio n. 1
0
        private void OnTriggerExit(Collider other)
        {
            --count;
            if (count > 0)
            {
                return;
            }

            PoolManagerScript.Despawn(spawnedLevel);
        }
Esempio n. 2
0
        private void OnTriggerStay(Collider other)
        {
            ++count;
            if (count > 1)
            {
                return;
            }

            spawnedLevel = PoolManagerScript.Spawn(levelPrefab, transform.position, Quaternion.identity);
        }
Esempio n. 3
0
        /// <summary>
        /// Initialization called by PoolManagerScript on runtime created pools.
        /// </summary>
        public void Awake()
        {
            //can't initialize without prefab
            if (prefab == null)
            {
                return;
            }

            //add this pool to the PoolManagerScript dictionary
            PoolManagerScript.Add(this);

            PreLoad();
        }
Esempio n. 4
0
        /// <summary>
        /// Instantiates the object in the scene using PoolManagerScript functionality.
        /// </summary>
        private void SpawnLoot()
        {
            var random = Random.Range(0, 100);
            int index  = CalculateRandom(random);

            if (obj != null)
            {
                return;
            }

            var spawPosition = new Vector3(transform.position.x, transform.position.y + 2.55f, transform.position.z);

            //use the poolmanager to spawn the loot on top of the plateforme
            obj = PoolManagerScript.Spawn(prefabs[index], spawPosition, prefabs[index].gameObject.transform.localRotation);

            var pObject = obj.GetComponent <PlayerObjectScript>();

            pObject.SetLootTrackerIndex(LootTracker.Count);
            LootTracker.Add(pObject);
        }
Esempio n. 5
0
 /// <summary>
 /// Called by the spawned object to destroy itself on this managing component.
 /// For example when it has been collected by players.
 /// </summary>
 public void Destroy()
 {
     //despawn object and clear references
     PoolManagerScript.Despawn(obj);
     obj = null;
 }