Implemented armor and diamond ability
This commit is contained in:
parent
c42406e615
commit
0c4592ac7c
6 changed files with 113 additions and 1 deletions
|
|
@ -255,6 +255,7 @@ MonoBehaviour:
|
||||||
blackDieAbility: {fileID: 37414492}
|
blackDieAbility: {fileID: 37414492}
|
||||||
chestRewardSelection: {fileID: 1772543310}
|
chestRewardSelection: {fileID: 1772543310}
|
||||||
torchAbility: {fileID: 1015377333}
|
torchAbility: {fileID: 1015377333}
|
||||||
|
armorAbility: {fileID: 802557996}
|
||||||
player: {fileID: 386902759}
|
player: {fileID: 386902759}
|
||||||
--- !u!4 &323570089
|
--- !u!4 &323570089
|
||||||
Transform:
|
Transform:
|
||||||
|
|
@ -1236,6 +1237,7 @@ RectTransform:
|
||||||
- {fileID: 37414491}
|
- {fileID: 37414491}
|
||||||
- {fileID: 27283140}
|
- {fileID: 27283140}
|
||||||
- {fileID: 1015377332}
|
- {fileID: 1015377332}
|
||||||
|
- {fileID: 802557995}
|
||||||
m_Father: {fileID: 748138896}
|
m_Father: {fileID: 748138896}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
|
@ -1281,6 +1283,56 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 801256674}
|
m_GameObject: {fileID: 801256674}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &802557994
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 802557995}
|
||||||
|
- component: {fileID: 802557996}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: ArmorAndDiamond
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &802557995
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 802557994}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 801256675}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &802557996
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 802557994}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8a78399457cb0c74b9140b3ea8b42870, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
player: {fileID: 386902759}
|
||||||
|
maxUses: 3
|
||||||
--- !u!1001 &864735004
|
--- !u!1001 &864735004
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
46
PuzzleGameProject/Assets/Scripts/Abilities/ArmorAbility.cs
Normal file
46
PuzzleGameProject/Assets/Scripts/Abilities/ArmorAbility.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Abilities
|
||||||
|
{
|
||||||
|
public class ArmorAbility : MonoBehaviour
|
||||||
|
{
|
||||||
|
public event Action MarkAbilityUsed;
|
||||||
|
public event Action ArmorAbilityGained;
|
||||||
|
|
||||||
|
[SerializeField] private Player player;
|
||||||
|
[SerializeField] private int maxUses;
|
||||||
|
private int currentUses;
|
||||||
|
|
||||||
|
private bool _abilityAcive;
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
ChestRewardSelection.DiamondAndLifeSelected += HandleAbilityAcitvated;
|
||||||
|
player.DamageTaken += HandleDamageDealt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleDamageDealt(int damage)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < damage; i++)
|
||||||
|
{
|
||||||
|
if (_abilityAcive)
|
||||||
|
{
|
||||||
|
player.Heal(1);
|
||||||
|
currentUses--;
|
||||||
|
MarkAbilityUsed?.Invoke();
|
||||||
|
if (currentUses < 1)
|
||||||
|
{
|
||||||
|
_abilityAcive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleAbilityAcitvated()
|
||||||
|
{
|
||||||
|
ArmorAbilityGained?.Invoke();
|
||||||
|
_abilityAcive = true;
|
||||||
|
currentUses = maxUses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a78399457cb0c74b9140b3ea8b42870
|
||||||
|
|
@ -6,7 +6,8 @@ using UnityEngine.Serialization;
|
||||||
public class Player : MonoBehaviour
|
public class Player : MonoBehaviour
|
||||||
{
|
{
|
||||||
public event Action<int> DiamondCountUpdated;
|
public event Action<int> DiamondCountUpdated;
|
||||||
public event Action<int> HealthUpdated;
|
public event Action<int> HealthUpdated;
|
||||||
|
public event Action<int> DamageTaken;
|
||||||
|
|
||||||
[SerializeField] private int maxHealth;
|
[SerializeField] private int maxHealth;
|
||||||
[SerializeField] private int diamonds;
|
[SerializeField] private int diamonds;
|
||||||
|
|
@ -44,6 +45,7 @@ public class Player : MonoBehaviour
|
||||||
_healthIndex += damage;
|
_healthIndex += damage;
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
DamageTaken?.Invoke(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Heal(int healAmount)
|
public void Heal(int healAmount)
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,12 @@ namespace UI
|
||||||
_blackDieAbilityUsesUsed--;
|
_blackDieAbilityUsesUsed--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MarkArmorAbilityUsed()
|
||||||
|
{
|
||||||
|
_armorUses[_armorUsesUsed].value = true;
|
||||||
|
_armorUsesUsed++;
|
||||||
|
}
|
||||||
|
|
||||||
public void MarkStartingBlackDieAbilityUsed()
|
public void MarkStartingBlackDieAbilityUsed()
|
||||||
{
|
{
|
||||||
_startingBlackDieAbilityUses[_startingBlackDieAbilityUsesUsed].value = true;
|
_startingBlackDieAbilityUses[_startingBlackDieAbilityUsesUsed].value = true;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ namespace UI
|
||||||
[SerializeField] private BlackDieAbility blackDieAbility;
|
[SerializeField] private BlackDieAbility blackDieAbility;
|
||||||
[SerializeField] private ChestRewardSelection chestRewardSelection;
|
[SerializeField] private ChestRewardSelection chestRewardSelection;
|
||||||
[SerializeField] private TorchAbility torchAbility;
|
[SerializeField] private TorchAbility torchAbility;
|
||||||
|
[SerializeField] private ArmorAbility armorAbility;
|
||||||
[SerializeField] private Player player;
|
[SerializeField] private Player player;
|
||||||
|
|
||||||
public static UIManager Instance { get; private set; }
|
public static UIManager Instance { get; private set; }
|
||||||
|
|
@ -73,6 +74,9 @@ namespace UI
|
||||||
|
|
||||||
player.DiamondCountUpdated += hudController.SetDiamondCount;
|
player.DiamondCountUpdated += hudController.SetDiamondCount;
|
||||||
player.HealthUpdated += hudController.SetHealth;
|
player.HealthUpdated += hudController.SetHealth;
|
||||||
|
|
||||||
|
armorAbility.ArmorAbilityGained += hudController.SetArmorAbilityEnabled;
|
||||||
|
armorAbility.MarkAbilityUsed += hudController.MarkArmorAbilityUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue