void ArcadeOutput(object sender, IntCodeOutputEventArgs e) { outputCache.Add(e.OutputValue); if (outputCache.Count < 3) { return; } var x = outputCache[0]; var y = outputCache[1]; if (x == -1 && y == 0) { Score = outputCache[2]; } else { var location = new Point((int)x, (int)y); var tile = (TileType)outputCache[2]; if (TileGrid.ContainsKey(location)) { TileGrid[location] = tile; } else { TileGrid.Add(location, tile); } } outputCache.Clear(); }
void Cpu_Output(object sender, IntCodeOutputEventArgs e) { outputCount++; switch (outputCount) { case 1: DoPaintHull((HullColor)e.OutputValue); break; case 2: DoRotateAndMove((TurnDirection)e.OutputValue); break; default: break; } if (outputCount == 2) { outputCount = 0; } }
void Cpu_OnOutput(object sender, IntCodeOutputEventArgs e) { var code = (RepairDroidStatusCode)e.OutputValue; var args = new ReportStatusEventArgs(code); switch (code) { case RepairDroidStatusCode.HitWall: map.Set(CalcNewPosition(LastMoveDirection), MapLegend.Wall); break; case RepairDroidStatusCode.MovedOneStep: MoveToNewPosition(LastMoveDirection); var lastTile = MapLegend.Hall; if (LastLocation == startPoint) { lastTile = MapLegend.Start; } if (LastLocation == o2Location) { lastTile = MapLegend.O2Generator; } map.Set(LastLocation, lastTile); map.Set(Location, MapLegend.Droid); break; case RepairDroidStatusCode.MovedOneStep_AtDestination: MoveToNewPosition(LastMoveDirection); map.Set(LastLocation, MapLegend.Hall); map.Set(Location, MapLegend.O2Generator); o2Location = Location; break; } LastLocation = Location; LastMoveDirection = MoveDirection; ReportStatus(this, args); }