예제 #1
0
        public FieldToken(AToken previousToken, string text) : base(previousToken, "fieldToken", fillUserText(text))
        {
            this.trueText = text;

            this.associatedToken         = null;
            this.previousAssociatedToken = null;
        }
예제 #2
0
        public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed)
        {
            if (this.associatedToken != this.previousAssociatedToken)
            {
                if (this.associatedToken != null)
                {
                    AToken nextToken = this.NextToken;

                    int i = 0;
                    while (nextToken != null)
                    {
                        if (i == 0)
                        {
                            officeWorld.NotifyTextUpdated(nextToken, nextToken.PreviousToken, this.associatedToken, this.InitialPosition);
                        }
                        else
                        {
                            officeWorld.NotifyTextUpdated(nextToken, nextToken.PreviousToken, null, this.InitialPosition);
                        }

                        i++;
                        nextToken = nextToken.NextToken;
                    }

                    officeWorld.NotifyInternalGameEvent(this.previousAssociatedToken, this.associatedToken, "association");
                }

                this.previousAssociatedToken = this.associatedToken;
            }

            base.UpdateLogic(officeWorld, timeElapsed);
        }
예제 #3
0
        public static AToken CreateToken(string data, TokenType type)
        {
            AToken tokenObject = null;

            switch (type)
            {
            case TokenType.NORMAL:
                tokenObject = new NormalToken(null, data);
                break;

            case TokenType.SANCTUARY:
                tokenObject = new SanctuaryToken(null, data);
                break;

            case TokenType.ANSWER:
                tokenObject = new AnswerToken(null, data);
                break;

            case TokenType.HEADER:
                tokenObject = new HeaderToken(null, data);
                break;

            case TokenType.FIELD:
                tokenObject = new FieldToken(null, data);
                break;

            case TokenType.TIMER:
                tokenObject = new TimerTokenObject(null, data);
                break;
            }

            return(tokenObject);
        }
예제 #4
0
        public void AddToken(AToken token)
        {
            List <AToken> currentList = this.tokensList.Last();

            int nbLetter = 0;

            foreach (AToken tokenInList in currentList)
            {
                nbLetter += tokenInList.Text.Length;
            }

            if (nbLetter > this.WidthDialogue)
            {
                currentList = new List <AToken>();
                this.tokensList.Add(currentList);

                if (token.PreviousToken != null)
                {
                    token.PreviousToken.NextToken = null;
                    token.PreviousToken           = null;
                }
            }

            currentList.Add(token);
        }
예제 #5
0
        public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed)
        {
            if (this.previousPosition.X != this.position.X ||
                this.previousPosition.Y != this.position.Y)
            {
                if (this.isFocused == false)
                {
                    officeWorld.NotifyTextPositionChanged(this, this.previousToken, this.position);
                }
                else
                {
                    officeWorld.NotifyObjectPositionChanged(this, this.position);
                }
                this.previousPosition = new Vector2f(this.position.X, this.position.Y);
            }

            if (this.isFocused != this.previousIsFocused)
            {
                officeWorld.NotifyObjectFocusChanged(this, this.isFocused);

                this.previousIsFocused = this.isFocused;
            }

            if (this.displayedText.Equals(this.previousDisplayedText) == false)
            {
                officeWorld.NotifyObjectTextChanged(this, this.displayedText);

                this.previousDisplayedText = this.displayedText;

                AToken nextToken = this.NextToken;
                if (nextToken != null && nextToken.IsTextFull)
                {
                    while (nextToken != null)
                    {
                        nextToken.SetKinematicParameters(nextToken.InitialPosition, new SFML.System.Vector2f(0, 0));
                        nextToken = nextToken.NextToken;
                    }
                }
            }

            if (this.isTextLaunched && this.speedText > 0 && this.indexText < this.text.Length)
            {
                this.nbCharacterToAdd += this.speedText * timeElapsed.AsSeconds() * this.speedFactor;

                int nbCharacterToAddInteger = (int)this.nbCharacterToAdd;

                this.indexText += nbCharacterToAddInteger;

                this.indexText = Math.Min(this.text.Length, this.indexText);

                this.nbCharacterToAdd -= nbCharacterToAddInteger;

                this.displayedText = this.text.Substring(0, this.indexText);
            }

            if (this.IsTextFull && this.isTextLaunched)
            {
                this.isTextLaunched = false;
            }
        }
