// Start is called before the first frame update void Start() { tessera = new Tessera(); if (tessera.getFunction() != null) { GetComponent <TMP_Text>().SetText($"{this.tessera.getFunction()}({this.tessera.getArg()})"); } else { GetComponent <TMP_Text>().SetText(this.tessera.getArg()); } }
private void useCard() { players[player].RemoveAt(current_card); if (equalToFirstCard) { foreach (GameObject go in gameCards) { var position = go.transform.position; position = new Vector3(position.x + 40f, position.y, position.z); go.transform.position = position; } gameCards.Insert(0, referenceCard); gameCards[0].transform.position = new Vector3(-252, 131); gameCards[0].transform.eulerAngles = new Vector3(0, 95, -65); gameCards[0].transform.localScale = new Vector3(1.5f, 1.5f, 0.7f); if (turnCard) { Tessera temp = gameCards[0].GetComponentsInChildren <setText>()[0].tessera; gameCards[0].GetComponentsInChildren <setText>()[0].tessera = gameCards[0].GetComponentsInChildren <setText>()[1].tessera; gameCards[0].GetComponentsInChildren <setText>()[1].tessera = temp; gameCards[0].GetComponentsInChildren <setText>()[0].rewrite(); gameCards[0].GetComponentsInChildren <setText>()[1].rewrite(); temp = gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[0].tessera; gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[0].tessera = gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[1].tessera; gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[1].tessera = temp; foreach (var setText in gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()) { setText.rewrite(); } } } else { Debug.Log($"index_anchored={index_card_to_achor}"); Debug.Log($"index_insert={index_card_to_insert}"); gameCards.Add(referenceCard); gameCards[gameCards.Count - 1].transform.position = new Vector3(this.space, 131f); if (turnCard) { Tessera temp = gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[0].tessera; gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[0].tessera = gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[1].tessera; gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[1].tessera = temp; gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[0].rewrite(); gameCards[gameCards.Count - 1].GetComponentsInChildren <setText>()[1].rewrite(); } } gameCards[gameCards.Count - 1].transform.eulerAngles = new Vector3(0, 95, -65); gameCards[gameCards.Count - 1].transform.localScale = new Vector3(1.5f, 1.5f, 0.7f); this.space += 40; changePlayer(); }
private string getGameCardData() { string str = "\n"; foreach (GameObject gameObject in gameCards) { foreach (setText setText in gameObject.GetComponentsInChildren <setText>()) { Tessera tessera = setText.tessera; str += $"{tessera}\tanchored = {tessera.anchored}\n"; } } return(str); }
//Checks for any Tesseras private void CheckForTessera() { Piece color = CurrentPiece.PieceColor; Tessera tessera = null; foreach (Tria t in CurrentPlayer.Trias) { Tuple <int, int> position1 = new Tuple <int, int>(t.StartingPoint.Item1 - t.Direction.Item1, t.StartingPoint.Item2 - t.Direction.Item2); Tuple <int, int> position2 = new Tuple <int, int>(t.StartingPoint.Item1 + (3 * t.Direction.Item1), t.StartingPoint.Item2 + (3 * t.Direction.Item2)); Tuple <int, int> position3 = new Tuple <int, int>(t.StartingPoint.Item1 - (2 * t.Direction.Item1), t.StartingPoint.Item2 - (2 * t.Direction.Item2)); Tuple <int, int> position4 = new Tuple <int, int>(t.StartingPoint.Item1 + (4 * t.Direction.Item1), t.StartingPoint.Item2 + (4 * t.Direction.Item2)); Tile t1 = GetPieceAtPosition(position1, CurrentPieces); Tile t2 = GetPieceAtPosition(position2, CurrentPieces); Tile t3 = GetPieceAtPosition(position3, CurrentPieces); Tile t4 = GetPieceAtPosition(position4, CurrentPieces); if (t1 != null && t1.PieceColor == color && t3 == null && t4 == null) { tessera = new Tessera() { StartingPoint = position1, Direction = t.Direction }; } else if (t2 != null && t2.PieceColor == color && t3 == null && t4 == null) { tessera = new Tessera() { StartingPoint = position2, Direction = new Tuple <int, int>(-t.Direction.Item1, -t.Direction.Item2) }; } foreach (Tessera tess in CurrentPlayer.Tesseras) { if (tess.Equals(tessera)) { tessera = null; } } if (tessera != null) { CurrentPlayer.Alerts = $"{CurrentPlayer.Name} has a Tessera!"; CurrentPlayer.Tesseras.Add(tessera); } } }
static void Main(string[] args) { Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(@" ██████╗ █████╗ ███╗ ███╗██████╗ ██████╗ ██╔════╝██╔══██╗████╗ ████║██╔══██╗██╔═══██╗ ██║ ███████║██╔████╔██║██████╔╝██║ ██║ ██║ ██╔══██║██║╚██╔╝██║██╔═══╝ ██║ ██║ ╚██████╗██║ ██║██║ ╚═╝ ██║██║ ╚██████╔╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ███╗ ███╗██╗███╗ ██╗ █████╗ ████████╗ ██████╗ ████╗ ████║██║████╗ ██║██╔══██╗╚══██╔══╝██╔═══██╗ ██╔████╔██║██║██╔██╗ ██║███████║ ██║ ██║ ██║ ██║╚██╔╝██║██║██║╚██╗██║██╔══██║ ██║ ██║ ██║ ██║ ╚═╝ ██║██║██║ ╚████║██║ ██║ ██║ ╚██████╔╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ "); Console.ResetColor(); int riga = 0; int colonne = 0; int numBombe = 0; string difficoltà = ""; Console.SetCursorPosition(30, 20); Console.WriteLine("In che difficoltà vuoi giocare?"); Console.SetCursorPosition(30, 22); Console.ResetColor(); difficoltà = Console.ReadLine(); if (difficoltà.Contains("facile")) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(" _____ _____ ____ _ _ _____"); Console.WriteLine(@"/ / / _ \ / _\ / \ / \ / __/"); Console.WriteLine(@"| __\ | / \ | | / | | | | | \ "); Console.WriteLine(@"| | | | | | | \_ | | | |____ | /_"); Console.WriteLine(@"\_/ \_/ \ | \____/ \_/ \____ / \____\"); Console.WriteLine("- 9 righe"); Console.WriteLine("- 9 colonne"); Console.WriteLine("- 10 righe "); Thread.Sleep(2000); Console.ResetColor(); riga = 9; colonne = 9; numBombe = 10; } if (difficoltà.ToLower().Contains("intermedio")) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(@".__ __ .___.__ |__| _____/ |_ ___________ _____ ____ __| _/|__| ____ | |/ \ __\/ __ \_ __ \/ \_/ __ \ / __ | | |/ _ \ | | | \ | \ ___/| | \/ Y Y \ ___// /_/ | | ( <_> ) |__|___| /__| \___ >__| |__|_| /\___ >____ | |__|\____/ \/ \/ \/ \/ \/ "); Console.WriteLine(" - 16 righe"); Console.WriteLine("- 16 colonne"); Console.WriteLine("- 40 righe "); Thread.Sleep(3000); Console.ResetColor(); riga = 16; colonne = 16; numBombe = 40; } if (difficoltà.ToLower().Contains("difficile")) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(@" .___.__ _____ _____.__ .__.__ __| _/|__|/ ____\/ ____\__| ____ |__| | ____ / __ | | \ __\\ __\| |/ ___\| | | _/ __ \ / /_/ | | || | | | | \ \___| | |_\ ___/ \____ | |__||__| |__| |__|\___ >__|____/\___ > \/ \/ \/ "); Console.WriteLine("- 30 righe"); Console.WriteLine("- 16 colonne"); Console.WriteLine("- 99 righe "); Thread.Sleep(3000); Console.ResetColor(); riga = 16; colonne = 30; numBombe = 99; } bool fine = false; Tessera[,] campoMinato = new Tessera[riga, colonne]; //stampo in base alla difficoltà scelta Stampa(campoMinato); Random gen = new Random(); //l'utente fa la prima mossa MossaGeneraBomba(campoMinato, riga, colonne); for (int i = 0; i < numBombe; i++) { bool bomba = false; while (!bomba) { int row = gen.Next(0, riga); int col = gen.Next(0, colonne); if (campoMinato[row, col].Bomba == false && campoMinato[row, col].CellaScoperta == false) { campoMinato[row, col].Bomba = true; bomba = true; } } } //Scansiona celle adiacenti BombeAd(campoMinato); int pos1 = 0; int pos2 = 1; //ciclo finchè uno dei due non vince while (!fine) { Mossa(campoMinato, riga, colonne, pos1, pos2); if (Vittoria(campoMinato, numBombe)) { Console.WriteLine("You Won!"); SpeechSynthesizer voice = new SpeechSynthesizer(); voice.Speak("You Won!"); fine = true; } if (Sconfitta(campoMinato)) { Console.WriteLine("Game over"); SpeechSynthesizer voice = new SpeechSynthesizer(); voice.Speak("Game Over!"); fine = true; } } }