コード例 #1
0
ファイル: PlayerFire.cs プロジェクト: leamzi/WJ2017
    private void setBulletPool()
    {
        if (bullets == null)
        {
            bullets = new List <GameObject>();
        }

        switch (GameGlobalVariables.Instance.currentBulletType)
        {
        case GameGlobalVariables.PlayerBulletType.BULLET_FORK:
            bulletPool = FastPoolManager.GetPool(GameGlobalVariables.bulletType.bulletForkID, null, false);
            break;

        case GameGlobalVariables.PlayerBulletType.BULLET_KNIFE:
            bulletPool = FastPoolManager.GetPool(GameGlobalVariables.bulletType.bulletKnifeID, null, false);
            break;

        case GameGlobalVariables.PlayerBulletType.BULLET_MIXER:
            bulletPool = FastPoolManager.GetPool(GameGlobalVariables.bulletType.bulletMixerID, null, false);
            break;

        case GameGlobalVariables.PlayerBulletType.BULLET_CUTTER:
            bulletPool = FastPoolManager.GetPool(GameGlobalVariables.bulletType.bulletCutterID, null, false);
            break;
        }
        //print("Setting Bullet pool: " + GameGlobalVariables.Instance.currentBulletType.ToString());
    }
コード例 #2
0
ファイル: BasicUnit.cs プロジェクト: andrewstarnes/wwtd2
		void Start() 
		{
			if(healthBarPool==null) {
				healthBarPool = FastPoolManager.GetPool(healthBarPrefab,true);
			}
			if(canvas==null) {
				canvas = GameObject.Find ("Canvas");
			
			}


			setupUnit();
			
			if(this.flying==false) {
				UnitFacade u = (UnitFacade) this.GetUnitFacade();
				GameObject exit = GameObject.Find("CreepExit");
				u.MoveTo(exit.transform.position,false);
			}
			if(!GameManager.REF.demo) {
				GameObject child = NGUITools.AddChild(CreepSpawner.hudRoot, this.hudTextPrefab);
				mText = child.GetComponent<HUDText>();
			
				// Make the UI follow the target
				child.AddComponent<UIFollowTarget>().target = this.transform;
			}

		}
コード例 #3
0
ファイル: Lightning.cs プロジェクト: Crazy0wl/Magnet_Balls_2
 public void Init(FastPool pool)
 {
     this.pool = pool;
     if (!line)
     {
         line = GetComponent <LineRenderer>();
     }
 }
コード例 #4
0
ファイル: FactoryManager.cs プロジェクト: yabos/SaveTheQueen
 public int CreatePoolCache <T>(GameObject gameObject, bool warmOnLoad = false, int preloadCount = 0, int capacity = 0) where T : Component
 {
     if (gameObject != null)
     {
         FastPool fastPool = m_fastPoolFactory.CreatePoolC <T>(gameObject, warmOnLoad, preloadCount, capacity);
         return(fastPool.ID);
     }
     return(-1);
 }
コード例 #5
0
ファイル: FactoryManager.cs プロジェクト: yabos/SaveTheQueen
 public int CreatePoolCache(GameObject gameObject, int preloadCount, int capacity)
 {
     if (gameObject != null)
     {
         FastPool fastPool = m_fastPoolFactory.CreatePool(gameObject, false, preloadCount, capacity);
         return(fastPool.ID);
     }
     return(-1);
 }
コード例 #6
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public GameObject CreatePoolObject(GameObject poolGameObject, Vector3 position, Quaternion rotation, Transform parentTransform, bool active)
        {
            FastPool fastPool = GetPool(poolGameObject.GetInstanceID());

            if (fastPool != null)
            {
                return(fastPool.FastInstantiate(active, position, rotation, parentTransform));
            }
            return(null);
        }
コード例 #7
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        /// <summary>
        /// Returns pool for the specified prefab or creates it if needed (with default params)
        /// </summary>
        /// <param name="component">Any component of the source prefab</param>
        /// <returns></returns>
        //public FastPool GetPool(Component component, Transform parent, bool createIfNotExists = true)
        //{
        //    if (component != null)
        //    {
        //        GameObject prefab = component.gameObject;
        //        if (m_pools.ContainsKey(prefab.GetInstanceID()))
        //            return m_pools[prefab.GetInstanceID()];
        //        else
        //            return CreatePool(prefab, parent);
        //    }
        //    else
        //    {
        //        Debug.LogError("Trying to get pool for null object");
        //        return null;
        //    }
        //}


        public GameObject CreatePoolObject(int prefabHash, Vector3 position, Quaternion rotation, Transform parentTransform, bool active)
        {
            FastPool fastPool = GetPool(prefabHash);

            if (fastPool != null)
            {
                return(fastPool.FastInstantiate(active, position, rotation, parentTransform));
            }
            return(null);
        }
