Esempio n. 1
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action <bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            if (presenter.Equals(_currentPresenter))
            {
                completed(true);
                return;
            }

            if (_currentPresenter != null)
            {
                _currentPresenter.Deactivate();
            }

            presenter = EnsurePresenter(presenter);

            if (IsActive)
            {
                presenter.Activate();
            }

            ChangeCurrentPresenterCore(presenter);

            completed(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Activates this instance.
        /// </summary>
        public override void Activate()
        {
            if (!IsActive)
            {
                if (_currentPresenter != null)
                {
                    _currentPresenter.Activate();
                }

                OnActivate();
                IsActive = true;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action <bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            presenter = EnsurePresenter(presenter);

            if (IsActive)
            {
                presenter.Activate();
            }

            completed(true);
        }
Esempio n. 4
0
    private void Awake()
    {
        ISerializer   serializer    = new JsonNetSerializer();
        UdpClientInfo udpClientInfo = new UdpClientInfo
        {
            ServerIp   = "127.0.0.1",
            ServerPort = 3000,
            ChannelId  = 0
        };
        WorldData           worldData          = new WorldData();
        IModelManagerClient modelManagerClient = new ModelManagerClient(worldData);
        IReplication        worldReplication   = new WorldReplication(worldData, serializer.GetCaster());

        _client         = new UdpClient(udpClientInfo);
        _networkManager = new NetworkManager(_client, serializer, modelManagerClient, worldReplication)
        {
            MillisecondsBetweenSendPacket = 1000
        };
        _presenterManager = new GamePresenter(_viewManager, modelManagerClient);

        _presenterManager.Activate();
    }
Esempio n. 5
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action <bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            if (presenter.Equals(_currentPresenter))
            {
                completed(true);
                return;
            }

            Action successfulCompletion =
                () =>
            {
                var node = presenter as IPresenterNode;
                if (node != null)
                {
                    node.Parent = this;
                }

                if (IsInitialized)
                {
                    presenter.Initialize();
                }

                if (IsActive)
                {
                    presenter.Activate();
                }

                ChangeCurrentPresenterCore(presenter);

                completed(true);
            };

            if (_currentPresenter != null)
            {
                CanShutdownPresenter(
                    _currentPresenter,
                    isSuccess =>
                {
                    if (!isSuccess)
                    {
                        completed(false);
                        return;
                    }

                    _currentPresenter.Deactivate();
                    _currentPresenter.Shutdown();

                    var node = _currentPresenter as IPresenterNode;
                    if (node != null)
                    {
                        node.Parent = null;
                    }

                    successfulCompletion();
                });
            }
            else
            {
                successfulCompletion();
            }
        }
Esempio n. 6
0
        public void ActivateScreenFor <T>() where T : IPresenter
        {
            IPresenter presenter = ObjectFactory.GetInstance <T>();

            presenter.Activate();
        }
Esempio n. 7
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action<bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            if (presenter.Equals(_currentPresenter))
            {
                completed(true);
                return;
            }

            Action successfulCompletion =
                () =>
                {
                    var node = presenter as IPresenterNode;
                    if (node != null) node.Parent = this;

                    if (IsInitialized)
                        presenter.Initialize();

                    if (IsActive)
                        presenter.Activate();

                    ChangeCurrentPresenterCore(presenter);

                    completed(true);
                };

            if (_currentPresenter != null)
            {
                CanShutdownPresenter(
                    _currentPresenter,
                    isSuccess =>
                    {
                        if (!isSuccess)
                        {
                            completed(false);
                            return;
                        }

                        _currentPresenter.Deactivate();
                        _currentPresenter.Shutdown();

                        var node = _currentPresenter as IPresenterNode;
                        if (node != null) node.Parent = null;

                        successfulCompletion();
                    });
            }
            else successfulCompletion();
        }
Esempio n. 8
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action<bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            if (presenter.Equals(_currentPresenter))
            {
                completed(true);
                return;
            }

            if (_currentPresenter != null)
                _currentPresenter.Deactivate();

            presenter = EnsurePresenter(presenter);

            if (IsActive)
                presenter.Activate();

            ChangeCurrentPresenterCore(presenter);

            completed(true);
        }
Esempio n. 9
0
        /// <summary>
        /// Opens the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="completed">Called when the open action is finished.</param>
        public virtual void Open(IPresenter presenter, Action<bool> completed)
        {
            if (presenter == null)
            {
                completed(false);
                return;
            }

            presenter = EnsurePresenter(presenter);

            if (IsActive)
                presenter.Activate();

            completed(true);
        }