Created
December 4, 2020 13:58
-
-
Save dmitryzenevich/c08a16526ce3698f0389874b0a21db1e to your computer and use it in GitHub Desktop.
Revisions
-
dmitryzenevich created this gist
Dec 4, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ using UnityEngine; public enum Shape { Rock, Paper, Scissors } public class TuplePatterns : MonoBehaviour { public Shape First; public Shape Second; public static string GetWinnerMessage(Shape first, Shape second) => (first, second) switch { (Shape.Rock, Shape.Paper) => "rock is covered by paper. Paper wins.", (Shape.Rock, Shape.Scissors) => "rock breaks scissors. Rock wins.", (Shape.Paper, Shape.Rock) => "paper covers rock. Paper wins.", (Shape.Paper, Shape.Scissors) => "paper is cut by scissors. Scissors wins.", (Shape.Scissors, Shape.Rock) => "scissors is broken by rock. Rock wins.", (Shape.Scissors, Shape.Paper) => "scissors cuts paper. Scissors wins.", (_, _) => "tie" }; void OnValidate() => Debug.Log(GetWinnerMessage(First, Second)); }