Inheritance: MonoBehaviour
Esempio n. 1
0
        public void Init()
        {
            //Init Loot Pooler
            GameObject pool = GameObject.FindGameObjectWithTag("ScenePool");

            if (!pool)
            {
                Debug.LogError("NO SCENE POOL TRANSFORM FOUND IN SCENE");
            }
            _lootPool = new GenericPooler(pool ? pool.transform : null);


            List <LootConfig.LootDef> lootDefs = _lootConfig.lootDefs;

            for (int i = 0; i < lootDefs.Count; i++)
            {
                LootConfig.LootDef            def   = lootDefs[i];
                List <LootConfig.LootItemDef> items = def.lootItems;
                int warmAmount = def.pooledWarmAmount;
                for (int j = 0; j < items.Count; j++)
                {
                    LootConfig.LootItemDef item = items[j];
                    string type = Storeable.GetCachedStoreableKey(item.type);
                    _lootPool.InitPool(type, warmAmount, item.prefab);
                }
            }

            _dispatcher.AddListener(GameplayEventType.ENEMY_KILLED, OnEnemyDestroyed);
        }
Esempio n. 2
0
        public void Init()
        {
            //init building pool
            _gameplayCam   = GameObject.FindObjectOfType <GameplayCamera>();
            _gameBoard     = GameObject.FindObjectOfType <GameBoard>();
            _buildHologram = GameObject.Instantiate <BuildHologram>(_buildConfig.buildHologram);

            GameObject pool = GameObject.FindGameObjectWithTag("ScenePool");

            if (!pool)
            {
                Debug.LogError("NO SCENE POOL TRANSFORM FOUND IN SCENE");
            }
            _buildingGenerator = new GenericPooler(pool ? pool.transform : null);
            BuildConfig.BuildableBlueprint[] blueprints = _buildConfig.buildables;
            for (int i = 0; i < blueprints.Length; i++)
            {
                BuildConfig.BuildableBlueprint blueprint = blueprints[i];
                _buildingGenerator.InitPool(blueprint.GetKey(), 10, blueprint.prefab);
            }

            //UI
            _buildViewController = new BuildViewController(this, _inventorySystem, _buildConfig);

            //Build Cam
            //_buildCam = new BuildCam(_buildConfig,_gameplayCam);

            //init currenty build type
            SetBuildType(_buildConfig.startingBuildType);
        }
Esempio n. 3
0
    public void Init()
    {
        GameObject pool = GameObject.FindGameObjectWithTag("ScenePool");

        if (!pool)
        {
            Debug.LogError("NO SCENE POOL TRANSFORM FOUND IN SCENE");
        }
        _enemyPool = new GenericPooler(pool.transform);
        _enemyPool.InitPool(ENEMY, 0, _gameplayResources.basicEnemyView);
    }
Esempio n. 4
0
 void Spawn_Cube()
 {
     if (Is_Spawning == true)
     {
         pool_script = Cube_Pooler.GetComponent <GenericPooler> ();
         GameObject obj = pool_script.GetPooledObject();
         //GameObject obj = GenericPooler.current.GetPooledObject();
         if (obj == null)
         {
             return;
         }
         obj.transform.position = transform.position;
         obj.transform.rotation = transform.rotation;
         obj.SetActive(true);
         Active_Counter.CubesActive += 1;
     }
 }
Esempio n. 5
0
    void Start()
    {
        magazineKeytoIndex = new Dictionary <string, int>();

        for (int i = 0; i < bulletTypes.Length; i++)
        {
            Bullet bulletType = bulletTypes[i].GetComponent <Bullet>();
            if (bulletType == null)
            {
                // make sure all game objects are valid
                Debug.LogError(string.Format("added non bullet to bullet pool at index: {0}", i));
                return;
            }
            magazineKeytoIndex.Add(bulletType.MagazineKey, i);
            GenericPooler currentPool = ScriptableObject.CreateInstance <GenericPooler>();
            currentPool.Init(bulletTypes[i], 30);
            currentPool.allowedToGrow = true;
            bulletPool.Add(currentPool);
        }
    }
        /// <summary>
        /// Adds different particles of type (for example impact) to pool
        /// Particles are stored in different arrays in particle config for readability
        /// </summary>
        public void InitParticlePool()
        {
            var particleTypes = Enum.GetValues(typeof(Particle.Type));

            foreach (Particle.Type type in particleTypes)
            {
                Particle.sParticleTypeString[type] = type.ToString();
            }

            if (_particleConfig)
            {
                GameObject pool = GameObject.FindGameObjectWithTag("ScenePool");
                _particlePool = new GenericPooler(pool.transform);
                AddToPool(_particleConfig.particles);
            }
            else
            {
                Debug.LogError("Particle Config is null in the Particle God System");
            }
        }
Esempio n. 7
0
    void Awake()
    {
        current = this;
        poolDict = new Dictionary<string, List<GameObject>>();
        objPool = new List<GameObject>();

        foreach (var poolObj in pooledObjects)
        {
            // Clear the temporary list
            List<GameObject> tempPool = new List<GameObject>();

            for (int i = 0; i < pooledAmount; i++)
            {
                GameObject obj = (GameObject)Instantiate(poolObj);
                obj.SetActive(false);
                tempPool.Add(obj);
            }

            poolDict.Add(poolObj.name, tempPool);
        }
    }
Esempio n. 8
0
 // Use this for initialization
 void Awake()
 {
     current = this;
 }
Esempio n. 9
0
	void Awake () { current = this; }