示例#1
0
        public async Task Reset(FieldSettings fieldSettings)
        {
            if (GameState == GameStateEnum.PLAYING)
            {
                throw new InvalidOperationException("Cannot reset game while playing in process.");
            }
            ZeroScore();
            GameState = GameStateEnum.RESET;
            Field fieldToRandomize = new Field(fieldSettings);
            await fieldToRandomize.Randomize(fieldSettings);

            _scoreBoard.AutonomousFieldString = fieldSettings.AutonomousFieldString;
            _scoreBoard.StateOfPlay           = StateOfPlayEnum.RESET;
            Field = new Field(fieldSettings);
        }
示例#2
0
 public Field(FieldSettings fieldSettings)
 {
     if (fieldSettings.RedSwitchSettings != null)
     {
         RedSwitch = new Switch(fieldSettings.RedSwitchSettings);
     }
     if (fieldSettings.BlueSwitchSettings != null)
     {
         BlueSwitch = new Switch(fieldSettings.BlueSwitchSettings);
     }
     if (fieldSettings.ScaleSettings != null)
     {
         Scale = new Scale(fieldSettings.ScaleSettings);
     }
 }
示例#3
0
 public async Task Randomize(FieldSettings fieldSettings)
 {
     // Pass in field settings in order to wait for settings
     // to get updated by the field piece firmware
     fieldSettings.PrepareForRandomizationUpdates();
     if (RedSwitch != null)
     {
         await RedSwitch.Randomize();
     }
     if (BlueSwitch != null)
     {
         await BlueSwitch.Randomize();
     }
     if (Scale != null)
     {
         await Scale.Randomize();
     }
     fieldSettings.WaitForAllUpdates();
 }