XIPU27GAVXMAKDP42DDSYNA6DSN5WBHH6AG4EK6YIIM43AQQHQAAC
5I5QA3YK5G5QQCXMSDOEAX3A74LVXV7PYWAIHMLFANR2GUFWMKGQC
XF52N4U7HWXOF4PDSCR7LCUENLTSXLWEZGS2IJ6562KYI567Z2GAC
R5JJA7VQ5HCQ6TZEFMORFMPYBXTMIOBAH6YMDCG4QZKBJZCQLR4AC
MDJQTAONL4M7SFFORMXLJHA7WBDTDTRZAZ544JR23SODSCWSVZ3AC
NZIEX6J6Q6DSJKNSCTHNIA6EJDQEGMK3ZSP3LKX2UAEDHURQPRVQC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
LTG4LQJEMFY22QOI6E5HM3U4OE3JCYRFJ6VGW3KI3AFTMHZCTWRAC
PlayerKeyActions.onTimeDilationSpeedUp += PlayerKeyActions_onTimeDilationSpeedUp;
PlayerKeyActions.onTimeDilationSpeedDown += PlayerKeyActions_onTimeDilationSpeedDown;
PlayerKeyActions.onTimeDilationSpeedReset += PlayerKeyActions_onTimeDilationSpeedReset;
eventAggregator.onTimeDilationSpeedUp += PlayerKeyActions_onTimeDilationSpeedUp;
eventAggregator.onTimeDilationSpeedDown += PlayerKeyActions_onTimeDilationSpeedDown;
eventAggregator.onTimeDilationSpeedReset += PlayerKeyActions_onTimeDilationSpeedReset;
void OnDestroy() {
print("TimeDilationController OnDestroy");
eventAggregator.onTimeDilationSpeedUp -= PlayerKeyActions_onTimeDilationSpeedUp;
eventAggregator.onTimeDilationSpeedDown -= PlayerKeyActions_onTimeDilationSpeedDown;
eventAggregator.onTimeDilationSpeedReset -= PlayerKeyActions_onTimeDilationSpeedReset;
}
private void Test() {
TimeDialationTester timeDialationTester = new TimeDialationTester(eventAggregator);
timeDialationTester.TestTimeDialationSpeedUp();
timeDialationTester.TestTimeDialationSpeedDown();
timeDialationTester.TestTimeDialationSpeedPause();
timeDialationTester.TestTimeDialationSpeedReset();
}
namespace Testing {
public class TimeDialationTester {
EventAggregator _eventAggregator;
public TimeDialationTester(EventAggregator eventAggregator) {
_eventAggregator = eventAggregator;
}
public void TestTimeDialationSpeedUp() {
float currentTimeScale = Time.timeScale;
string testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.InvokeOnTimeDilationSpeedUp(this, System.EventArgs.Empty);
if (Time.timeScale > currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
} else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedDown() {
float currentTimeScale = Time.timeScale;
string testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.InvokeOnTimeDilationSpeedDown(this, System.EventArgs.Empty);
if (Time.timeScale < currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
} else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedPause() {
float currentTimeScale = Time.timeScale;
string testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.InvokeOnTimeDilationSpeedPause(this, System.EventArgs.Empty);
if (Time.timeScale == 0) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
} else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedReset() {
float currentTimeScale = Time.timeScale;
string testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
Time.timeScale = 4;
_eventAggregator.InvokeOnTimeDilationSpeedReset(this, System.EventArgs.Empty);
if (Time.timeScale == 1) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
} else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
}
}
fileFormatVersion: 2
guid: f37f9e3131cf5524b8784eb4a3c60493
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
[CreateAssetMenu(fileName = "NewEventAggregator", menuName = "Combat/EventAggregator")]
public class EventAggregator : ScriptableObject
{
// public event EventHandler<UnitActionArgs> OnUnitSelected;
// public event EventHandler<UnitMoveArgs> OnUnitMove;
public event EventHandler onTimeDilationSpeedUp;
public event EventHandler onTimeDilationSpeedDown;
public event EventHandler onTimeDilationSpeedReset;
public event EventHandler onTimeDilationSpeedPause;
public void InvokeOnUnitSelected(object sender, UnitActionArgs e) {
// OnUnitSelected?.Invoke(sender, e);
}
public void InvokeOnTimeDilationSpeedUp(object sender, EventArgs e) {
onTimeDilationSpeedUp?.Invoke(sender, e);
}
public void InvokeOnTimeDilationSpeedDown(object sender, EventArgs e) {
onTimeDilationSpeedDown?.Invoke(sender, e);
}
public void InvokeOnTimeDilationSpeedReset(object sender, EventArgs e) {
onTimeDilationSpeedReset?.Invoke(sender, e);
}
public void InvokeOnTimeDilationSpeedPause(object sender, EventArgs e) {
onTimeDilationSpeedPause?.Invoke(sender, e);
}
void OnEnable() {
}
void OnDisable() {
}
void Cleanup() {
}
}
fileFormatVersion: 2
guid: 83ebe19076f094047a01aa5018087746
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7674cb78dbff8d447b6c39984750a2da
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f37f9e3131cf5524b8784eb4a3c60493, type: 3}
m_Name: EventAggregator
m_EditorClassIdentifier: