Esempio n. 1
0
    private void Start()
    {
        initialElapsed = elapsed;
        m_current      = TextboxState.HIDDEN;

        scale = 0.0f;
    }
Esempio n. 2
0
 public static void reset()
 {
     lines.Clear();
     callback = null;
     state = TextboxState.Hidden;
     cur_line = cur_pos = 0;
     last_anim_tick = VERGEGame.game.tick;
 }
Esempio n. 3
0
 public void DecreaseSize()
 {
     scale -= Mathf.Min(scale, Time.deltaTime / 5f);
     gameObject.transform.localScale = new Vector2(scale, scale);
     if (scale == 0)
     {
         m_current = TextboxState.HIDDEN;
     }
 }
Esempio n. 4
0
 public void IncreaseSize()
 {
     scale += Mathf.Min(1.0f - scale, Time.deltaTime / 5f);
     gameObject.transform.localScale = new Vector2(scale, scale);
     if (scale == 1)
     {
         m_current = TextboxState.STAYING;
     }
 }
Esempio n. 5
0
 void ElapsedTime(TextboxState changeState)
 {
     elapsed -= Mathf.Min(elapsed, Time.deltaTime);
     if (elapsed == 0)
     {
         elapsed   = initialElapsed;
         m_current = changeState;
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes variables for the Text Manager.
        /// </summary>
        public static void Init()
        {
            textCache = new List <DataTypes.RPGString>();
            InitCharDictionary();
            currentSpeech   = "";
            textUIReady     = false;
            textUILowering  = false;
            stringDone      = false;
            textTimer       = 0;
            state           = TextboxState.lowered;
            textboxPosition = new Vector2(0, textboxLoweredY);

            DisablePreferences();
        }
Esempio n. 7
0
        public void Update()
        {
            SullyGame game = (SullyGame)VERGEGame.game;
            int step;
            switch (state) {
                case TextboxState.Waiting: // The textbox has finished scrolling and is awaiting input
                    if (game.action.confirm.pressed || game.action.cancel.pressed) {

                        boxes_of_text.Remove( boxes_of_text[0] );

                        if( boxes_of_text.Count == 0 ) {
                            if( callback != null ) {
                                callback();
                            }

                            if( OnDone != null ) {
                                OnDone();
                            }

                            full_reset();

                            if( this.dontReleasePlayerOnDone ) {
                                this.dontReleasePlayerOnDone = false;
                            } else {
                                VERGEGame.game.unlock_player();
                            }

                        } else {
                            box_reset();
                        }
                    }
                    break;
                case TextboxState.Printing: { // The textbox is currently scrolling text
                    if( currently_rendering_text.Count == 0 || game.action.cancel.pressed ) {

                        state = TextboxState.Waiting;
                        last_anim_tick = game.tick;

                    } else {
                        if (game.action.confirm.down) step = short_step;
                        else step = long_step;
                        while (game.tick - last_anim_tick >= step) {
                            last_anim_tick += step;
                            cur_pos++;
                            while( cur_line < currently_rendering_text.Count && cur_pos >= currently_rendering_text[cur_line].Length ) {
                                cur_line++;
                                cur_pos = 0;
                            }
                            if( cur_line >= currently_rendering_text.Count ) {
                                state = TextboxState.Waiting;
                            }
                        }
                    }
                }
                break;
            }
        }
Esempio n. 8
0
 public void maybe_start()
 {
     if( !isStarted ) {
         VERGEGame.game.lock_player();
         box_reset();
         state = TextboxState.Printing;
         isStarted = true;
     }
 }
Esempio n. 9
0
 public void full_reset()
 {
     callback = null;
     OnDone = null;
     state = TextboxState.Hidden;
     cur_line = cur_pos = 0;
     last_anim_tick = VERGEGame.game.tick;
     isStarted = false;
 }
Esempio n. 10
0
        public void box_reset()
        {
            last_anim_tick = VERGEGame.game.tick;
            cur_line = cur_pos = 0;
            this.currently_rendering_text.Clear();

            List<object> curbox = (List<object>)boxes_of_text[0];
            activeSpeechIdx = (int)curbox[0];

            this.currently_rendering_text.Add( (string)curbox[1] );
            this.currently_rendering_text.Add( (string)curbox[2] );
            this.currently_rendering_text.Add( (string)curbox[3] );
            state = TextboxState.Printing;
        }
Esempio n. 11
0
 public static void Update()
 {
     MGame game = (MGame)VERGEGame.game;
     int step;
     switch (Textbox.state) {
         case TextboxState.Waiting: // The textbox has finished scrolling and is awaiting input
             if (game.action.confirm.pressed || game.action.cancel.pressed) {
                 reset();
                 if (callback != null) callback();
                 VERGEGame.game.unlock_player();
             }
             break;
         case TextboxState.Printing: { // The textbox is currently scrolling text
             if (lines.Count == 0 || game.action.cancel.pressed) {
                 state = TextboxState.Waiting;
                 last_anim_tick = game.tick;
             }
             else {
                 if (game.action.confirm.down) step = short_step;
                 else step = long_step;
                 while (game.tick - last_anim_tick >= step) {
                     last_anim_tick += step;
                     cur_pos++;
                     while (cur_line < lines.Count && cur_pos >= lines[cur_line].Length) {
                         cur_line++;
                         cur_pos = 0;
                     }
                     if (cur_line >= lines.Count) {
                         state = TextboxState.Waiting;
                     }
                 }
             }
         }
         break;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AGS.API.TextBoxKeyPressingEventArgs"/> class.
 /// </summary>
 /// <param name="pressedKey">Pressed key.</param>
 /// <param name="intendedState">Intended state.</param>
 public TextBoxKeyPressingEventArgs(Key pressedKey, TextboxState intendedState)
 {
     PressedKey    = pressedKey;
     IntendedState = intendedState;
 }
Esempio n. 13
0
        /// <summary>
        /// Updates the text manager.
        /// </summary>
        public static void Update()
        {
            if (animationIncrement < int.MaxValue)
            {
                animationIncrement++;
            }
            else
            {
                animationIncrement = 0;
            }

            //Checks the state of the text manager
            switch (state)
            {
            //If the textbox is lowered...
            case (TextboxState.lowered):
                if (nametagPosition.Y < RPGEngineMain.WindowHeight + textboxNametag.Height)
                {
                    nametagPosition = new Vector2(nametagPosition.X, nametagPosition.Y + textboxAnimationSpeed);
                }

                if (textCache.Count > 0)
                {
                    state = TextboxState.raising;
                }
                break;

            //If the textbox is raising...
            case (TextboxState.raising):
                if (textboxPosition.Y > textboxRaisedY)
                {
                    textboxPosition = new Vector2(textboxPosition.X, textboxPosition.Y - textboxAnimationSpeed);
                }

                if (textboxPosition.Y < textboxRaisedY)
                {
                    textboxPosition = new Vector2(textboxPosition.X, textboxRaisedY);
                }

                nametagPosition = new Vector2(0, textboxPosition.Y - textboxNametag.Height);

                if (textboxPosition.Y == textboxRaisedY)
                {
                    state = TextboxState.printing;
                }
                break;

            //If the textbox is printing...
            case (TextboxState.printing):
                //If you're holding down the key, make it type faster
                if (InputManager.State.IsKeyDown(Keys.Z))
                {
                    textTimer += 4;
                }
                else
                {
                    textTimer++;
                }

                //If there's still text left...
                if (textCache.Count > 0 && currentSpeech.Length < textCache[textCache.Count - 1].text.Length)
                {
                    //And the timer reaches its limit...
                    if (textTimer >= textCache[textCache.Count - 1].textSpeed)
                    {
                        textTimer = 0;
                        //And the current speech length isin't greater than what's in the cache...
                        if (currentSpeech.Length < textCache[textCache.Count - 1].text.Length)
                        {
                            //Add a letter to the current text
                            currentSpeech = textCache[textCache.Count - 1].text.Substring(0, currentSpeech.Length + 1);
                        }

                        //If the next character equals these, make it longer to print out the next character
                        char newChar = currentSpeech.ToCharArray()[currentSpeech.Length - 1];
                        if (newChar == '.' || newChar == ',' || newChar == '!' || newChar == '?' || newChar == ';' || newChar == ':')
                        {
                            textTimer = (int)Math.Round(-textCache[textCache.Count - 1].textSpeed * 3.0);
                        }
                    }
                }
                else
                {
                    //If the text is done, and you hit the key...
                    if (InputManager.Clicked(Keys.Z))
                    {
                        //Clear the current speech, and pop the cache
                        currentSpeech = "";
                        CachePop();
                        //But if there's no text left in the cache...
                        if (textCache.Count == 0)
                        {
                            //Reset the timer and lower the textbox
                            textTimer = 0;
                            state     = TextboxState.lowering;
                        }
                    }
                }
                break;

            //If the textbox is lowering...
            case (TextboxState.lowering):
                if (textboxPosition.Y < textboxLoweredY)
                {
                    textboxPosition = new Vector2(textboxPosition.X, textboxPosition.Y + textboxAnimationSpeed);
                }

                if (textboxPosition.Y > textboxLoweredY)
                {
                    textboxPosition = new Vector2(textboxPosition.X, textboxLoweredY);
                }

                nametagPosition = new Vector2(0, textboxPosition.Y - textboxNametag.Height);

                if (textboxPosition.Y == textboxLoweredY)
                {
                    state = TextboxState.lowered;
                    Managers.GlobalVariables.gameState = GameState.gamePlay;
                }
                break;
            }
        }