RiftMayhem/Assets/Scripts/ClassResource.cs
Pedro Gomes e1081a2bf4 Necromancer and Minions update
- Necromancer class playable
- Savage minion ability & npc
- Mage minion ability & npc
- rogue minion ability & npc
- warrior minion ability & npc
- golem minion ability & npc
- minion abilities
- Class resource (used to automatically summon minions based on the amount of souls drained, in case of necromancer)
- class resource spender (auto cast from priority list)
- class resource regen instant effect option
2024-07-22 16:46:13 +01:00

56 lines
1.2 KiB
C#

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class ClassResource : Resource
{
[HideInInspector]
public PhotonView photonView;
private void Awake()
{
photonView = GetComponent<PhotonView>();
}
protected override void Start()
{
currentValue = 0f;
onResourceChanged.Invoke(currentValue);
canRegen = false;
}
public override void ChangeValue(float value)
{
currentValue += value;
currentValue = Mathf.Clamp(currentValue, 0, maxValue);
onResourceChanged.Invoke(currentValue);
}
public override void SetCurrentValue(float value)
{
currentValue = value;
currentValue = Mathf.Clamp(currentValue, 0, maxValue);
onResourceChanged.Invoke(currentValue);
}
public bool EnoughResource(float cost)
{
return currentValue >= cost;
}
[PunRPC]
public void RPC_ChangeValueClassResource(float value)
{
if (!photonView.IsMine) return;
Debug.Log("Received ChangeValue from RPC from someone");
ChangeValue(value);
}
}