英理功能增加
This commit is contained in:
@@ -5706,7 +5706,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 312, y: 150}
|
||||
m_SizeDelta: {x: 0, y: 150}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &367483173
|
||||
MonoBehaviour:
|
||||
@@ -8360,7 +8360,7 @@ Transform:
|
||||
m_GameObject: {fileID: 519420028}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||
m_LocalPosition: {x: -0.009999275, y: 0, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -9511,9 +9511,9 @@ RectTransform:
|
||||
- {fileID: 576009914}
|
||||
m_Father: {fileID: 367483172}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 188, y: -25}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 64, y: 100}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!222 &640896811
|
||||
@@ -10584,7 +10584,7 @@ Transform:
|
||||
m_GameObject: {fileID: 704370074}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||
m_LocalPosition: {x: -0.009999275, y: 0, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -15189,9 +15189,9 @@ RectTransform:
|
||||
- {fileID: 527148464}
|
||||
m_Father: {fileID: 367483172}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 94, y: -25}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 64, y: 100}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!222 &1164645868
|
||||
@@ -21190,7 +21190,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: -20, y: 10}
|
||||
m_SizeDelta: {x: 101.9, y: 25}
|
||||
m_SizeDelta: {x: 0, y: 25}
|
||||
m_Pivot: {x: 1, y: 0}
|
||||
--- !u!114 &1609388205
|
||||
MonoBehaviour:
|
||||
@@ -23774,9 +23774,9 @@ RectTransform:
|
||||
- {fileID: 1970860741}
|
||||
m_Father: {fileID: 367483172}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 282, y: -25}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 64, y: 100}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!222 &1928871882
|
||||
@@ -27134,7 +27134,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2135943277
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
+2635
-2029
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,16 @@ MonoBehaviour:
|
||||
- command: 0
|
||||
moduleName: Memory
|
||||
flickerTime: 3
|
||||
lightOnTime: 10
|
||||
lightOnTime: 5
|
||||
- command: 0
|
||||
moduleName: Eye
|
||||
flickerTime: 3
|
||||
lightOnTime: 10
|
||||
lightOnTime: 5
|
||||
- command: 0
|
||||
moduleName: Logic
|
||||
flickerTime: 3
|
||||
lightOnTime: 5
|
||||
- command: 0
|
||||
moduleName: Speak
|
||||
flickerTime: 3
|
||||
lightOnTime: 5
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
@@ -9,9 +10,9 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
private readonly MonoBehaviour _mono;
|
||||
private AbsWhackMoleNodeHandler _nodeHandler;
|
||||
|
||||
|
||||
public event Action<bool> OnGameEnd;
|
||||
|
||||
|
||||
private WhackMoleHandler(MonoBehaviour mono)
|
||||
{
|
||||
_mono = mono;
|
||||
@@ -37,7 +38,7 @@ namespace AibisDream.FixSystem
|
||||
_nodeHandler.onHandleEnd.AddListener(OnHandleEnd);
|
||||
_mono.StartCoroutine(_nodeHandler.Handle());
|
||||
}
|
||||
|
||||
|
||||
private void OnHandleEnd(bool isSuccess)
|
||||
{
|
||||
if (isSuccess)
|
||||
@@ -62,26 +63,27 @@ namespace AibisDream.FixSystem
|
||||
OnGameEnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static WhackMoleHandler Create(WhackMoleData data, MonoBehaviour mono)
|
||||
{
|
||||
var res = new WhackMoleHandler(mono);
|
||||
AbsWhackMoleNodeHandler lastHandler = null;
|
||||
foreach (var node in data.nodes)
|
||||
{
|
||||
var handler = CreateNodeHandler(node);
|
||||
var handler = res.CreateNodeHandler(node);
|
||||
res._nodeHandler ??= handler;
|
||||
if (lastHandler != null)
|
||||
{
|
||||
lastHandler.nextHandler = handler;
|
||||
}
|
||||
|
||||
lastHandler = handler;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static AbsWhackMoleNodeHandler CreateNodeHandler(WhackMoleNode node)
|
||||
private AbsWhackMoleNodeHandler CreateNodeHandler(WhackMoleNode node)
|
||||
{
|
||||
AbsWhackMoleNodeHandler handler = node.command switch
|
||||
{
|
||||
@@ -95,25 +97,28 @@ namespace AibisDream.FixSystem
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class AbsWhackMoleNodeHandler
|
||||
{
|
||||
protected static WhackMoleSystem WhackMoleSystem => FixSystemCenter.SystemDic.Get<WhackMoleSystem>();
|
||||
|
||||
|
||||
protected WhackMoleNode node;
|
||||
public AbsWhackMoleNodeHandler nextHandler;
|
||||
|
||||
public readonly UnityEvent<bool> onHandleEnd = new();
|
||||
|
||||
public virtual void Init(WhackMoleNode nodeData)
|
||||
|
||||
public readonly UnityEvent<bool> onHandleEnd = new();
|
||||
|
||||
public void Init(WhackMoleNode nodeData)
|
||||
{
|
||||
node = nodeData;
|
||||
}
|
||||
|
||||
public IEnumerator Handle()
|
||||
{
|
||||
EnumEventSystem.Global.Send(WhackMoleState.BeforePlug);
|
||||
yield return BeforePlug();
|
||||
EnumEventSystem.Global.Send(WhackMoleState.WaitPlug, node.lightOnTime);
|
||||
yield return WaitPlug();
|
||||
EnumEventSystem.Global.Send(WhackMoleState.AfterPlug);
|
||||
yield return AfterPlug();
|
||||
}
|
||||
|
||||
@@ -123,37 +128,26 @@ namespace AibisDream.FixSystem
|
||||
yield return new WaitForSeconds(node.flickerTime);
|
||||
WhackMoleSystem.StopAllFlicker();
|
||||
}
|
||||
|
||||
|
||||
protected abstract IEnumerator WaitPlug();
|
||||
|
||||
protected abstract IEnumerator AfterPlug();
|
||||
|
||||
|
||||
public abstract void OnPlugIn(string moduleName);
|
||||
public abstract void OnPlugOut(string moduleName);
|
||||
}
|
||||
|
||||
|
||||
public class SingleModuleLightOnHandler : AbsWhackMoleNodeHandler
|
||||
{
|
||||
private bool _isPlugIn;
|
||||
|
||||
public override void Init(WhackMoleNode nodeData)
|
||||
{
|
||||
base.Init(nodeData);
|
||||
// 处理Random
|
||||
if (nodeData.moduleName.ToLowerInvariant() == "random")
|
||||
{
|
||||
// TODO 随机选择一个模块
|
||||
node.moduleName = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerator WaitPlug()
|
||||
{
|
||||
Debug.Log("进入等待");
|
||||
// 先等待
|
||||
yield return 0.5f;
|
||||
yield return new WaitForSeconds(1f);
|
||||
_isPlugIn = false;
|
||||
|
||||
|
||||
WhackMoleSystem.LightOnModule(node.moduleName);
|
||||
// 进入循环等待插入事件,规定时间内未插入则进入失败结局
|
||||
var waitTime = 0f;
|
||||
@@ -161,6 +155,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
waitTime += Time.deltaTime;
|
||||
yield return null;
|
||||
EnumEventSystem.Global.Send(WhackMoleState.WaitPlug, node.lightOnTime - waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +166,7 @@ namespace AibisDream.FixSystem
|
||||
if (_isPlugIn)
|
||||
{
|
||||
// TODO 正常插入,触发效果并进入下一个关卡
|
||||
yield return null;
|
||||
yield return new WaitForSeconds(1);
|
||||
onHandleEnd?.Invoke(true);
|
||||
}
|
||||
else
|
||||
@@ -188,7 +183,7 @@ namespace AibisDream.FixSystem
|
||||
_isPlugIn = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnPlugOut(string moduleName)
|
||||
{
|
||||
if (moduleName == node.moduleName)
|
||||
@@ -197,7 +192,7 @@ namespace AibisDream.FixSystem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MultipleModuleLightOnHandler : AbsWhackMoleNodeHandler
|
||||
{
|
||||
protected override IEnumerator WaitPlug()
|
||||
@@ -213,7 +208,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public override void OnPlugIn(string moduleName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnPlugOut(string moduleName)
|
||||
@@ -221,7 +215,7 @@ namespace AibisDream.FixSystem
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SingleModuleColorOnHandler : AbsWhackMoleNodeHandler
|
||||
{
|
||||
protected override IEnumerator WaitPlug()
|
||||
@@ -236,7 +230,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public override void OnPlugIn(string moduleName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnPlugOut(string moduleName)
|
||||
@@ -244,7 +237,7 @@ namespace AibisDream.FixSystem
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MultipleModuleColorOnHandler : AbsWhackMoleNodeHandler
|
||||
{
|
||||
protected override IEnumerator WaitPlug()
|
||||
@@ -259,7 +252,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public override void OnPlugIn(string moduleName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnPlugOut(string moduleName)
|
||||
@@ -267,4 +259,11 @@ namespace AibisDream.FixSystem
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public enum WhackMoleState
|
||||
{
|
||||
BeforePlug,
|
||||
WaitPlug,
|
||||
AfterPlug,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using AibisDream.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
public class WhackMoleLog : MonoBehaviour
|
||||
{
|
||||
private TMP_Text _countDownText;
|
||||
private TMP_Text _stateText;
|
||||
private TMP_Text _resText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_countDownText = transform.Find("倒计时").GetComponent<TMP_Text>();
|
||||
_stateText = transform.Find("当前状态").GetComponent<TMP_Text>();
|
||||
_resText = transform.Find("结果").GetComponent<TMP_Text>();
|
||||
|
||||
EnumEventSystem.Global.Register(WhackMoleState.BeforePlug, OnBeforePlug);
|
||||
EnumEventSystem.Global.Register<WhackMoleState, float>(WhackMoleState.WaitPlug, OnWaitPlug);
|
||||
EnumEventSystem.Global.Register(WhackMoleState.AfterPlug, OnAfterPlug);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_countDownText.text = "倒计时:等待";
|
||||
_stateText.text = "当前状态:开始";
|
||||
_resText.text = "结果:等待";
|
||||
}
|
||||
|
||||
private void OnBeforePlug()
|
||||
{
|
||||
_stateText.text = "当前状态:前置效果";
|
||||
_countDownText.text = "倒计时:0";
|
||||
}
|
||||
|
||||
private void OnWaitPlug(float time)
|
||||
{
|
||||
_stateText.text = "当前状态:插线倒计时";
|
||||
_countDownText.text = $"倒计时:{time:F}";
|
||||
}
|
||||
|
||||
private void OnAfterPlug()
|
||||
{
|
||||
_stateText.text = "当前状态:后置效果";
|
||||
_countDownText.text = "倒计时:0";
|
||||
}
|
||||
|
||||
public void OnGameEnd(bool isSuccess)
|
||||
{
|
||||
_stateText.text = "当前状态:游戏结束";
|
||||
_countDownText.text = "倒计时:0";
|
||||
_resText.text = "结果:" + (isSuccess ? "成功" : "失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c60dc35d51a4c349889aa59f70a6442
|
||||
timeCreated: 1753262821
|
||||
@@ -11,6 +11,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
private BodyModuleSystem _bodyModuleSystem;
|
||||
private WhackMoleHandler _handler;
|
||||
private WhackMoleLog _log;
|
||||
|
||||
private Dictionary<string, MoleModule> _moleModules;
|
||||
|
||||
@@ -18,6 +19,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
_bodyModuleSystem = GetComponent<BodyModuleSystem>();
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
_log = GetComponentInChildren<WhackMoleLog>();
|
||||
}
|
||||
|
||||
#region 打地鼠游戏流程控制
|
||||
@@ -29,14 +31,16 @@ namespace AibisDream.FixSystem
|
||||
// 获取当前所有模块
|
||||
_moleModules =
|
||||
_bodyModuleSystem.BodyModules.ToDictionary(item => item.data.moduleName, item => item as MoleModule);
|
||||
|
||||
_moleModules.Values.ToList().ForEach(item => item.isInMoleGame = true);
|
||||
_log.Init();
|
||||
_handler.StartGame();
|
||||
}
|
||||
|
||||
private void OnWhackEnd(bool isSuccess)
|
||||
{
|
||||
Debug.Log($"打地鼠:{isSuccess}");
|
||||
_moleModules.Values.ToList().ForEach(item => item.isInMoleGame = false);
|
||||
// TODO 触发游戏结束
|
||||
_log.OnGameEnd(isSuccess);
|
||||
DialogController.Instance.StartDialogNode("游戏结束");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user