コード例 #8
0
    // Use this for initialization
    protected override void Start()
    {
        Time.timeScale = 1;
        base.Start();

        powerupWeaponPool = FastPoolManager.GetPool(GameGlobalVariables.gamePowerupType.powerupWeaponID, null, false);
        SoundManager.instance.PlayBgm(GameGlobalVariables.BGM_GAMEPLAY);

        StartCoroutine(spawnPowerupWeapon());
    }
コード例 #9
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public void DestroyPool(int InstanceID)
        {
            FastPool fastPool = GetPool(InstanceID);

            if (fastPool != null)
            {
                fastPool.ClearCache();
                DestroyPoolFactory(fastPool.ID);
                m_pools.Remove(fastPool.ID);
            }
        }
コード例 #10
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public T CreatePoolComponent <T>(int poolHash, Vector3 position, Quaternion rotation, Transform parentTransform, bool active) where T : Component
        {
            FastPool fastPool = GetPool(poolHash);

            if (fastPool == null)
            {
                return(null);
            }

            return(fastPool.FastInstantiate <T>(active, position, rotation, parentTransform));
        }
コード例 #11
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public T CreatePoolComponent <T>(GameObject prefab, Vector3 position, Quaternion rotation, Transform parentTransform, bool active) where T : Component
        {
            FastPool fastPool = GetPool(prefab.GetInstanceID());

            if (fastPool == null)
            {
                fastPool = CreatePoolC <T>(prefab);
            }

            return(fastPool.FastInstantiate <T>(active, position, rotation, parentTransform));
        }
コード例 #12
0
 private Effect GetEffect(string name, Vector2 pos)
 {
     if (inited)
     {
         FastPool p = null;
         if (effectsPool.TryGetValue(name, out p))
         {
             Effect result = p.FastInstantiate <Effect>(pos, Quaternion.identity, transform);
             result.Init(p);
             return(result);
         }
     }
     return(null);
 }
コード例 #13
0
ファイル: AdvancedSpawn.cs プロジェクト: andrewstarnes/wwtd2
    void Start()
    {
        hugeObjectsArray = new GameObject[1000];

        //Create a new pool for our sampleGameObject clones and let him to preload 1000 clones
        fastPool = FastPoolManager.CreatePool(sampleGameObject, true, 1000);


        //Or you may don't use the FastPoolManager and create and manage pool by yourself.
        //If you make your FastPool variable public - it will be visible at the inspector 
        //with the same UI as in the FastPoolManager. Look "Without Manager" example for details.
        //
        //fastPool = new FastPool(sampleGameObject, null, true, 1000);
    }
コード例 #14
0
ファイル: AdvancedSpawn.cs プロジェクト: EastNightmare/ZZRun
    void Start()
    {
        hugeObjectsArray = new GameObject[1000];

        //Create a new pool for our sampleGameObject clones and let him to preload 1000 clones
        fastPool = FastPoolManager.CreatePool(sampleGameObject, true, 1000);


        //Or you may don't use the FastPoolManager and create and manage pool by yourself.
        //If you make your FastPool variable public - it will be visible at the inspector
        //with the same UI as in the FastPoolManager. Look "Without Manager" example for details.
        //
        //fastPool = new FastPool(sampleGameObject, null, true, 1000);
    }
コード例 #15
0
 private BaseBonus InstantiateBonus(Ball ball, Vector3 force, float delay)
 {
     if (inited)
     {
         FastPool p = null;
         if (ballTypesPool.TryGetValue(ball.BallType, out p))
         {
             BaseBonus result = p.FastInstantiate <BaseBonus>(ball.Pos, Quaternion.identity, transform);
             result.Emit(ball, p, force, delay);
             return(result);
         }
     }
     return(null);
 }
