blob: 3a4c093026538bf5b5f4144aa5a1ed26b1bd1f86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using System;
using UnityEngine;
using UnityEngine.Events;
public class ReloadTigger : MonoBehaviour
{
public UnityEvent reloadDoneEvent;
public UnityEvent outOfAmmoEvent;
private void Start()
{
CharacterStatModifiers componentInParent = GetComponentInParent<CharacterStatModifiers>();
componentInParent.OnReloadDoneAction = (Action<int>)Delegate.Combine(componentInParent.OnReloadDoneAction, new Action<int>(OnReloadDone));
CharacterStatModifiers componentInParent2 = GetComponentInParent<CharacterStatModifiers>();
componentInParent2.OutOfAmmpAction = (Action<int>)Delegate.Combine(componentInParent2.OutOfAmmpAction, new Action<int>(OnOutOfAmmo));
}
private void OnDestroy()
{
CharacterStatModifiers componentInParent = GetComponentInParent<CharacterStatModifiers>();
componentInParent.OnReloadDoneAction = (Action<int>)Delegate.Remove(componentInParent.OnReloadDoneAction, new Action<int>(OnReloadDone));
CharacterStatModifiers componentInParent2 = GetComponentInParent<CharacterStatModifiers>();
componentInParent2.OutOfAmmpAction = (Action<int>)Delegate.Remove(componentInParent2.OutOfAmmpAction, new Action<int>(OnOutOfAmmo));
}
private void OnReloadDone(int bulletsReloaded)
{
reloadDoneEvent.Invoke();
}
private void OnOutOfAmmo(int bulletsReloaded)
{
outOfAmmoEvent.Invoke();
}
private void Update()
{
}
}
|