Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,624 changes: 3,973 additions & 651 deletions Assets/Scenes/Level1.unity

Large diffs are not rendered by default.

4,967 changes: 4,346 additions & 621 deletions Assets/Scenes/Level2.unity

Large diffs are not rendered by default.

4,594 changes: 4,049 additions & 545 deletions Assets/Scenes/Level3.unity

Large diffs are not rendered by default.

6,325 changes: 4,970 additions & 1,355 deletions Assets/Scenes/Level4.unity

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions Assets/Scripts/PillarInteractor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using UnityEngine;
using TMPro;

public class PillarInteractor : MonoBehaviour
{
public GameObject minigameCanvas;
public TextMeshProUGUI interactionPromptText;

private bool playerIsNear = false;

void Start()
{
if (interactionPromptText != null)
{
interactionPromptText.gameObject.SetActive(false);
}
}

void Update()
{
if (playerIsNear && !minigameCanvas.activeSelf && Input.GetKeyDown(KeyCode.E))
{
ActivateMinigame();
}
}

private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
playerIsNear = true;
if (interactionPromptText != null)
{
interactionPromptText.text = "Press [E] to Play Tic-Tac-Toe";
interactionPromptText.gameObject.SetActive(true);
}
}
}

private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
playerIsNear = false;
if (interactionPromptText != null)
{
interactionPromptText.gameObject.SetActive(false);
}
}
}

