Esempio n. 1
0
 void Start()
 {
     arrowRotation = Quaternion.Euler(0, 0, 90);
     info          = SetPoolingObjectInfo(arrowPrefab, gameObject, gameObject.transform.position, arrowRotation);
     CreatePoolingObjectQueue(info, 1);
     SetAutoSpawn(info, ACTIVATE_TIME);
 }
Esempio n. 2
0
        void Start()
        {
            gemList.Add(diamondPrefab);
            gemList.Add(rubyPrefab);
            gemList.Add(emeraldPrefab);
            gemList.Add(sapphirePrefab);
            gemList.Add(goldBarPrefab);
            gemList.Add(idolPrefab);

            for (int i = 0; i < gemList.Count; i++)
            {
                PoolingObjectInfo gemInfo = new PoolingObjectInfo
                {
                    prefab         = gemList[i],
                    spawner        = gameObject,
                    position       = transform.position,
                    objectRotation = transform.rotation
                };
                gemsInfo.Add(gemInfo);
                ObjectPooler.instance.CreatePoolingObjectQueue(gemsInfo[i], 100);
            }

            closedChest = transform.GetChild(0).gameObject;
            openedChest = transform.GetChild(1).gameObject;

            closedChest.SetActive(true);
            openedChest.SetActive(false);
        }
Esempio n. 3
0
        public void CreatePoolingObjectQueue(PoolingObjectInfo info, int size)
        {
            GameObject         obj;
            Queue <GameObject> poolingObjectQueue;

            if (poolDictionary.ContainsKey(info.prefab))
            {
                poolingObjectQueue = poolDictionary[info.prefab];
                poolDictionary.Remove(info.prefab);
            }
            else
            {
                poolingObjectQueue = new Queue <GameObject>();
            }

            for (int i = 0; i < size; i++)
            {
                obj = Instantiate(info.prefab);
                obj.SetActive(false);
                obj.transform.position = new Vector3(info.position.x, info.position.y, Random.Range(0.0f, 1.0f));
                obj.transform.SetParent(info.spawner.transform);
                poolingObjectQueue.Enqueue(obj);
            }
            poolDictionary.Add(info.prefab, poolingObjectQueue);
        }
Esempio n. 4
0
 void SpawnBomb()
 {
     poisonBombInfo                = poisonBombSpawner.info;
     throwDirection                = enemyPhysics.rotation.y == 0.0f ? 1 : -1;
     poisonBombSpawnPosition.x     = throwDirection * Mathf.Abs(poisonBombSpawnPosition.x);
     poisonBombInfo.position       = transform.position + poisonBombSpawnPosition;
     poisonBombInfo.objectRotation = enemyPhysics.rotation;
     poisonBombSpawner.OperateSpawn(poisonBombInfo, PoisonBombSpawner.ACTIVATE_TIME);
 }
Esempio n. 5
0
 public void ClearPoolingObjectQueue(PoolingObjectInfo info)
 {
     if (poolDictionary.ContainsKey(info.prefab))
     {
         Queue <GameObject> poolingObjectQueue;
         poolingObjectQueue = poolDictionary[info.prefab];
         poolingObjectQueue.Clear();
     }
 }
Esempio n. 6
0
        IEnumerator CheckAutoSpawnCoroutine(PoolingObjectInfo info, float objectActivateTime)
        {
            GameObject poolingObject = ObjectPooler.instance.GetPoolingObject(info);

            yield return(new WaitForSeconds(objectActivateTime));

            RecyclePoolingObject(info, poolingObject);
            SetAutoSpawn(info, objectActivateTime);
        }
Esempio n. 7
0
 void SpawnDagger()
 {
     daggerInfo                = daggerSpawner.info;
     throwDirection            = enemyPhysics.rotation.y == 0.0f ? 1 : -1;
     daggerSpawnPosition.x     = throwDirection * Mathf.Abs(daggerSpawnPosition.x);
     daggerInfo.position       = transform.position + daggerSpawnPosition;
     daggerInfo.objectRotation = enemyPhysics.rotation;
     daggerSpawner.OperateSpawn(daggerInfo, DaggerSpawner.ACTIVATE_TIME);
 }
Esempio n. 8
0
        void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            int childs = transform.childCount;

            for (int i = childs - 1; i >= 0; i--)
            {
                DestroyImmediate(transform.GetChild(i).gameObject);
            }
            info = SetPoolingObjectInfo(prefab, gameObject, gameObject.transform.position, transform.rotation);
            CreatePoolingObjectQueue(info, 10);
        }
Esempio n. 9
0
        protected PoolingObjectInfo SetPoolingObjectInfo(GameObject prefab, GameObject spawner)
        {
            PoolingObjectInfo info = new PoolingObjectInfo
            {
                prefab         = prefab,
                spawner        = spawner,
                position       = spawner.transform.position,
                objectRotation = spawner.transform.rotation
            };

            return(info);
        }
