예제 #1
0
 public SituationOutcomeState(SituationOutcome outcome, GameContext context)
 {
     this.outcome = outcome;
     this.context = context;
 }
예제 #2
0
 public override void Update(GameContext context, GameTime gameTime, Input input)
 {
     if (input.WasKeyPressed(Keys.Up))
     {
         _selectedAction -= 1;
     }
     if (input.WasKeyPressed(Keys.Down))
     {
         _selectedAction += 1;
     }
     if (_selectedAction < 0)
     {
         _selectedAction = 2;
     }
     if (_selectedAction > 2)
     {
         _selectedAction = 0;
     }
     if (input.WasKeyPressed(Keys.Enter))
     {
         var outcome = new SituationOutcome();
         outcome.Action = _selectedAction;
         if (_selectedAction == 0)
         {
             outcome.Description = "YOU CHOSE TO FIGHT..";
             foreach (var risk in FightRisks)
             {
                 var check = context.Random.Next(0, 100);
                 if (check < risk.ChanceOfHappening)
                 {
                     outcome.Consequences.Add(risk.Card);
                 }
             }
             outcome.GainedResources.AddRange(this.Resources);
         }
         else if (_selectedAction == 1)
         {
             outcome.Description = "YOU CHOSE TO LOOT SOME RESOURCES AND RUN...";
             foreach (var risk in GrabAndRunRisks)
             {
                 var check = context.Random.Next(0, 100);
                 if (check < risk.ChanceOfHappening)
                 {
                     outcome.Consequences.Add(risk.Card);
                 }
             }
             var gain = Resources.OrderBy(_ => context.Random.Next(100)).First();
             outcome.GainedResources.Add(gain);
             Resources.Remove(gain);
             int i = 30;
             foreach (var remainingResource in Resources)
             {
                 var check = context.Random.Next(100);
                 if (check < (i - context.Group.MemberCount))
                 {
                     outcome.GainedResources.Add(remainingResource);
                 }
                 i -= 5;
             }
         }
         else
         {
             outcome.Description = "YOU CHOSE TO RUN...";
             foreach (var risk in RunRisks)
             {
                 var check = context.Random.Next(0, 100);
                 if (check < risk.ChanceOfHappening)
                 {
                     outcome.Consequences.Add(risk.Card);
                 }
             }
         }
         Manager.State = new SituationOutcomeState(outcome, context);
     }
 }