Пример #1
0
    void Awake()
    {
        director = SSDirector.getInstance();
        director.currentSceneController = this;
        director.currentSceneController.LoadResources();
        director.currentSceneController.CreatePatrols();

        sc  = director.currentSceneController as IHandle;
        sub = player.GetComponent <Player>();
        sub.AddListener(sc);
        ani     = player.GetComponent <Animator>();
        isStart = false;
    }
Пример #2
0
    public void CreatePatrols()
    {
        PatrolFactory patrolFactory = Singleton <PatrolFactory> .Instance;

        for (int i = 0; i < 6; i++)
        {
            GameObject patrol = patrolFactory.getPatrol();
            patrol.name = "Patrol" + i;
            sub         = player.GetComponent <Player>();
            sub.AddListener(patrol.GetComponent <Patrol>());
            patrol.GetComponent <Patrol>().register(GetComponent <ScoreRecorder>().addScore);
        }
    }
Пример #3
0
        public void SubjectUpdatesListeners()
        {
            Subject     subject  = new Subject();
            FooListener listener = new FooListener();

            subject.AddListener(listener);

            Assert.AreEqual(listener.OldValue, 0);
            Assert.AreEqual(listener.NewValue, 0);

            subject.SetValue(10);

            Assert.AreEqual(listener.OldValue, 0);
            Assert.AreEqual(listener.NewValue, 10);

            subject.SetValue(20);

            Assert.AreEqual(listener.OldValue, 10);
            Assert.AreEqual(listener.NewValue, 20);
        }