コード例 #16
0
 private Coin GetCoinEffect(BallColor col, Vector2 pos)
 {
     if (inited)
     {
         FastPool p = null;
         if (coinsPool.TryGetValue(col, out p))
         {
             Coin result = p.FastInstantiate <Coin>(pos, Quaternion.identity, transform);
             result.Init(p);
             return(result);
         }
     }
     return(null);
 }
コード例 #17
0
ファイル: SimpleSpawn.cs プロジェクト: EastNightmare/ZZRun
    public void DestroyObjects()
    {
        //lets despawn our 1000 objects
        for (int i = 0; i < 1000; i++)
        {
            //Get the pool for our source game object.
            //If it's not exists - it will be created automatically with default settings.
            //Note that you must always provide the SOURCE game object and NOT a clone!
            FastPool fastPool = FastPoolManager.GetPool(sampleGameObject);

            //Cache our clone.
            fastPool.FastDestroy(hugeObjectsArray[i]);


            //Or you can do it all in one line:
            //  FastPoolManager.GetPool(sampleGameObject).FastDestroy(hugeObjectsArray[i]);
        }
    }
コード例 #18
0
    public void DestroyObjects()
    {
        //lets despawn our 1000 objects
        for (int i = 0; i < 1000; i++)
        {
            //Get the pool for our custom pool ID.
            //If pool for this id does not exist and you want it will be created automatically - then provide the sourcePrefab
            //and set "createIfNotExists" to true.
            //Otherwise you can set prefab parameter as null (in this case "createIfNotExists" must be false)
            FastPool fastPool = FastPoolManager.GetPool(1, null, false);

            //Cache our clone.
            fastPool.FastDestroy(hugeObjectsArray[i]);


            //Or you can do it all in one line:
            //  FastPoolManager.GetPool(1, null, false).FastDestroy(hugeObjectsArray[i]);
        }
    }
コード例 #19
0
ファイル: SimpleSpawn.cs プロジェクト: EastNightmare/ZZRun
    public void Spawn()
    {
        //lets spawn 1000 objects
        for (int i = 0; i < 1000; i++)
        {
            //First of all we need to get the pool for our source game object.
            //If it's not exists - it will be created automatically with default settings.
            //Note that you must always provide the SOURCE game object and NOT a clone!
            FastPool fastPool = FastPoolManager.GetPool(sampleGameObject);

            //Just spawn a clone and remember it.
            //If pool has cached objects - it will quickly activate it instead of instantiating a new one.
            hugeObjectsArray[i] = fastPool.FastInstantiate();


            //Or you can do it all in one line:
            //  hugeObjectsArray[i] = FastPoolManager.GetPool(sampleGameObject).FastInstantiate();
        }
    }
コード例 #20
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        /// <summary>
        /// Create a new pool from provided prefab
        /// </summary>
        /// <param name="prefab">Prefab that will be cloned</param>
        /// <param name="preloadCount">How much items must be preloaded and cached</param>
        /// <param name="capacity">Cache size (maximum amount of the cached items). [0 - unlimited]</param>
        /// <param name="warmOnLoad">Load source prefab in the memory while scene is loading. A bit slower scene loading, but much faster instantiating of new objects in pool</param>
        /// <returns>FastPool instance</returns>
        public FastPool CreatePool(GameObject prefab, bool warmOnLoad = false, int preloadCount = 0, int capacity = 0)
        {
            if (prefab != null)
            {
                if (m_pools.ContainsKey(prefab.GetInstanceID()) == false)
                {
                    Transform poolTransform = CreatePoolFactory(prefab);

                    FastPool newPool = new FastPool(prefab, poolTransform, warmOnLoad, preloadCount, capacity);
                    m_pools.Add(prefab.GetInstanceID(), newPool);
                    newPool.Init();
                    return(newPool);
                }

                return(m_pools[prefab.GetInstanceID()]);
            }

            Debug.LogError("Creating pool with null object");
            return(null);
        }
コード例 #21
0
    public void Spawn()
    {
        //lets spawn 1000 objects
        for (int i = 0; i < 1000; i++)
        {
            //First of all we need to get the pool for our custom pool ID.
            //If pool for this id does not exist and you want it will be created automatically - then provide the sourcePrefab
            //and set "createIfNotExists" to true.
            //Otherwise you can set prefab parameter as null (in this case "createIfNotExists" must be false)
            FastPool fastPool = FastPoolManager.GetPool(1, null, false);

            //Just spawn a clone and remember it.
            //If pool has cached objects - it will quickly activate it instead of instantiating a new one.
            hugeObjectsArray[i] = fastPool.FastInstantiate();


            //Or you can do it all in one line:
            //  hugeObjectsArray[i] = FastPoolManager.GetPool(sampleGameObject).FastInstantiate();
        }
    }