예제 #6
0
        public static DialogueObject CreateDialogueFactory(int dialogueLength, string data, TokenType type)
        {
            DialogueObject dialogueObject = new DialogueObject(dialogueLength);
            AToken         previousToken  = null;

            string[] words;
            if (type != TokenType.ANSWER &&
                type != TokenType.FIELD)
            {
                words = data.Split(' ');
            }
            else
            {
                words = new string[] { data };
            }

            foreach (string word in words)
            {
                AToken tokenObject = null;
                switch (type)
                {
                case TokenType.NORMAL:
                    tokenObject = new NormalToken(previousToken, word + " ");
                    break;

                case TokenType.SANCTUARY:
                    tokenObject = new SanctuaryToken(previousToken, word + " ");
                    break;

                case TokenType.ANSWER:
                    tokenObject = new AnswerToken(previousToken, word);
                    break;

                case TokenType.HEADER:
                    tokenObject = new HeaderToken(previousToken, word + " ");
                    break;

                case TokenType.FIELD:
                    tokenObject = new FieldToken(previousToken, word);
                    break;
                }

                if (previousToken != null)
                {
                    previousToken.NextToken = tokenObject;
                }

                dialogueObject.AddToken(tokenObject);

                previousToken = tokenObject;
            }

            return(dialogueObject);
        }
예제 #7
0
        public AToken(AToken previousToken, string id, string text) : base(id)
        {
            this.previousToken = previousToken;
            this.nextToken     = null;

            this.text = text;
            this.previousDisplayedText = string.Empty;
            this.displayedText         = string.Empty;

            this.indexText        = 0;
            this.nbCharacterToAdd = 0;
            this.speedText        = 8;
            this.speedFactor      = 1;

            this.isTextLaunched = false;
        }
예제 #8
0
 public TimerTokenObject(AToken previousToken, string text) : base(previousToken, "timerToken", text)
 {
 }
예제 #9
0
 public NormalToken(AToken previousToken, string text) : base(previousToken, "normalToken", text)
 {
 }
예제 #10
0
 public SanctuaryToken(AToken previousToken, string text) : base(previousToken, "sanctuaryToken", text)
 {
 }
예제 #11
0
        public static DialogueObject CreateDialogueFactory(int dialogueLength, Dialogue data)
        {
            DialogueObject dialogueObject = new DialogueObject(dialogueLength);

            AToken        previousToken     = null;
            DialogueToken previousDataToken = null;

            foreach (DialogueToken token in data.DialoguesToken)
            {
                string[] words;
                if (token.Type != TokenType.ANSWER &&
                    token.Type != TokenType.FIELD)
                {
                    words = token.Token.Split(' ');
                }
                else
                {
                    words = new string[] { token.Token };
                }

                foreach (string word in words)
                {
                    AToken tokenObject = null;
                    switch (token.Type)
                    {
                    case TokenType.NORMAL:
                        if (previousDataToken != null && (previousDataToken.Type == TokenType.FIELD || previousDataToken.Type == TokenType.ANSWER))
                        {
                            tokenObject = new NormalToken(previousToken, " " + word + " ");
                        }
                        else
                        {
                            tokenObject = new NormalToken(previousToken, word + " ");
                        }
                        break;

                    case TokenType.SANCTUARY:
                        tokenObject = new SanctuaryToken(previousToken, word + " ");
                        break;

                    case TokenType.ANSWER:
                        tokenObject = new AnswerToken(previousToken, word);
                        break;

                    case TokenType.HEADER:
                        tokenObject = new HeaderToken(previousToken, word);
                        break;

                    case TokenType.FIELD:
                        tokenObject = new FieldToken(previousToken, word);
                        break;
                    }

                    if (previousToken != null)
                    {
                        previousToken.NextToken = tokenObject;
                    }

                    dialogueObject.AddToken(tokenObject);

                    previousToken     = tokenObject;
                    previousDataToken = token;
                }
            }

            return(dialogueObject);
        }
예제 #12
0
 public HeaderToken(AToken previousToken, string text) : base(previousToken, "headerToken", text)
 {
 }
예제 #13
0
 public AnswerToken(AToken previousToken, string text) : base(previousToken, "answerToken", text)
 {
 }