Transformer() public method

Constructor for the Transformer object. This is used to create a transformer which will transform specified types using transforms loaded from the class path. Transforms are matched to types using the specified matcher object.
public Transformer ( Matcher matcher ) : SimpleFramework.Xml.Util
matcher Matcher /// this is used to match types to transforms ///
return SimpleFramework.Xml.Util
Exemplo n.º 1
0
        public override void Draw(GameTime gameTime)
        {
            WithZoom(zoom, (b) =>
            {
                base.Draw(gameTime);
                _inputChat.Draw(gameTime);
                // Stop drawing
                if (ChatLines.Count <= 0)
                {
                    SpriteBatch.End();
                    return;
                }
                int count = 0;
                _chatLinesFont.Position = _initialLinePos;

                // Go to every line
                foreach (ChatMessage line in ChatLines)
                {
                    _chatLinesFont.Text  = line.Text;
                    _chatLinesFont.Color = line.Color;

                    if (count > 0) // Passed the first
                    {
                        _chatLinesFont.Alpha    = 1.0F;
                        _chatLinesFont.Position = Positioner.GetSideBy(_chatLinesFont.BoundingBox, _chatLinesFont.BoundingBox, Positioner.SideFrom.Top);
                    }
                    else if (count == 0) // The last, the most recent message
                    {
                        // Checks do animation again
                        if (doAnimation)
                        {
                            _lastMessage = _lastMessage.Transformer(0.0F, 1.0F, 250, gameTime, (t) => _chatLinesFont.Alpha = t.CurrentValue);

                            // If last message animation is done, reset and restart
                            if (_lastMessage.Done)
                            {
                                _lastMessage = null;
                                doAnimation  = false;
                            }
                        }
                    }
                    _chatLinesFont.Draw(gameTime);
                    count++;
                }
                SpriteBatch.End();
            });
        }
Exemplo n.º 2
0
        public override void Draw(GameTime gameTime)
        {
            // Check size
            if (Notifications.Count <= 0)
            {
                return;
            }

            base.Draw(gameTime);

            // Take the first without removing, Dequeue() method removes it
            Notification first = Notifications.Peek();

            _notSprite.RectangleSource = (first.Type == NotificationType.Success) ? _notificationsRecs.Get(0) : _notificationsRecs.Get(1);
            _notificationShow          = _notificationShow.Transformer(0.0F, 1.0F, 250, gameTime, (t) => _notSprite.Alpha = t.CurrentValue);
            _notSprite.Draw(gameTime);
            _notFont.Text = first.Text;
            _notFont.Draw(gameTime);

            // Delete Notification
            if (_counter.Done)
            {
                // Hides notification
                _notificationHide = _notificationHide.Transformer(1.0F, 0.0F, 250, gameTime, (t) => _notSprite.Alpha = t.CurrentValue);

                // Checks if its hidden
                if (_notificationHide.Done)
                {
                    _counter.Reset();
                    Notifications.Dequeue();

                    // Resets transforms
                    _notificationShow = null;
                    _notificationHide = null;
                }
            }

            SpriteBatch.End();
        }
        public override void Update(GameTime gameTime)
        {
            _counter.Update(gameTime);
            if (!_counter.Done)
            {
                return;
            }

            // Fade all
            _overlayShow = _overlayShow.Transformer(0.0F, 1.0F, 300, gameTime, (t) => {
                _overlayLogin.Alpha   = t.CurrentValue;
                _overlayContent.Alpha = t.CurrentValue;
                _connText.Alpha       = t.CurrentValue;
            });

            // When fade is complete
            if (_overlayShow.Done)
            {
                bool online = false;

                if (User.State == LoginState.Connecting)
                {
                    // Still conecting
                    return;
                }
                else if (User.State == LoginState.Online)
                {
                    if (!_addedLobby)
                    {
                        Settings.UserOnline = User;
                        ScreenManager.SearchScreen <LoginScreen>().IsExiting = true;
                        ScreenManager.AddScreen(new LobbyScreen());
                        ScreenManager.AddScreen(new LobbyChatScreen());
                        ScreenManager.AddScreen(new LobbyBackScreen());
                    }
                    online      = true;
                    _addedLobby = true;
                }

                // Safe time
                _safeTime.Update(gameTime);

                if (_safeTime.Done)
                {
                    // Hide all content
                    _overlayHide = _overlayHide.Transformer(1.0F, 0.0F, 300, gameTime, (t) =>
                    {
                        _overlayLogin.Alpha   = t.CurrentValue;
                        _overlayContent.Alpha = t.CurrentValue;
                        _connText.Alpha       = t.CurrentValue;
                    });

                    // Everything is hidden?
                    if (_overlayHide.Done)
                    {
                        // If use ris online
                        if (online)
                        {
                            NotifierScreen.Notifications.Enqueue(new NotifierScreen.Notification()
                            {
                                Text = "Logged.", Type = NotificationType.Success
                            });
                        }
                        else
                        {
                            NotifierScreen.Notifications.Enqueue(new NotifierScreen.Notification()
                            {
                                Text = "Failed to make\nconnection.", Type = NotificationType.Alert
                            });
                        }
                        IsExiting = true;
                    }
                }
            }

            _overlayMove = _overlayMove.Transformer(0F, 16F, 4000, gameTime, (t) => { });

            // We have to put after transformer fo prevent null exception
            if (_overlayMove.Done)
            {
                _overlayMove = null; // Restart the animation
                return;
            }
        }