コード例 #22
0
 /// <summary>
 /// Create a new pool from provided prefab
 /// </summary>
 /// <param name="prefab">Prefab that will be cloned</param>
 /// <param name="preloadCount">How much items must be preloaded and cached</param>
 /// <param name="capacity">Cache size (maximum amount of the cached items). [0 - unlimited]</param>
 /// <param name="warmOnLoad">Load source prefab in the memory while scene is loading. A bit slower scene loading, but much faster instantiating of new objects in pool</param>
 /// <returns>FastPool instance</returns>
 public static FastPool CreatePool(GameObject prefab, bool warmOnLoad = true, int preloadCount = 0, int capacity = 0)
 {
     if (prefab != null)
     {
         if (!Instance.pools.ContainsKey(prefab.GetInstanceID()))
         {
             FastPool newPool = new FastPool(prefab, Instance.curTransform, warmOnLoad, preloadCount, capacity);
             Instance.pools.Add(prefab.GetInstanceID(), newPool);
             return(newPool);
         }
         else
         {
             return(Instance.pools[prefab.GetInstanceID()]);
         }
     }
     else
     {
         Debug.LogError("Creating pool with null object");
         return(null);
     }
 }
コード例 #23
0
 public static void FastDestroy(this GameObject objectToDestroy, FastPool pool)
 {
     pool.FastDestroy(objectToDestroy);
 }
コード例 #24
0
	public void Start() {
		if(blastObjectPool==null||blastObjectPool.ID==0) {
			blastObjectPool = FastPoolManager.GetPool(blastObjectPrefab,true);
		}
	}
コード例 #25
0
ファイル: BaseBonus.cs プロジェクト: Crazy0wl/Magnet_Balls_2
 public virtual void Emit(Ball ball, FastPool pool, Vector2 force, float delay)
 {
     this.pool = pool;
     this.ball = ball;
     StartCoroutine(EnableParticlesRoutine(delay));
 }
コード例 #26
0
 /// <summary>
 /// Destroys provided pool and it's cached objects
 /// </summary>
 /// <param name="pool">Pool to destroy</param>
 public static void DestroyPool(FastPool pool)
 {
     pool.ClearCache();
     Instance.pools.Remove(pool.ID);
 }