Esempio n. 10
0
        protected PoolingObjectInfo SetPoolingObjectInfo(GameObject prefab, GameObject spawner, Vector3 position, Quaternion objectRotation)
        {
            PoolingObjectInfo info = new PoolingObjectInfo
            {
                prefab         = prefab,
                spawner        = spawner,
                position       = position,
                objectRotation = objectRotation
            };

            return(info);
        }
Esempio n. 11
0
 public void SetActiveFalsePoolingObjects(PoolingObjectInfo info)
 {
     if (!poolDictionary.ContainsKey(info.prefab))
     {
         return;
     }
     foreach (GameObject obj in poolDictionary[info.prefab])
     {
         obj.transform.position = new Vector3(info.position.x, info.position.y, Random.Range(0.0f, 1.0f));
         obj.transform.rotation = info.objectRotation;
         obj.SetActive(false);
     }
 }
Esempio n. 12
0
 public void RecyclePoolingObject(PoolingObjectInfo info, GameObject clone)
 {
     if (clone == null)
     {
         return;
     }
     clone.transform.SetParent(info.spawner.transform);
     clone.SetActive(false);
     if (!poolDictionary.ContainsKey(info.prefab))
     {
         Queue <GameObject> poolingObjectQueue = new Queue <GameObject>();
         poolingObjectQueue.Enqueue(clone);
         poolDictionary.Add(info.prefab, poolingObjectQueue);
         return;
     }
     poolDictionary[info.prefab].Enqueue(clone);
 }
Esempio n. 13
0
        public GameObject GetPoolingObject(PoolingObjectInfo info, bool ignoreQueue = true)
        {
            GameObject obj;

            if (!poolDictionary.ContainsKey(info.prefab) || poolDictionary[info.prefab].Count == 0)
            {
                if (!ignoreQueue)
                {
                    return(null);
                }
                CreatePoolingObject(info);
            }
            obj = poolDictionary[info.prefab].Dequeue();
            obj.transform.position = new Vector3(info.position.x, info.position.y, Random.Range(0.0f, 1.0f));
            obj.gameObject.SetActive(true);
            obj.transform.rotation = info.objectRotation;
            return(obj);
        }
Esempio n. 14
0
        void Start()
        {
            spawnPositionCount = transform.childCount;
            infos          = new PoolingObjectInfo[spawnPositionCount];
            recycleObjects = new GameObject[spawnPositionCount];

            for (int i = 0; i < spawnPositionCount; i++)
            {
                infos[i] = new PoolingObjectInfo
                {
                    prefab         = prefab,
                    spawner        = gameObject,
                    position       = transform.GetChild(i).transform.position,
                    objectRotation = transform.rotation
                };
                ObjectPooler.instance.SetPoolingObject(infos[i]);
                if (!isTriggerSpawner && !isUpdateSpawner)
                {
                    recycleObjects[i] = ObjectPooler.instance.GetPoolingObject(infos[i]);
                }
            }

            //StartCoroutine("CheckSomething");
        }
Esempio n. 15
0
        IEnumerator CheckActivateTimeCoroutine(float objectActivateTime, PoolingObjectInfo info, GameObject poolingObject)
        {
            yield return(new WaitForSeconds(objectActivateTime));

            RecyclePoolingObject(info, poolingObject);
        }
Esempio n. 16
0
 protected void ActivatePoolingObject(float objectActivateTime, PoolingObjectInfo info, GameObject poolingObject)
 {
     StartCoroutine(CheckActivateTimeCoroutine(objectActivateTime, info, poolingObject));
 }
Esempio n. 17
0
 protected void RecyclePoolingObject(PoolingObjectInfo info, GameObject poolingObject)
 {
     ObjectPooler.instance.RecyclePoolingObject(info, poolingObject);
 }
Esempio n. 18
0
 protected void CreatePoolingObjectQueue(PoolingObjectInfo info, int size)
 {
     ObjectPooler.instance.CreatePoolingObjectQueue(info, size);
 }
Esempio n. 19
0
        protected GameObject GetPoolingObject(PoolingObjectInfo info)
        {
            GameObject poolingObject = ObjectPooler.instance.GetPoolingObject(info);

            return(poolingObject);
        }
Esempio n. 20
0
        public void OperateSpawn(PoolingObjectInfo info, float objectActivateTime)
        {
            GameObject poolingObject = ObjectPooler.instance.GetPoolingObject(info);

            ActivatePoolingObject(objectActivateTime, info, poolingObject);
        }
Esempio n. 21
0
 public void OperateSpawn(PoolingObjectInfo info)
 {
     GameObject poolingObject = ObjectPooler.instance.GetPoolingObject(info);
 }
Esempio n. 22
0
 protected void SetAutoSpawn(PoolingObjectInfo info, float objectActivateTime)
 {
     StartCoroutine(CheckAutoSpawnCoroutine(info, objectActivateTime));
 }
Esempio n. 23
0
 void Start()
 {
     info = SetPoolingObjectInfo(prefab, gameObject, gameObject.transform.position, transform.rotation);
     CreatePoolingObjectQueue(info, 10);
 }