- Added an option for instant effects to generate class resource per hit for the user - fixed an issue where some extended ability scripts were not spending all required resources (inheritance issue) - Added a class-based melee ability for Mages - Added a class Signature ability for Mages to make use of class resource
59 lines
1.2 KiB
C#
59 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)
|
|
{
|
|
if (value == 0) return;
|
|
Debug.Log("Class resource change value:" + 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);
|
|
}
|
|
}
|