GetPooledObject() 공개 메소드

public GetPooledObject ( string objType ) : GameObject
objType string
리턴 GameObject
예제 #1
0
        private void GenerateLoot(ILootable lootable)
        {
            LootConfig.LootDropDef lootDropDef = lootable._lootDropDef;

            List <LootConfig.ProbabilityDef> probabilities = lootDropDef.probabilities;

            probabilities.Sort(LootUtil.CompareLootByProbability);

            int   lootToDrop = LootUtil.GetLootDropCount(lootDropDef);
            float totalSum   = LootUtil.GetTotalSum(probabilities);

            for (int i = 0; i < lootToDrop; i++)
            {
                Loot.Rarity        rarity  = LootUtil.GetWeightedRarity(probabilities, totalSum);
                LootConfig.LootDef lootDef = _lootConfig.GetLootDef(rarity);
                int bucket = Random.Range(0, lootDef.lootItems.Count);
                LootConfig.LootItemDef itemDef = lootDef.lootItems[bucket];
                string    key  = Storeable.GetCachedStoreableKey(itemDef.type);
                ILootItem item = _lootPool.GetPooledObject(key).GetComponent <ILootItem>();
                if (item != null)
                {
                    item.Init(lootable, _playerCombatSystem.playerController.transform, lootDef, _lootConfig, itemDef);
                }
                else
                {
                    Debug.LogError("Item of type " + key + " does not implement  ILootItem");
                }
            }
        }
예제 #2
0
        private void BuildCoreLoop()
        {
            if (_builderRecharging)
            {
                return;
            }
            int  cost   = _buildConfig.GetCost(_currentBuildType);
            bool canBuy = _inventorySystem.CanBuy(Storeable.Type.Coin, cost);

            //Set our hologram position
            Ray ray = _gameplayCam.camera.ScreenPointToRay(Input.mousePosition);

            //IF WE ARE ON THE GAMEBOARD
            if (Physics.RaycastNonAlloc(ray, _hitResults, 100, _gameBoard.GetLayer()) > 0)
            {
                Vector3 hitPoint = _hitResults[0].point;
                seaLevelPos.x = hitPoint.x;
                seaLevelPos.z = hitPoint.z;
                GridPosition gridPos = GetHoloGramPosition(hitPoint);
                float        yOffset = _buildConfig.GetOffset(_currentBuildType);
                _buildHologram.SetPosition(gridPos, yOffset);
                Debug.DrawRay(hitPoint, Vector3.up, Color.blue);

                bool colliding = false;
                if (_collisionDetectionEnabled)
                {
                    Collider[] overlap = Physics.OverlapBox(_buildHologram.GetPosition(), (_buildHologram.GetScale() / 2.1f), Quaternion.identity, _buildConfig._collisionLayerMask);
                    colliding = overlap.Length > 0;
                    //if(colliding)
                    //{
                    //    Debug.Log(overlap[0].transform.name);
                    //}
                }



                _buildHologram.UpdateHologram(!colliding && canBuy, _buildConfig.hologramData);

                //TRY TO BUILD
                if (canBuy && !colliding && Input.GetKey(KeyCode.Mouse1))
                {
                    //BUILD!
                    BuildConfig.BuildableBlueprint blueprint = _buildConfig.GetBuildableBlueprint(_currentBuildType);
                    Buildable building = _buildingGenerator.GetPooledObject(blueprint.GetKey()) as Buildable;
                    building.Build(_buildHologram.GetPosition(), blueprint.buildTime, blueprint.fallHeight, blueprint.buildEaseType, blueprint);

                    _builderRecharging = true;
                    BuyBuildable(cost);
                }
            }
        }
예제 #3
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;
     }
 }
예제 #4
0
    public void AddEnemy(Transform target, Vector3 position)
    {
        EnemyView       enemyView = _enemyPool.GetPooledObject(ENEMY) as EnemyView;
        int             id        = enemyView.gameObject.GetInstanceID();
        EnemyController enemy;

        if (!_lookup.ContainsKey(id))
        {
            enemy = new EnemyController(_enemyDef, enemyView, target);

            _enemyList.Add(enemy);
            _lookup.Add(id, enemy);
        }
        else
        {
            enemy = _lookup[id];
        }

        enemy.Init();
        enemy.position = position;

        _enemyList.Sort(EnemyUtil.CompareEnemiesByHealth);
    }