public void GetsDifferentInstancesWhenPassingDifferentKeys() { var first = SingletonPool.GetInstance("key1", () => new ImportantThing()); var second = SingletonPool.GetInstance("key2", () => new ImportantThing()); Assert.That(ReferenceEquals(first.Instance, second.Instance), Is.False); }
protected override void OnAwake() { mvComponent = GetLogicalComponent <PlayerMovementComponent>(); ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>(); forceManager.AddManagerForce(gameObject.GetInstanceID(), GetComponent <Rigidbody2D>(), gameObject); }
public void GetsSameInstanceWhenPassingTheSameKey() { var first = SingletonPool.GetInstance("key", () => new ImportantThing()); var second = SingletonPool.GetInstance("key", () => new ImportantThing()); Assert.That(ReferenceEquals(first.Instance, second.Instance), Is.True); }
public void ChangeSlide(string nameSlider) { AudioManager audioManager = SingletonPool.Get <AudioManager>(); AudioEnum audioEnum = EnumExtend.ParseEnum <AudioEnum>(nameSlider); audioManager.SetVolume(audioEnum, sliders[audioEnum].value, true); }
private static void LogBuild(object obj) { if (GameObject.FindObjectOfType <DebugBuildManager>() == null) { CreateDebugBuild(); } SingletonPool.Get <DebugBuildManager>().Log(obj); }
public override void SetAction() { ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>(); transform.rotation = QuaternionExtend.CalculateRotation2D(Take <Vector2>("direction")); forceManager.EnableForce(gameObject.GetInstanceID()); forceManager.AddForce(gameObject.GetInstanceID(), "movement", Take <Vector2>("direction") * speed); }
private void OnDisable() { ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>(); if (forceManager) { forceManager.DisableForce(gameObject.GetInstanceID()); } }
private void SetMusicSlider() { AudioManager audioManager = SingletonPool.Get <AudioManager>(); Transform parent = transform.Find("OptionsPanel/"); sliders = new Dictionary <AudioEnum, Slider> { { AudioEnum.Music, parent.Find("SliderMusic").GetComponent <Slider>() }, { AudioEnum.SoundEffects, parent.Find("SliderEffects").GetComponent <Slider>() } }; sliders[AudioEnum.Music].value = audioManager.GetVolume(AudioEnum.Music); sliders[AudioEnum.SoundEffects].value = audioManager.GetVolume(AudioEnum.SoundEffects); }
// Use this for initialization void Awake() { m_EnemyPool = new Pool(m_EnemyPrefab, m_MaxEnemies, true); m_EnemyPool.ForEach(SetTargetPlayer); m_EnemyPool.ForEach(MakeChildOfEnemy); int longestWord = GetLongestWord(); EnemyBehavior.m_LongestWord = longestWord; SingletonPool.ForceInstantiate(m_BulletPrefab, longestWord * 2 * m_EnemyCountCap, true); SingletonPool.Instance.ForEach(MakeChildOfEnemy); Reset(); }
public void DisposesWhenLastReferenceIsDisposed() { var first = SingletonPool.GetInstance("key", () => new ImportantThing()); var second = SingletonPool.GetInstance("key", () => new ImportantThing()); Assert.That(first.Instance.IsDisposed, Is.False); first.Dispose(); Assert.That(first.Instance.IsDisposed, Is.False); second.Dispose(); Assert.That(first.Instance.IsDisposed, Is.True); }
public void SetMovement(Vector2 valueInput) { CalculateDirection(valueInput); SingletonPool.Get <ForceManagerSystem>().AddForce(ID, "movement", valueInput * speed); }
protected static GameManager GetIstance() { return(SingletonPool.Get <GameManager>()); }
public static void ForceInstantiate(GameObject forcedPrefab, int forcedLength, bool isGrowing = false) { m_instance = new SingletonPool(forcedPrefab, forcedLength, isGrowing); }
private static InputReaderManager GetIstance() { return(SingletonPool.Get <InputReaderManager>()); }
public override void SetAwake() { ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>(); forceManager.AddManagerForce(gameObject.GetInstanceID(), GetComponent <Rigidbody2D>()); }