Example #1
0
 private void ChooseIdle()
 {
     if (NpcActionExtensions.IsSpecialIdle(this.CurrentAction))
     {
         this.CurrentAction = NpcAction.Idle;
     }
     else
     {
         float num1 = RandomHelper.Unit();
         float num2 = (float)(1 + FezMath.AsNumeric(this.CanIdle2) + FezMath.AsNumeric(this.CanIdle3));
         if ((double)num1 < 1.0 / (double)num2)
         {
             this.CurrentAction = NpcAction.Idle;
         }
         else if ((double)num2 > 1.0 && (double)num1 < 2.0 / (double)num2)
         {
             this.CurrentAction = this.CanIdle2 ? NpcAction.Idle2 : NpcAction.Idle3;
         }
         else
         {
             if ((double)num2 <= 2.0 || (double)num1 >= 3.0 / (double)num2)
             {
                 return;
             }
             this.CurrentAction = NpcAction.Idle3;
         }
     }
 }
Example #2
0
 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");
 }
Example #3
0
        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;
        }