public void Start() { GlobalState.EventService.AddEventHandler <PowerUpAppliedEvent>(OnApplied); var config = GlobalState.Instance.Config.bubbles; screenXBound = (config.numPerRow / 2) * config.size; overlayPool.Allocate(overlayPrefab, 7); }
public void Preload(AnimationType type, int count) { var definition = GetDefinitionByType(type); animationPool.Allocate(definition.Prefab, count, (prefab) => { var instance = animationPool.DefaultAllocator(prefab); HidePooledObject(instance); return(instance); }); }
public static int Allocate(IntPtr l) { int result; try { GameObjectPool gameObjectPool = (GameObjectPool)LuaObject.checkSelf(l); GameObject o = gameObjectPool.Allocate(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
/// <summary> /// Create the splash that will play on the surface /// </summary> /// <param name="rPosition"></param> public void CreateSplash(Vector3 rPosition) { if (SplashPrefab != null) { //GameObject lSplash = GameObject.Instantiate(Resources.Load(mSplashPath)) as GameObject; GameObject lSplash = GameObjectPool.Allocate(SplashPrefab); if (lSplash != null) { ParticleCore lSplashCore = lSplash.GetComponent <ParticleCore>(); lSplashCore.Prefab = SplashPrefab; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } lSplash.transform.position = rPosition; } } }
/// <summary> /// Create the underwater effect. Keep it alive as long as it's active /// </summary> /// <param name="rAnimator">Mecanim animator this swimmer is tied to</param> /// <param name="rBone">Bone the effect is to play from</param> public void CreateUnderwaterEffect(Animator rAnimator, HumanBodyBones rBone) { if (mUnderwaterCore == null) { if (UnderwaterPrefab != null) { //GameObject lUnderwater = GameObject.Instantiate(Resources.Load(mUnderwaterPath)) as GameObject; GameObject lUnderwater = GameObjectPool.Allocate(UnderwaterPrefab); if (lUnderwater != null) { Vector3 lPosition = Vector3.zero; if (rAnimator != null) { Transform lBone = rAnimator.GetBoneTransform(rBone); if (lBone != null) { lPosition = lBone.position; } } mUnderwaterCore = lUnderwater.GetComponent <ParticleCore>(); mUnderwaterCore.Prefab = UnderwaterPrefab; mUnderwaterCore.OnReleasedEvent = OnUnderwaterReleased; mUnderwaterCore.Transform.parent = mActorController._Transform; mUnderwaterCore.Transform.position = lPosition; } } } else { mUnderwaterCore.Age = 0f; if (rAnimator != null) { Transform lBone = rAnimator.GetBoneTransform(rBone); if (lBone != null) { mUnderwaterCore.Transform.position = lBone.position; } } } }
/// <summary> /// Create the ripples that will play on the surface. I the ripples exist, /// we'll simply keep them alive /// </summary> /// <param name="rPosition"></param> public void CreateRipples(Vector3 rPosition) { if (mRipplesCore == null) { if (RipplesPrefab != null) { //GameObject lRipples = GameObject.Instantiate(RipplesPrefab) as GameObject; GameObject lRipples = GameObjectPool.Allocate(RipplesPrefab); if (lRipples != null) { mRipplesCore = lRipples.GetComponent <ParticleCore>(); if (mRipplesCore != null) { mRipplesCore.Prefab = RipplesPrefab; mRipplesCore.OnReleasedEvent = OnRipplesReleased; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } mRipplesCore.Transform.position = rPosition; } } } } else { mRipplesCore.Age = 0f; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } mRipplesCore.Transform.position = rPosition; } }