コード例 #27
0
        private void initDictionary()
        {
            if (!inited)
            {
                coinsPool[BallColor.White]  = FastPoolManager.CreatePool(Coin1Prefab);
                coinsPool[BallColor.Black]  = FastPoolManager.CreatePool(Coin2Prefab);
                coinsPool[BallColor.Red]    = FastPoolManager.CreatePool(Coin5Prefab);
                coinsPool[BallColor.Green]  = FastPoolManager.CreatePool(Coin10Prefab);
                coinsPool[BallColor.Blue]   = FastPoolManager.CreatePool(Coin20Prefab);
                coinsPool[BallColor.Yellow] = FastPoolManager.CreatePool(Coin50Prefab);
                coinsPool[BallColor.Aqua]   = FastPoolManager.CreatePool(Coin100Prefab);

                foreach (GameObject o in BonusPrefabs)
                {
                    BaseBonus e = o.GetComponent <BaseBonus>();
                    ballTypesPool[e.BonusType] = FastPoolManager.CreatePool(o);
                }

                foreach (GameObject o in EffectsPrefabs)
                {
                    effectsPool[o.name] = FastPoolManager.CreatePool(o);
                }
                lightningPool = FastPoolManager.CreatePool(LightningPrefab);

                ColorFigureSprites = new Dictionary <BallColor, Sprite>();
                ColorFigureSprites[BallColor.Black]  = Black;
                ColorFigureSprites[BallColor.White]  = White;
                ColorFigureSprites[BallColor.Green]  = Green;
                ColorFigureSprites[BallColor.Aqua]   = Aqua;
                ColorFigureSprites[BallColor.Red]    = Red;
                ColorFigureSprites[BallColor.Blue]   = Blue;
                ColorFigureSprites[BallColor.Yellow] = Yellow;

                BallTypeSprites = new Dictionary <BallType, Sprite>();
                BallTypeSprites[BallType.Simple]    = Simple;
                BallTypeSprites[BallType.Chameleon] = Chameleon;
                BallTypeSprites[BallType.Freeze]    = Freeze;
                BallTypeSprites[BallType.Brush]     = Brush;
                BallTypeSprites[BallType.Bomb]      = Bomb;
                BallTypeSprites[BallType.Lightning] = Lightning;
                BallTypeSprites[BallType.Anchored]  = Anchored;
                BallTypeSprites[BallType.Anchor]    = Anchor;
                BallTypeSprites[BallType.Aim]       = Aim;

                BallTypeSprites[BallType.Bubble]  = Bubble;
                BallTypeSprites[BallType.Frozen]  = Frozen;
                BallTypeSprites[BallType.Crashed] = Crashed;
                BallTypeSprites[BallType.Rust]    = Rust;

                BallColors = new Dictionary <BallColor, Color32>();
                BallColors[BallColor.White]  = WhiteColor;
                BallColors[BallColor.Black]  = BlackColor;
                BallColors[BallColor.Green]  = GreenColor;
                BallColors[BallColor.Aqua]   = AquaColor;
                BallColors[BallColor.Red]    = RedColor;
                BallColors[BallColor.Blue]   = BlueColor;
                BallColors[BallColor.Yellow] = YellowColor;
                BallColors[BallColor.None]   = Color.white;

                BallsPool = FastPoolManager.GetPool(BallPrefab);

                colors    = new BallColor[8];
                colors[0] = BallColor.White;
                colors[1] = BallColor.Black;
                colors[2] = BallColor.Green;
                colors[3] = BallColor.Aqua;
                colors[4] = BallColor.Red;
                colors[5] = BallColor.Blue;
                colors[6] = BallColor.Yellow;
                inited    = true;
            }
        }
コード例 #28
0
ファイル: MF_BasicWeapon.cs プロジェクト: andrewstarnes/wwtd2
	public void Start () {
		if (CheckErrors() == true) { return; }
		

		
		if(this.shot.ID==0) {
			this.shot = FastPoolManager.GetPool(this.shotPrefab,true);
		}  
		GameObject g = this.shot.TryGetNextObject(Vector3.zero,Quaternion.identity);
		useGravity = g.GetComponent<Rigidbody>().useGravity;
		Destroy(g);

		curAmmoCount = maxAmmoCount;
		
		// find muzzle flash particle systems
		for (int f=0; f < exits.Length; f++) {
			if ( exits[f].transform.childCount == 1 ) { // check for child
				exits[f].flare = exits[f].transform.GetChild(0).gameObject;
				exits[f].particleComponent = exits[f].flare.GetComponent<ParticleSystem>();
				exits[f].particleComponent.Stop(true);
			}
		}
	}
コード例 #29
0
 public void Init(FastPool pool)
 {
     this.pool = pool;
 }
コード例 #30
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
 /// <summary>
 /// Destroys provided pool and it's cached objects
 /// </summary>
 /// <param name="pool">Pool to destroy</param>
 public void DestroyPool(FastPool pool)
 {
     pool.ClearCache();
     DestroyPoolFactory(pool.ID);
     m_pools.Remove(pool.ID);
 }
コード例 #31
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public void FastDestroy(int InstanceID, GameObject sceneObject)
        {
            FastPool fastPool = GetPool(InstanceID);

            fastPool.FastDestroy(sceneObject);
        }
コード例 #32
0
 public static void FastDestroy(this GameObject objectToDestroy, FastPool pool)
 {
     pool.FastDestroy(objectToDestroy);
 }
コード例 #33
0
 public override void Emit(Ball ball, FastPool pool, Vector2 force, float delay)
 {
     base.Emit(ball, pool, force, delay);
     StartCoroutine(EmitRoutine(delay));
 }
コード例 #34
0
ファイル: FastPoolFactory.cs プロジェクト: yabos/SaveTheQueen
        public void FastDestroy <T>(int InstanceID, T sceneObject) where T : Component
        {
            FastPool fastPool = GetPool(InstanceID);

            fastPool.FastDestroy(sceneObject);
        }