This class invokes the event.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpecialTurn : BattleState
{
public static event StateAction onEnterSpecial;
public static event StateAction onExitSpecial;
public override void EnterState()
{
if (onEnterSpecial != null)
{
StartCoroutine(timer());
onEnterSpecial.Invoke();
Debug.Log("Timerdan önce");
}
}
public override void ExitState()
{
onExitSpecial?.Invoke();
}
public override void updateState()
{
throw new System.NotImplementedException();
}
public IEnumerator timer()
{
for (float time = 10; time >= 0; time -= Time.deltaTime)
{
//Add UI some timer component
//Timer.setTime(time);
Debug.Log("Time : " + time);
yield return null;
}
ExitState();
}
}
This class receives the onEnterSpecial event
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayAreaHandler : MonoBehaviour
{
private void OnEnable()
{
SpecialTurn.onEnterSpecial += enableEnemyTurnCardArea;
SpecialTurn.onExitSpecial += disableEnemyTurnCardArea;
}
private void OnDisable()
{
SpecialTurn.onEnterSpecial -= enableEnemyTurnCardArea;
SpecialTurn.onExitSpecial -= disableEnemyTurnCardArea;
}
public void enableEnemyTurnCardArea()
{
enemyTurnBox.SetActive(true);
}
public void disableEnemyTurnCardArea()
{
Debug.Log("Play area içindeyim");
enemyTurnBox.SetActive(false);
}
}
onSpecialEnter successfully invokes another class but does not invoke this. Do you have any idea why this happens?