예제 #1
0
        public void tick()
        {
            if (chatModel == null && this.chatMessages.Count > 0)
            {
                Scene.getActiveScene().pause();
                chatModel = new Model();
                chatModel.getMaterial().setRender2D(true);
                chatModel.getMaterial().setRender3D(false);

                Camera cmr;
                lock (cmr = Camera.getCamera()) {
                    background = new Quad();
                    background.setScaleX(cmr.getWidth());
                    background.getMaterial().setRender2D(true);
                    background.getMaterial().setRender3D(false);
                    background.setScaleY(150);
                    background.getMaterial().setColor(Color.BLUE.clone().setAlpha(0.1));

                    chatModel.addChild(background);

                    chatModel.getLocation().setX(cmr.getWidth() / 2.0);
                    chatModel.getLocation().setY(cmr.getHeight() - background.getScaleY() / 2.0);
                }

                Sprite cu = this.characterFace = new Sprite(Chat.getFrameBuffer().getLoadableTexture().getTexture());
                cu.flipY();
                cu.updateFace();
                cu.getLocation().setX(-background.getScaleX() / 2.0);
                cu.getLocation().setY(-cu.getHeight() / 2.0);
                chatModel.addChild(cu);

                Scene.getActiveScene().addModel(chatModel);
            }

            if (this.chatMessages.Count < 1 && chatModel != null)
            {
                Scene.getActiveScene().removeModel(chatModel);

                background.Dispose();
                characterFace.Dispose();
                chatModel.Dispose();

                background    = null;
                characterFace = null;
                chatModel     = null;
                Scene.getActiveScene().resume();
            }

            if (chatModel != null)
            {
                Scene.getActiveScene().removeModel(chatModel);

                if (getCurrentMessage() != this.currentMessage)
                {
                    if (this.fontModels != null)
                    {
                        lock (this.fontModels) {
                            foreach (FontModel fm in this.fontModels)
                            {
                                if (fm == null)
                                {
                                    continue;
                                }
                                lock (fm) {
                                    fm.getTexture().Dispose();
                                    fm.getVBO().Dispose();
                                    fm.Dispose();
                                }
                            }
                        }
                        this.fontModels = null;
                    }
                    else
                    {
                        ChatMessage c = this.currentMessage = getCurrentMessage();
                        String[]    s = c.getMessage().Split('\n');
                        foreach (String ss in s)
                        {
                            this.strs.Add(ss);
                        }
                        this.updateFonts();
                    }
                }

                Scene.getActiveScene().addModel(chatModel);

                if (this.strs.Count > 0)
                {
                    if (Game.GAME_INSTANCE.isButtonDown(GamePadButtons.Enter) && !this.enterLastFrame)
                    {
                        this.nextPage();
                    }
                }
            }

            this.enterLastFrame = Game.GAME_INSTANCE.isButtonDown(GamePadButtons.Enter);
        }
예제 #2
0
 public void centerY()
 {
     this.getLocation().setY(Camera.getCamera().getHeight() / 2.0 - this.getHeight() / 2.0);
 }
예제 #3
0
 public void seventyFivePercentY()
 {
     this.getLocation().setY(Camera.getCamera().getHeight() * 0.75 - this.getHeight() / 2.0);
 }
예제 #4
0
 public void centerX()
 {
     this.getLocation().setX(Camera.getCamera().getWidth() / 2.0 - this.getWidth() / 2.0);
 }