Implemented both dice selections

This commit is contained in:
Max 2025-01-20 14:59:33 +01:00
parent 2b08dc425f
commit d04624edfd
9 changed files with 182 additions and 29 deletions

View file

@ -1,37 +1,102 @@
using System;
using UnityEngine;
using Object = UnityEngine.Object;
using System.Collections.Generic;
public enum GameState
{
PickRoom,
RollDice
PickRoomOne,
PickRoomTwo,
PickDiceOne,
PickDiceTwo,
}
public class GameManager : MonoBehaviour
{
public GameState state;
public GameObject rooms;
public GameObject dice;
public DiceRoller diceRoller;
private (Die, Die) _dicePairOne = (null, null);
private (Die, Die) _dicePairTwo = (null, null);
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
state = GameState.RollDice;
state = GameState.PickDiceOne;
foreach (Transform roomTransform in rooms.transform)
{
roomTransform.gameObject.GetComponent<Room>().ValidRoomClicked += ValidRoomClicked;
}
foreach (Transform diceTransform in dice.transform)
{
diceTransform.gameObject.GetComponent<Die>().DieClicked += DieClicked;
}
diceRoller.RollDice();
}
void ValidRoomClicked(object sender, Room room) {
if (state == GameState.PickRoom)
if (state != GameState.PickRoomOne && state != GameState.PickRoomTwo)
{
room.SetRoomExplored();
return;
}
room.SetRoomExplored();
if (state == GameState.PickRoomOne)
{
state = GameState.PickDiceTwo;
}
else
{
// Not implemented
}
}
void DieClicked(object sender, Die die)
{
if (state != GameState.PickDiceOne && state != GameState.PickDiceTwo)
{
return;
}
if (state == GameState.PickDiceOne)
{
if (_dicePairOne.Item1 == null && _dicePairOne.Item2 == null)
{
_dicePairOne.Item1 = die;
die.DieBeingUsed(true, false);
}
else if (_dicePairOne.Item2 == null)
{
_dicePairOne.Item2 = die;
_dicePairOne.Item1.DieBeingUsed(true, true);
die.DieBeingUsed(true, true);
}
if (_dicePairOne.Item1 != null && _dicePairOne.Item2 != null)
{
state = GameState.PickRoomOne;
}
}
else if(state == GameState.PickDiceTwo)
{
if (_dicePairTwo.Item1 == null && _dicePairTwo.Item2 == null)
{
_dicePairTwo.Item1 = die;
die.DieBeingUsed(false, false);
}
else if (_dicePairTwo.Item2 == null)
{
_dicePairTwo.Item2 = die;
_dicePairTwo.Item1.DieBeingUsed(false, true);
die.DieBeingUsed(false, true);
}
if (_dicePairTwo.Item1 != null && _dicePairTwo.Item2 != null)
{
state = GameState.PickRoomTwo;
}
}
}
void SetUpDice() {
}
}