示例#1
0
        private void Talk()
        {
            if (this.Npc.CustomSpeechLine != null)
            {
                this.CurrentLine = this.Npc.CustomSpeechLine;
            }
            else
            {
                SpeechLine speechLine = this.CurrentLine;
                if (this.Npc.Speech.Count <= 1 || this.Npc.SayFirstSpeechLineOnce && !this.SaidFirstLine)
                {
                    this.CurrentLine = Enumerable.FirstOrDefault <SpeechLine>((IEnumerable <SpeechLine>) this.Npc.Speech);
                }
                else
                {
                    do
                    {
                        if (this.Npc.RandomizeSpeech)
                        {
                            this.CurrentLine = RandomHelper.InList <SpeechLine>(this.Npc.Speech);
                        }
                        else
                        {
                            this.CurrentLine = this.Npc.Speech[this.SequentialLineIndex];
                            ++this.SequentialLineIndex;
                            if (this.SequentialLineIndex == this.Npc.Speech.Count)
                            {
                                this.SequentialLineIndex = 0;
                            }
                        }
                    }while (speechLine == this.CurrentLine || this.Npc.SayFirstSpeechLineOnce && this.SaidFirstLine && this.CurrentLine == this.Npc.Speech[0]);
                }
                this.SaidFirstLine = true;
            }
            IPlayerManager playerManager1 = this.PlayerManager;
            Vector3        vector3_1      = playerManager1.Velocity * Vector3.UnitY;

            playerManager1.Velocity   = vector3_1;
            this.PlayerManager.Action = ActionType.ReadingSign;
            Vector3 a = this.PlayerManager.Position - this.Position;

            this.SpeechManager.Origin = this.Position + Vector3.UnitY * 0.5f;
            string s;

            if (this.LevelManager.SongName == "Majesty")
            {
                this.SpeechManager.Font = SpeechFont.Zuish;
                string stringRaw = GameText.GetStringRaw(this.CurrentLine.Text);
                this.SpeechManager.Origin       = this.Position + Vector3.UnitY * 0.5f + FezMath.RightVector(this.CameraManager.Viewpoint);
                this.SpeechManager.ChangeText(s = stringRaw);
            }
            else
            {
                this.SpeechManager.ChangeText(s = GameText.GetString(this.CurrentLine.Text));
            }
            this.LookingDirection = FezMath.DirectionFromMovement(FezMath.Dot(a * FezMath.Sign(this.Npc.DestinationOffset), FezMath.SideMask(this.CameraManager.Viewpoint)));
            this.PlayerManager.LookingDirection = FezMath.DirectionFromMovement(-FezMath.Dot(a, FezMath.RightVector(this.CameraManager.Viewpoint)));
            float num = FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint));

            if ((double)Math.Abs(num) < 1.0)
            {
                Vector3 center   = this.PlayerManager.Center;
                Vector3 velocity = this.PlayerManager.Velocity;
                MultipleHits <TrileInstance> ground = this.PlayerManager.Ground;
                IPlayerManager playerManager2       = this.PlayerManager;
                Vector3        vector3_2            = playerManager2.Center + (float)Math.Sign(num) * (1.25f - Math.Abs(num)) * FezMath.SideMask(this.CameraManager.Viewpoint);
                playerManager2.Center = vector3_2;
                this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                this.PlayerManager.Velocity = velocity;
                if (!this.PlayerManager.Grounded)
                {
                    this.PlayerManager.Center = center;
                    this.PlayerManager.Ground = ground;
                }
                else
                {
                    this.PlayerManager.Center = center + (float)Math.Sign(num) * (1f - Math.Abs(num)) * FezMath.SideMask(this.CameraManager.Viewpoint);
                }
            }
            this.CurrentAction = NpcAction.Talk;
            this.Npc.Talking   = true;
            if (this.Npc.ActorType == ActorType.LightningGhost)
            {
                this.Group.Material.Opacity = 0.0f;
            }
            this.talkWaiter = Waiters.Wait(0.100000001490116 + 0.0750000029802322 * (double)Util.StripPunctuation(s).Length *(Culture.IsCJK ? 2.0 : 1.0), (Action)(() =>
            {
                if (this.talkEmitter == null)
                {
                    return;
                }
                this.talkEmitter.FadeOutAndPause(0.1f);
            }));
            this.talkWaiter.AutoPause = true;
            this.UpdateAction();
        }