示例#1
0
        public virtual void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed)
        {
            if (this.isFocused != this.previousIsFocused)
            {
                officeWorld.NotifyObjectFocusChanged(this, this.isFocused);

                this.previousIsFocused = this.isFocused;
            }

            if (this.currentAnimationIndex != this.previousAnimationIndex)
            {
                officeWorld.NotifyObjectAnimationChanged(this, this.currentAnimationIndex);

                this.previousAnimationIndex = this.currentAnimationIndex;
            }

            if (this.speedVector != null &&
                (this.speedVector.X != 0 || this.speedVector.Y != 0))
            {
                this.position += this.speedVector * timeElapsed.AsSeconds();
            }

            if (this.previousPosition.X != this.position.X ||
                this.previousPosition.Y != this.position.Y)
            {
                officeWorld.NotifyObjectPositionChanged(this, this.position);

                this.previousPosition = new Vector2f(this.position.X, this.position.Y);
            }
        }
示例#2
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;
            }
        }