protected void LoadContent() { foreach (NpcAction action in this.Npc.Actions.Keys) { NpcActionContent npcActionContent = this.Npc.Actions[action]; npcActionContent.Animation = this.LoadAnimation(npcActionContent.AnimationName); npcActionContent.Animation.Timing.Loop = NpcActionExtensions.Loops(action); if (npcActionContent.SoundName != null) { npcActionContent.Sound = this.LoadSound(npcActionContent.SoundName); } else if (this.Npc.Metadata.SoundActions.Contains(action)) { npcActionContent.Sound = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/" + this.Npc.Metadata.SoundPath); } } foreach (NpcActionContent npcActionContent in Enumerable.Select <SpeechLine, NpcActionContent>(Enumerable.Where <SpeechLine>((IEnumerable <SpeechLine>) this.Npc.Speech, (Func <SpeechLine, bool>)(x => x.OverrideContent != null)), (Func <SpeechLine, NpcActionContent>)(x => x.OverrideContent))) { if (npcActionContent.AnimationName != null) { npcActionContent.Animation = this.LoadAnimation(npcActionContent.AnimationName); } if (npcActionContent.SoundName != null) { npcActionContent.Sound = this.LoadSound(npcActionContent.SoundName); } } if (!this.CanTakeOff) { return; } this.flySound = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Wildlife/BirdFly"); }
public override void Update(GameTime gameTime) { TimeSpan elapsedGameTime = gameTime.ElapsedGameTime; this.Npc.Enabled = this.Npc.ActorType != ActorType.Owl || !this.OwlInvisible; if (!this.Scripted && NpcActionExtensions.AllowsRandomChange(this.CurrentAction)) { this.TimeSinceActionChange += elapsedGameTime; if (this.TimeSinceActionChange > this.TimeUntilActionChange) { this.ToggleAction(); } } else if (!NpcActionExtensions.Loops(this.CurrentAction) && this.CurrentTiming.Ended && this.CurrentAction != NpcAction.Hide) { this.ToggleAction(); } if (this.CurrentAction != NpcAction.Talk) { if (this.CanTalk && (this.Npc.Speech.Count > 0 || this.Npc.CustomSpeechLine != null)) { this.TryTalk(); } if (this.CurrentAction == NpcAction.Walk) { this.Walk(elapsedGameTime); } if (this.CurrentAction == NpcAction.Fly || this.CurrentAction == NpcAction.TakeOff) { this.Fly(elapsedGameTime); } } else if (this.TryStopTalking() && this.CurrentAction != NpcAction.TakeOff) { this.ToggleAction(); } if (this.Npc.AvoidsGomez && this.Npc.Visible) { this.TryFlee(); } if (this.CurrentTiming != null) { this.CurrentTiming.Update(elapsedGameTime, this.AnimationSpeed); this.SyncTextureMatrix(); } this.Npc.Visible = this.CameraManager.Frustum.Contains(new BoundingBox(this.Position - this.Group.Scale, this.Position + this.Group.Scale)) != ContainmentType.Disjoint; }