Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
        protected override void OnAwake()
        {
            mvComponent = GetLogicalComponent <PlayerMovementComponent>();
            ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>();

            forceManager.AddManagerForce(gameObject.GetInstanceID(), GetComponent <Rigidbody2D>(), gameObject);
        }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
        public void ChangeSlide(string nameSlider)
        {
            AudioManager audioManager = SingletonPool.Get <AudioManager>();
            AudioEnum    audioEnum    = EnumExtend.ParseEnum <AudioEnum>(nameSlider);

            audioManager.SetVolume(audioEnum, sliders[audioEnum].value, true);
        }
Ejemplo n.º 5
0
 private static void LogBuild(object obj)
 {
     if (GameObject.FindObjectOfType <DebugBuildManager>() == null)
     {
         CreateDebugBuild();
     }
     SingletonPool.Get <DebugBuildManager>().Log(obj);
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        private void OnDisable()
        {
            ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>();

            if (forceManager)
            {
                forceManager.DisableForce(gameObject.GetInstanceID());
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
    // 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();
    }
Ejemplo n.º 10
0
    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);
    }
Ejemplo n.º 11
0
 public void SetMovement(Vector2 valueInput)
 {
     CalculateDirection(valueInput);
     SingletonPool.Get <ForceManagerSystem>().AddForce(ID, "movement", valueInput * speed);
 }
Ejemplo n.º 12
0
 protected static GameManager GetIstance()
 {
     return(SingletonPool.Get <GameManager>());
 }
Ejemplo n.º 13
0
 public static void ForceInstantiate(GameObject forcedPrefab, int forcedLength, bool isGrowing = false)
 {
     m_instance = new SingletonPool(forcedPrefab, forcedLength, isGrowing);
 }
Ejemplo n.º 14
0
 private static InputReaderManager GetIstance()
 {
     return(SingletonPool.Get <InputReaderManager>());
 }
Ejemplo n.º 15
0
        public override void SetAwake()
        {
            ForceManagerSystem forceManager = SingletonPool.Get <ForceManagerSystem>();

            forceManager.AddManagerForce(gameObject.GetInstanceID(), GetComponent <Rigidbody2D>());
        }