Beispiel #1
0
        public void BroadcastMessagesTests()
        {
            var publisher   = new Publisher();
            var subscriber1 = new News();
            var subscriber2 = new Announcement();

            publisher.AddSubscriber(subscriber1);
            publisher.AddSubscriber(subscriber2);

            var message = new Message(MessageType.Announcement)
            {
                Title   = "Test Message",
                Content = "Lorem ipsum dolor sit amelur..."
            };

            publisher.PublishAnnouncement(message);
            Assert.AreEqual(1, publisher.MessageCount);
        }
Beispiel #2
0
    void Start()
    {
        DontDestroyOnLoad(gameObject);            // Команда Unity для сохранения объекта между сценами.

        publisher    = new Publisher();
        saveManager  = new SaveManager();
        gameManager  = new GameManager();
        animaManager = new AnimaManager();
        //logicManager = new LogicManager();
        //loadManager = new LoadManager(_logicManager);

        var            menuObject     = GameObject.FindWithTag("SceneController");
        ControllerMenu controllerMenu = menuObject.GetComponent <ControllerMenu>();

        if (controllerMenu == null)
        {
            throw new UnityException("There is no ControllerMenu script on UI object");
        }

        var buttonObject = GameObject.Find("btnStart");
        MouseClickHandler clickHandler = buttonObject.GetComponent <MouseClickHandler>();

        if (clickHandler == null)
        {
            throw new UnityException("There is no MouseClickHandler script on UI object");
        }

        UiButtonsMenu uiButtonsMenu = buttonObject.GetComponent <UiButtonsMenu>();

        if (clickHandler == null)
        {
            throw new UnityException("There is no MouseClickHandler script on UI object");
        }

        // Set dependencies
        clickHandler.SetDependecies(animaManager);
        uiButtonsMenu.SetDependecies(saveManager, animaManager);
        controllerMenu.SetDependecies(saveManager);
        publisher.AddSubscriber(saveManager);
    }