Weiß jetzt jemand noch was zu meinem zweiten Problem? Hier noch mal die Methode:
Spoiler anzeigen
Funktionieren tuts, sieht aber etwas unschön aus. Deswegen frag ich wie man das besser lösen könnte.
C#-Quellcode
- private WabeFieldType CalculateFieldType(WabeType type, WabeDirection direction, int index)
- {
- var result = WabeFieldType.Center;
- switch (type)
- {
- case WabeType.TwoWabe:
- if (direction.HasFlag(WabeDirection.Up) && direction.HasFlag(WabeDirection.Left))
- {
- if (index == 0 || index == 1 || index == 2 || index == 3 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 5 || index == 7) result = WabeFieldType.Unpowered;
- }
- else if (direction.HasFlag(WabeDirection.Down) && direction.HasFlag(WabeDirection.Left))
- {
- if (index == 0 || index == 2 || index == 3 || index == 6 || index == 7 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 5 || index == 1) result = WabeFieldType.Unpowered;
- }
- else if (direction.HasFlag(WabeDirection.Up) && direction.HasFlag(WabeDirection.Right))
- {
- if (index == 0 || index == 1 || index == 2 || index == 5 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 3 || index == 7) result = WabeFieldType.Unpowered;
- }
- else if (direction.HasFlag(WabeDirection.Down) && direction.HasFlag(WabeDirection.Right))
- {
- if (index == 0 || index == 2 || index == 5 || index == 6 || index == 7 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 1 || index == 3) result = WabeFieldType.Unpowered;
- }
- break;
- case WabeType.ThreeWabe:
- if (direction == WabeDirection.Left)
- {
- if (index == 0 || index == 2 || index == 3 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 1 || index == 5 || index == 7) result = WabeFieldType.Unpowered;
- }
- else if (direction == WabeDirection.Right)
- {
- if (index == 0 || index == 2 || index == 5 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 1 || index == 3 || index == 7) result = WabeFieldType.Unpowered;
- }
- else if (direction == WabeDirection.Up)
- {
- if (index == 0 || index == 1 || index == 2 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 7 || index == 3 || index == 5) result = WabeFieldType.Unpowered;
- }
- else if (direction == WabeDirection.Down)
- {
- if (index == 0 || index == 2 || index == 6 || index == 7 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 3 || index == 5 || index == 1) result = WabeFieldType.Unpowered;
- }
- break;
- case WabeType.FourWabe:
- if (direction == WabeDirection.Mid)
- {
- if (index == 0 || index == 2 || index == 6 || index == 8) result = WabeFieldType.Unused;
- if (index == 4) result = WabeFieldType.Center;
- if (index == 1 || index == 3 || index == 5 || index == 7) result = WabeFieldType.Unpowered;
- }
- break;
- }
- return result;
- }
Funktionieren tuts, sieht aber etwas unschön aus. Deswegen frag ich wie man das besser lösen könnte.
KaskadekingDE on GitHub
Bitte keine Fragen über Programmierung per PN! Dafür ist das Forum hier.
Who cares? ¯\_(ツ)_/¯
Bitte keine Fragen über Programmierung per PN! Dafür ist das Forum hier.
Who cares? ¯\_(ツ)_/¯