Exemplo n.º 1
0
 public void UpdateAlternativeTextLocation(TextAlternativeLocationState alternativeLocationState)
 {
     _narratingCharacter.SetAlternativeLocationState(alternativeLocationState);
     _mainCharacter.SetAlternativeLocationState(alternativeLocationState);
     foreach (var characterScript in _characterList)
     {
         characterScript.SetAlternativeLocationState(alternativeLocationState);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// For certain scenes, the text locations may need to change. Use this to communicate that.
 /// </summary>
 /// <param name="alternativeLocationState"></param>
 public void SetAlternativeLocationState(TextAlternativeLocationState alternativeLocationState)
 {
     _textAlternative = alternativeLocationState;
 }
Exemplo n.º 3
0
        private void Update()
        {
            if (characterState != _previousState)
            {
                RefreshSprite();

                _previousState = characterState;
            }

            switch (characterState)
            {
            case CharacterState.Hidden:
                // do nothing
                break;

            case CharacterState.Appearing:
                Appear();
                break;

            case CharacterState.Idling:
                if (_isSpeaking)
                {
                    characterState = CharacterState.Speaking;
                    _timeOffset    = Time.time;
                    _iconManager.informSpeakerReturnValue.dialogueBlocker.Unblock();
                }
                else
                {
                    sprite.transform.position = _currentStagePosition;
                }

                break;

            case CharacterState.Speaking:
                sprite.transform.position = _currentStagePosition +
                                            (Mathf.Abs(Mathf.Sin((Time.time - _timeOffset) *
                                                                 speakFloatSpeed)) * speakFloatHeight * Vector3.up);
                break;

            case CharacterState.Disappearing:
                Disappear();
                break;

            case CharacterState.ToRepositionIdling:
                if (sprite.transform.position != _idleTargetPosition)
                {
                    sprite.transform.position = Vector3.MoveTowards(sprite.transform.position,
                                                                    _idleTargetPosition, textTransitionSpeed * Time.deltaTime);
                }
                else
                {
                    characterState = CharacterState.RepostitionIdling;
                }

                break;

            case CharacterState.RepostitionIdling:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (_textAlternative != _previousTextAlternative)
            {
                _alternativeTextLocation = alternativeTextTransform.position;

                foreach (var data in alternativeTextLocationList)
                {
                    if (data.state == _textAlternative)
                    {
                        _alternativeTextLocation = data.transform.position;
                        break;
                    }
                }

                _defaultTextLocation = _initialTextLocation;

                foreach (var data in defaultTextLocationList)
                {
                    if (data.state == _textAlternative)
                    {
                        _defaultTextLocation = data.transform.position;
                        break;
                    }
                }

                _previousTextAlternative = _textAlternative;

                _currentStagePosition = stageLocation.position;

                foreach (var data in alternativeStageLocationList)
                {
                    if (data.state == _textAlternative)
                    {
                        _currentStagePosition = data.transform.position;
                        break;
                    }
                }

                switch (_textState)
                {
                case TextState.Default:
                    _textState = TextState.ToDefault;
                    break;

                case TextState.ToAlternative:
                    break;

                case TextState.Alternative:
                    _textState = TextState.Alternative;
                    break;

                case TextState.ToDefault:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            switch (_textState)
            {
            case TextState.Default:
                break;

            case TextState.ToAlternative:
                if (dialogueText.transform.position != _alternativeTextLocation)
                {
                    dialogueText.transform.position = Vector3.MoveTowards(dialogueText.transform.position,
                                                                          _alternativeTextLocation, textTransitionSpeed * Time.deltaTime);
                }
                else
                {
                    _textState = TextState.Alternative;
                }

                break;

            case TextState.Alternative:
                break;

            case TextState.ToDefault:
                if (dialogueText.transform.position != _defaultTextLocation)
                {
                    dialogueText.transform.position = Vector3.MoveTowards(dialogueText.transform.position,
                                                                          _defaultTextLocation, textTransitionSpeed * Time.deltaTime);
                }
                else
                {
                    _textState = TextState.Default;
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the status of a character depending on their emotion or description.
        /// It also checks what their status is based on icon manager.
        /// </summary>
        /// <param name="description"></param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public void UpdateStatus(string description)
        {
            if (_iconManager.currentSpeaking != this && characterState != CharacterState.Hidden)
            {
                characterState = CharacterState.Idling;
                _isSpeaking    = false;
            }
            else if (_iconManager.currentSpeaking == this && _characterType != CharacterType.Narrator)
            {
                _isSpeaking = true;
                switch (characterState)
                {
                case CharacterState.Hidden:
                    // show up
                    characterState = CharacterState.Appearing;
                    _iconManager.informSpeakerReturnValue.dialogueBlocker.Block();
                    break;

                case CharacterState.Appearing:
                    _iconManager.informSpeakerReturnValue.dialogueBlocker.Block();
                    // just keep it up
                    break;

                case CharacterState.Idling:
                    // go to speak immediately
                    characterState = CharacterState.Speaking;
                    _timeOffset    = Time.time;
                    break;

                case CharacterState.Speaking:
                    // keep the state
                    break;

                case CharacterState.ToRepositionIdling:
                    // go to speak immediately
                    characterState = CharacterState.Speaking;
                    _timeOffset    = Time.time;
                    break;

                case CharacterState.Disappearing:
                    Debug.LogWarning("UpdateStatus: This should not happen");
                    break;

                case CharacterState.RepostitionIdling:
                    characterState = CharacterState.Appearing;
                    _iconManager.informSpeakerReturnValue.dialogueBlocker.Block();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            if (_characterType == CharacterType.Side && !_isSpeaking && characterState != CharacterState.Hidden)
            {
                // check index in active characters
                int currentIndex = _iconManager.GetSideCharacterIndex(this);
                Debug.Assert(currentIndex != -1);
                _idleTargetPosition   = _currentStagePosition + (currentIndex * offsetIncrement);
                _idleTargetPosition.z = inactiveZ;
                characterState        = CharacterState.ToRepositionIdling;
            }

            if (characterState == CharacterState.Idling)
            {
                characterState = CharacterState.Appearing;
            }


            if (_isSpeaking)
            {
                _description = description.Trim();
                if (!_description.Equals(_oldDescription))
                {
                    // Ver bad hardcoding T.T
                    if (_oldDescription.ToLower().Equals("jojo"))
                    {
                        _iconManager.UpdateAlternativeTextLocation(_jojoPreviousAltState);
                    }

                    if (_description.ToLower().Equals("jojo"))
                    {
                        _jojoPreviousAltState = _textAlternative;
                        _iconManager.UpdateAlternativeTextLocation(TextAlternativeLocationState.Jojo);
                    }

                    _oldDescription = _description;
                    RefreshSprite();
                }
            }

            textCanvas.gameObject.SetActive(false);
            dialogueText.text = "";
        }