Ejemplo n.º 1
0
    public static void init()
    {
        if (mInitialized)
        {
            return;
        }
        mInitialized = true;

        dialogs = new List <Dialog>();

        shadow = new CSprite();
        //Esta tambien el shadow solo que llena toda la pantalla
        shadow.setImage(Resources.Load <Sprite>("Sprites/dialogShadow/shadow"));
        shadow.setName("Dialog - Background");
        shadow.setSortingLayerName("UI");
        shadow.setXY(0, CGameConstants.SCREEN_HEIGHT / 3 * 2);
        shadow.setWidth(CGameConstants.SCREEN_WIDTH);
        shadow.setVisible(false);

        characterPortrait = new CSprite();
        characterPortrait.setName("Character - Portrait");
        characterPortrait.setSortingLayerName("UI");
        characterPortrait.setXY(shadow.getX() + MARGIN, shadow.getY() + MARGIN);
        characterPortrait.setVisible(false);
        characterPortrait.setSortingOrder(1);

        text = new CText("");
        text.setFontSize(500.0f);
        text.setVisible(false);
        text.setXY(CGameConstants.SCREEN_WIDTH / 4 + MARGIN, shadow.getY() + MARGIN);
        text.setWidth(CGameConstants.SCREEN_WIDTH / 4 * 3 - MARGIN * 2);
    }
Ejemplo n.º 2
0
    public static void update()
    {
        shadow.update();
        text.update();
        characterPortrait.update();

        if (dialogs.Count > 0 && CKeyboard.firstPress(CKeyboard.ENTER))
        {
            if (dialogs[currentDialog].hasNextDialog())
            {
                text.setText(dialogs[currentDialog].goToNextDialog());
            }
            else if (currentDialog < dialogs.Count - 1)
            {
                currentDialog++;

                if (dialogs[currentDialog].hasPortrait())
                {
                    if (dialogs[currentDialog - 1].getPortrait() != dialogs[currentDialog].getPortrait())
                    {
                        characterPortrait.setFrames(Resources.LoadAll <Sprite>(dialogs[currentDialog].getPortrait()));
                        //characterPortrait.gotoAndPlay(1);
                        //characterPortrait.proceedAnimation();
                        characterPortrait.setVisible(true);
                    }
                }
                else
                {
                    characterPortrait.setVisible(false);
                }

                text.setText(dialogs[currentDialog].getCurrentDialog());
            }
            else
            {
                dialogs.Clear();
                text.setText("");
                shadow.setVisible(false);
                text.setVisible(false);
                currentDialog = 0;

                characterPortrait.setVisible(false);
            }
        }
    }