// Update is called once per frame void Update() { int currentPlayerToDisplay = 1; if (player1.enabled && player2.enabled) { currentPlayerToDisplay = boardBehaviour.currentPlayer; } if (boardBehaviour.GetTileState(x, y) == 0) { contents = boardBehaviour.GetTileScore(x, y, currentPlayerToDisplay); if (contents < 10 && contents > 0) { textMesh.text = contents.ToString(); } else if (contents > 9) { textMesh.text = "+"; } else { textMesh.text = ""; } } else { textMesh.text = ""; } Color tempColour = textMesh.color; tempColour.a = (0.3f + 0.1f * contents) + (0.05F - (float)(rand.NextDouble() / 10)); textMesh.color = tempColour; }
// Method to place a tile on the board. public void UpdateAI() { int highestX = -1; //The x co-ordinate of the current highest scoring tile int highestY = -1; //The y co-ordinate of the current highest scoring tile int highestScore = 0; //The highest score found so far int currentScore; //The score of the current tile being compared if (boardBehaviour.currentPlayer == playerNumber) { for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if (boardBehaviour.CanPlaceTile(x, y, playerNumber)) { currentScore = boardBehaviour.GetTileScore(x, y, playerNumber); if (currentScore > highestScore && boardBehaviour.GetTileState(x, y) == 0) { highestScore = currentScore; highestX = x; highestY = y; } } } } if (highestX != -1 && highestY != -1) { boardBehaviour.SetTileState(highestX, highestY, playerNumber); } boardBehaviour.TurnComplete(); } }
// Update is called once per frame void Update() { spriteRenderer.material.SetColor("_Color", currentColour); owner = boardBehaviour.GetTileState(x, y); //Who does this tile belong to? switch (owner) { case 0: tintColour = lightCyan; break; case 1: tintColour = deepPink; break; case 2: tintColour = deepCyan; break; } if (currentColour != tintColour || currentOpacity != opacity) { time = 0; fading = true; } else { fading = false; } if (fading) { time += Time.deltaTime; currentColour = Color.Lerp(currentColour, tintColour, time * fadeSpeed); currentOpacity = Mathf.Lerp(currentOpacity, opacity, time * fadeSpeed); currentColour.a = currentOpacity; } }