Implemented chest pop up and gaining ability upon completing a room with a chest reward.
This commit is contained in:
parent
90b9e2689a
commit
fdeab50984
15 changed files with 1185 additions and 997 deletions
|
|
@ -19,10 +19,12 @@ namespace Abilities
|
|||
|
||||
private void OnEnable() {
|
||||
GameManager.StateChanged += HandleStateChanged;
|
||||
ChestRewardSelection.BlackDiceAbilitySelected += HandleBlackDieAbilityGained;
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
GameManager.StateChanged -= HandleStateChanged;
|
||||
ChestRewardSelection.BlackDiceAbilitySelected -= HandleBlackDieAbilityGained;
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
|
|
@ -71,6 +73,12 @@ namespace Abilities
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleBlackDieAbilityGained()
|
||||
{
|
||||
abilityUseOne.GetComponent<Button>().interactable = true;
|
||||
abilityUseTwo.GetComponent<Button>().interactable = true;
|
||||
abilityUseThree.GetComponent<Button>().interactable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChestRewardSelection : MonoBehaviour
|
||||
{
|
||||
public static event Action DiamondAndLifeSelected;
|
||||
public static event Action TorchAbilitySelected;
|
||||
public static event Action BlackDiceAbilitySelected;
|
||||
|
||||
[SerializeField] private Button diamondAndLifeButton;
|
||||
[SerializeField] private Button torchButton;
|
||||
[SerializeField] private Button blackDiceButton;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
RoomReward.ChestRewarded += HandChestRewarded;
|
||||
diamondAndLifeButton.onClick.AddListener(HandleDiamondAndLifeSelected);
|
||||
torchButton.onClick.AddListener(HandleTorchSelected);
|
||||
blackDiceButton.onClick.AddListener(HandleBlackDiceSelected);
|
||||
}
|
||||
|
||||
private void HandChestRewarded()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void HandleDiamondAndLifeSelected()
|
||||
{
|
||||
diamondAndLifeButton.interactable = false;
|
||||
DiamondAndLifeSelected?.Invoke();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void HandleTorchSelected()
|
||||
{
|
||||
torchButton.interactable = false;
|
||||
TorchAbilitySelected?.Invoke();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void HandleBlackDiceSelected()
|
||||
{
|
||||
blackDiceButton.interactable = false;
|
||||
BlackDiceAbilitySelected?.Invoke();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4723029f5ae5a994d81f1fd4287eb808
|
||||
|
|
@ -17,11 +17,13 @@ public class TorchAbility : MonoBehaviour
|
|||
private void OnEnable()
|
||||
{
|
||||
GameManager.StateChanged += HandleStateChanged;
|
||||
ChestRewardSelection.TorchAbilitySelected += HandleGainedTorchAbility;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameManager.StateChanged -= HandleStateChanged;
|
||||
ChestRewardSelection.TorchAbilitySelected -= HandleGainedTorchAbility;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
|
@ -55,4 +57,10 @@ public class TorchAbility : MonoBehaviour
|
|||
{
|
||||
_canClick = true;
|
||||
}
|
||||
|
||||
private void HandleGainedTorchAbility()
|
||||
{
|
||||
abilityUseOne.GetComponent<Button>().interactable = true;
|
||||
abilityUseTwo.GetComponent<Button>().interactable = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ public class EmptyRoom : Room
|
|||
public override void SetRoomExplored() {
|
||||
_isExplored = true;
|
||||
UnhighlightRoomAsOption();
|
||||
if (roomReward != null)
|
||||
{
|
||||
roomReward.TriggerGetReward();
|
||||
}
|
||||
gameObject.GetComponent<SpriteRenderer>().color =
|
||||
ColorHelper.AddColorTint(gameObject.GetComponent<SpriteRenderer>().color, Color.grey, 0.5f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ public class MonsterRoom : Room
|
|||
{
|
||||
_isExplored = true;
|
||||
UnhighlightRoomAsOption();
|
||||
if (roomReward != null)
|
||||
{
|
||||
roomReward.TriggerGetReward();
|
||||
}
|
||||
gameObject.GetComponent<SpriteRenderer>().color =
|
||||
ColorHelper.AddColorTint(gameObject.GetComponent<SpriteRenderer>().color, Color.grey, 0.5f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public abstract class Room : MonoBehaviour
|
|||
{
|
||||
[SerializeField] private List<GameObject> adjacentRooms;
|
||||
[SerializeField] private bool isEntrance;
|
||||
[SerializeField] protected RoomReward roomReward;
|
||||
public event EventHandler<Room> RoomExploredByDice;
|
||||
public static event Action<Room> RoomExploredByTorch;
|
||||
private Color _roomNumberOriginalColor;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ public class RoomReward : MonoBehaviour
|
|||
public static event Action<int> DamageDealt;
|
||||
|
||||
[SerializeField] private int diamonds;
|
||||
[SerializeField] private bool chest;
|
||||
[SerializeField] private int damage;
|
||||
[SerializeField] private bool chest;
|
||||
|
||||
public void TriggerGetReward()
|
||||
{
|
||||
|
|
|
|||
17
PuzzleGameProject/Assets/Scripts/UIManager.cs
Normal file
17
PuzzleGameProject/Assets/Scripts/UIManager.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject canvas;
|
||||
[SerializeField] private GameObject chestRewardSelectionUI;
|
||||
private void OnEnable()
|
||||
{
|
||||
RoomReward.ChestRewarded += HandleChestRewarded;
|
||||
}
|
||||
|
||||
private void HandleChestRewarded()
|
||||
{
|
||||
Instantiate(chestRewardSelectionUI, canvas.transform);
|
||||
}
|
||||
}
|
||||
2
PuzzleGameProject/Assets/Scripts/UIManager.cs.meta
Normal file
2
PuzzleGameProject/Assets/Scripts/UIManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a277ce4246f154447a52f88a6c9937e0
|
||||
Loading…
Add table
Add a link
Reference in a new issue