private void ActivateMinigame()
{
if (minigameCanvas != null)
{
minigameCanvas.SetActive(true);
Time.timeScale = 0f;
if (interactionPromptText != null)
{
interactionPromptText.gameObject.SetActive(false);
}
}
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/PillarInteractor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions Assets/Scripts/PlayerCollectibles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,44 @@ private IEnumerator InvincibilityRoutine(float duration)
{
IsInvincible = true;
var renderers = GetComponentsInChildren<Renderer>();

foreach (var r in renderers)
{
if (r.material != null)
{
Color c = r.material.color;
r.material.color = new Color(c.r, c.g, c.b, 0.5f);
var mat = r.material;

if (mat.HasProperty("_Color"))
{
Color c = mat.color;
mat.color = new Color(c.r, c.g, c.b, 0.5f);
}
else if (mat.HasProperty("_TintColor"))
{
Color c = mat.GetColor("_TintColor");
mat.SetColor("_TintColor", new Color(c.r, c.g, c.b, 0.5f));
}
}
}

yield return new WaitForSeconds(duration);

foreach (var r in renderers)
{
if (r.material != null)
{
Color c = r.material.color;
r.material.color = new Color(c.r, c.g, c.b, 1f);
var mat = r.material;

if (mat.HasProperty("_Color"))
{
Color c = mat.color;
mat.color = new Color(c.r, c.g, c.b, 1f);
}
else if (mat.HasProperty("_TintColor"))
{
Color c = mat.GetColor("_TintColor");
mat.SetColor("_TintColor", new Color(c.r, c.g, c.b, 1f));
}
}
}

Expand Down
194 changes: 194 additions & 0 deletions Assets/Scripts/TicTacToeManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class TicTacToeManager : MonoBehaviour
{

public Button[] buttons = new Button[9];
public TextMeshProUGUI statusText;
public GameObject gameOverPanel;
public GameObject minigameCanvas;

private char[] board = new char[9];
private bool isPlayerTurn = true;
private bool gameOver = false;
private int movesMade = 0;

private bool isAwaitingAIMove = false;

void Start()
{
InitializeGame();
}

void Update()
{
if (isAwaitingAIMove)
{
isAwaitingAIMove = false;
AITurn();
}
}
private void InitializeGame()
{
for (int i = 0; i < 9; i++)
{
board[i] = ' ';
}
for (int i = 0; i < buttons.Length; i++)
{
buttons[i].GetComponentInChildren<TextMeshProUGUI>().text = "";
buttons[i].interactable = true;

int index = i;
buttons[i].onClick.RemoveAllListeners();
buttons[i].onClick.AddListener(() => OnButtonClick(index));
}
isPlayerTurn = true;
gameOver = false;
movesMade = 0;
isAwaitingAIMove = false;
gameOverPanel.SetActive(false);
UpdateStatusText("Your turn (X)");
}
private void UpdateStatusText(string message)
{
statusText.text = message;
}

public void OnButtonClick(int index)
{
if (board[index] != ' ' || gameOver || !isPlayerTurn)
{
return;
}

MakeMove(index, 'X');
isPlayerTurn = false;
if (!gameOver)
{
UpdateStatusText("AI's turn (O)...");
isAwaitingAIMove = true;
}
}

private void MakeMove(int index, char player)
{
board[index] = player;
buttons[index].GetComponentInChildren<TextMeshProUGUI>().text = player.ToString();
buttons[index].interactable = false;
movesMade++;

if (CheckWin(player))
{
GameOver(player.ToString() + " wins!");
}
else if (movesMade == 9)
{
GameOver("It's a draw!");
}
}

private void AITurn()
{
if (gameOver) return;

int bestMove = GetBestMove();

if (bestMove != -1)
{
MakeMove(bestMove, 'O');
}

if (!gameOver)
{
isPlayerTurn = true;
UpdateStatusText("Your turn (X)");
}
}

private int GetBestMove()
{
for (int i = 0; i < 9; i++)
{
if (board[i] == ' ')
{
board[i] = 'O';
if (CheckWin('O'))
{
board[i] = ' '; return i;
}
board[i] = ' ';
}
}

for (int i = 0; i < 9; i++)
{
if (board[i] == ' ')
{
board[i] = 'X';
if (CheckWin('X'))
{
board[i] = ' '; return i;
}
board[i] = ' ';
}
}

if (board[4] == ' ') return 4;
int[] corners = { 0, 2, 6, 8 };
foreach (int corner in corners)
{
if (board[corner] == ' ') return corner;
}
for (int i = 0; i < 9; i++)
{
if (board[i] == ' ')
{
return i;
}
}
return -1;
}
private bool CheckWin(char player)
{
int[,] winningLines = new int[,]
{
{0, 1, 2}, {3, 4, 5}, {6, 7, 8},
{0, 3, 6}, {1, 4, 7}, {2, 5, 8},
{0, 4, 8}, {2, 4, 6}
};

for (int i = 0; i < 8; i++)
{
if (board[winningLines[i, 0]] == player &&
board[winningLines[i, 1]] == player &&
board[winningLines[i, 2]] == player)
{
return true;
}
}
return false;
}

private void GameOver(string message)
{
gameOver = true;
UpdateStatusText("Game Over: " + message);
for (int i = 0; i < buttons.Length; i++)
{
buttons[i].interactable = false;
}
gameOverPanel.SetActive(true);
}
public void PlayAgain()
{
InitializeGame();
}
public void CloseGame()
{
minigameCanvas.SetActive(false);
Time.timeScale = 1f;
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/TicTacToeManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Assets/Settings/UniversalRenderPipelineGlobalSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ MonoBehaviour:
references:
version: 2
RefIds:
- rid: -2
type: {class: , ns: , asm: }
- rid: 2100176707506143232
type: {class: RenderingDebuggerRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
Expand Down Expand Up @@ -240,6 +242,9 @@ MonoBehaviour:
m_AutodeskInteractive: {fileID: 4800000, guid: 0e9d5a909a1f7e84882a534d0d11e49f, type: 3}
m_AutodeskInteractiveTransparent: {fileID: 4800000, guid: 5c81372d981403744adbdda4433c9c11, type: 3}
m_AutodeskInteractiveMasked: {fileID: 4800000, guid: 80aa867ac363ac043847b06ad71604cd, type: 3}
m_TerrainDetailLit: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144, type: 3}
m_TerrainDetailGrassBillboard: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90, type: 3}
m_TerrainDetailGrass: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1, type: 3}
m_DefaultSpeedTree7Shader: {fileID: 4800000, guid: 0f4122b9a743b744abe2fb6a0a88868b, type: 3}
m_DefaultSpeedTree8Shader: {fileID: -6465566751694194690, guid: 9920c1f1781549a46ba081a2a15a16ec, type: 3}
m_DefaultSpeedTree9Shader: {fileID: -6465566751694194690, guid: cbd3e1cc4ae141c42a30e33b4d666a61, type: 3}
Expand All @@ -250,8 +255,6 @@ MonoBehaviour:
m_CopyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
m_CameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, type: 3}
m_StencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
m_ClusterDeferred: {fileID: 4800000, guid: 222cce62363a44a380c36bf03b392608, type: 3}
m_StencilDitherMaskSeedPS: {fileID: 4800000, guid: 8c3ee818f2efa514c889881ccb2e95a2, type: 3}
m_DBufferClear: {fileID: 4800000, guid: f056d8bd2a1c7e44e9729144b4c70395, type: 3}
- rid: 6852985685364965379
type: {class: UniversalRenderPipelineDebugShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Material:
- _WeightNormal: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _FaceColor: {r: 0.07169801, g: 0.07093251, b: 0.06696323, a: 1}
- _FaceColor: {r: 0.90943396, g: 0.90943396, b: 0.7395585, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
Expand Down
Loading
Loading