summaryrefslogtreecommitdiff
path: root/SurvivalTest
diff options
context:
space:
mode:
Diffstat (limited to 'SurvivalTest')
-rw-r--r--SurvivalTest/Assets/Resources/Art/ui/item/executor_head.pngbin0 -> 8664 bytes
-rw-r--r--SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png.meta96
-rw-r--r--SurvivalTest/Assets/Resources/Art/ui/item/wrench.pngbin0 -> 4398 bytes
-rw-r--r--SurvivalTest/Assets/Resources/Art/ui/item/wrench.png.meta96
-rw-r--r--SurvivalTest/Assets/Scripts/Devices/DeviceBase.cs2
-rw-r--r--SurvivalTest/Assets/Scripts/Items/ExecutorParts.meta8
-rw-r--r--SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs14
-rw-r--r--SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs14
-rw-r--r--SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs11
-rw-r--r--SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Managers/PlayerManager_Items.cs2
-rw-r--r--SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs27
-rw-r--r--SurvivalTest/Assets/Scripts/Test/TestPeaceMaker.cs1
-rw-r--r--SurvivalTest/Assets/Scripts/Titles.meta8
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/TitleBase.cs12
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/TitleBase.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs11
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs13
-rw-r--r--SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIStateSection.cs18
-rw-r--r--SurvivalTest/Assets/Scripts/Utils/EventCenter.cs48
-rw-r--r--SurvivalTest/Assets/Scripts/Utils/EventCenter.cs.meta11
-rw-r--r--SurvivalTest/Assets/Scripts/Utils/EventType.cs12
-rw-r--r--SurvivalTest/Assets/Scripts/Utils/EventType.cs.meta11
27 files changed, 471 insertions, 10 deletions
diff --git a/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png b/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png
new file mode 100644
index 0000000..a30efb0
--- /dev/null
+++ b/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png
Binary files differ
diff --git a/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png.meta b/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png.meta
new file mode 100644
index 0000000..4bbe210
--- /dev/null
+++ b/SurvivalTest/Assets/Resources/Art/ui/item/executor_head.png.meta
@@ -0,0 +1,96 @@
+fileFormatVersion: 2
+guid: eeb9550acf831254a9973bc5be53617c
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 11
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 0
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: 1
+ aniso: 1
+ mipBias: 0
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 1
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 8
+ textureShape: 1
+ singleChannelComponent: 0
+ flipbookRows: 1
+ flipbookColumns: 1
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ platformSettings:
+ - serializedVersion: 3
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID: 5e97eb03825dee720800000000000000
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png b/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png
new file mode 100644
index 0000000..60011b8
--- /dev/null
+++ b/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png
Binary files differ
diff --git a/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png.meta b/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png.meta
new file mode 100644
index 0000000..e0ed9a7
--- /dev/null
+++ b/SurvivalTest/Assets/Resources/Art/ui/item/wrench.png.meta
@@ -0,0 +1,96 @@
+fileFormatVersion: 2
+guid: 7e56c3e6e104d7f40b6dc191af6bea79
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 11
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 0
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: 1
+ aniso: 1
+ mipBias: 0
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 1
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 8
+ textureShape: 1
+ singleChannelComponent: 0
+ flipbookRows: 1
+ flipbookColumns: 1
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ platformSettings:
+ - serializedVersion: 3
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID: 5e97eb03825dee720800000000000000
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Devices/DeviceBase.cs b/SurvivalTest/Assets/Scripts/Devices/DeviceBase.cs
index 61e347f..e4150b9 100644
--- a/SurvivalTest/Assets/Scripts/Devices/DeviceBase.cs
+++ b/SurvivalTest/Assets/Scripts/Devices/DeviceBase.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
/// <summary>
-/// 设备
+/// 可放置设备
/// </summary>
public class DeviceBase : MonoBehaviour
{
diff --git a/SurvivalTest/Assets/Scripts/Items/ExecutorParts.meta b/SurvivalTest/Assets/Scripts/Items/ExecutorParts.meta
new file mode 100644
index 0000000..0763300
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/ExecutorParts.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d6c76830245bc1746a35c236a3402063
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs
new file mode 100644
index 0000000..45450c1
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs
@@ -0,0 +1,14 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+/// <summary>
+/// 执行者的头
+/// </summary>
+public class Item_ExecutorHead : Item_ExecutorPart
+{
+ public override string name => "执行者的头颅";
+
+ public override string iconPath => "art/ui/item/executor_head";
+
+}
diff --git a/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs.meta b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs.meta
new file mode 100644
index 0000000..ff04c45
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorHead.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bbe96ae8793593c4997e1263d1ed7576
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs
new file mode 100644
index 0000000..43af6f9
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs
@@ -0,0 +1,14 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+/// <summary>
+/// 执行者的部件,集齐之后召唤执行者机器人
+/// 执行者机器人的攻击通过眼发射高能射线,高速扫射敌人
+/// 执行者笔挺的飘在空中,类似管家的姿势,一只手背在身后,眼里发射射线
+/// </summary>
+public class Item_ExecutorPart : ItemBase
+{
+
+
+} \ No newline at end of file
diff --git a/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs.meta b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs.meta
new file mode 100644
index 0000000..f928fe5
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/ExecutorParts/Item_ExecutorPart.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7ce82deacc2452a439329f8d8238f689
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs b/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs
new file mode 100644
index 0000000..52b9685
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs
@@ -0,0 +1,11 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Item_Wrench : ItemBase
+{
+ public override string name => "扳手";
+
+ public override string iconPath => "art/ui/item/wrench";
+
+}
diff --git a/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs.meta b/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs.meta
new file mode 100644
index 0000000..e5050c2
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Items/Item_Wrench.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6a46010aa71259942874b5a68178b1e5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Items.cs b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Items.cs
index 6ee4969..581cfdd 100644
--- a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Items.cs
+++ b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Items.cs
@@ -17,6 +17,8 @@ public partial class PlayerManager : Singleton<PlayerManager>
m_Items.Add(new Item_Horn());
m_Items.Add(new Item_Battery());
m_Items.Add(new Item_SwordSpectrum());
+ m_Items.Add(new Item_Wrench());
+ m_Items.Add(new Item_ExecutorHead());
}
void UpdateItems()
diff --git a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs
index 9a0f9db..16f9396 100644
--- a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs
+++ b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs
@@ -12,9 +12,20 @@ public partial class PlayerManager : Singleton<PlayerManager>
public bool isFire { get; private set; }
- public bool autoFire {get{return m_AutoFire;}}
private bool m_AutoFire;
- private float m_AutoFireDuration = 0.8f;
+ public bool autoFire
+ {
+ get
+ {
+ return m_AutoFire;
+ }
+ set
+ {
+ m_AutoFire = value;
+ EventCenter.Instance.Publish(EventMsgType.ToggleAutoFire, null);
+ }
+ }
+ private float autoFireDuration = 0.8f;
public bool lockAim { get; set; }
@@ -29,7 +40,7 @@ public partial class PlayerManager : Singleton<PlayerManager>
m_Weapons.Add(new Weapon_TeslaCoil());
m_Weapons.Add(new Weapon_MightyGlove());
- m_AutoFire = false;
+ autoFire = false;
m_LastAxisValue = Input.GetAxisRaw("GunTrigger");
}
@@ -54,26 +65,26 @@ public partial class PlayerManager : Singleton<PlayerManager>
if (Input.GetButtonDown("Fire1") || (axis == 1 && m_LastAxisValue != 1))
{
- if(m_AutoFire)
+ if(autoFire)
{
- m_AutoFire = false;
+ autoFire = false;
}
isFire = true;
RunFireCoroutine(true);
}
- if (!m_AutoFire && !Input.GetButton("Fire1") && (axis == 0 && m_LastAxisValue != 0))
+ if (!autoFire && !Input.GetButton("Fire1") && (axis == 0 && m_LastAxisValue != 0))
{
if (TinyCountDown.Instance.Get("ReleaseFire") > 0)
{
- m_AutoFire = true;
+ autoFire = true;
isFire = true;
RunFireCoroutine(true);
}
else
{
- TinyCountDown.Instance.Set("ReleaseFire", m_AutoFireDuration);
+ TinyCountDown.Instance.Set("ReleaseFire", autoFireDuration);
isFire = false;
RunFireCoroutine(false);
}
diff --git a/SurvivalTest/Assets/Scripts/Test/TestPeaceMaker.cs b/SurvivalTest/Assets/Scripts/Test/TestPeaceMaker.cs
index 3662daf..b05fdab 100644
--- a/SurvivalTest/Assets/Scripts/Test/TestPeaceMaker.cs
+++ b/SurvivalTest/Assets/Scripts/Test/TestPeaceMaker.cs
@@ -86,6 +86,7 @@ public class TestPeaceMaker : CrewScript
set
{
PlayerManager.Instance.lockAim = value;
+ EventCenter.Instance.Publish(EventMsgType.ToggleLockAim, null);
}
}
diff --git a/SurvivalTest/Assets/Scripts/Titles.meta b/SurvivalTest/Assets/Scripts/Titles.meta
new file mode 100644
index 0000000..08a5177
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7d56e7d2cb39441409931bba5a1adcd4
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs b/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs
new file mode 100644
index 0000000..138e945
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs
@@ -0,0 +1,12 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+
+/// <summary>
+/// 称号
+/// </summary>
+public class TitleBase
+{
+
+}
diff --git a/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs.meta b/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs.meta
new file mode 100644
index 0000000..d63cfc3
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/TitleBase.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c322a59acdb13f94e8c6723fe810b6b0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs b/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs
new file mode 100644
index 0000000..9043684
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs
@@ -0,0 +1,11 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+/// <summary>
+/// 机械专家
+/// </summary>
+public class Title_MachineExpert : TitleBase
+{
+
+} \ No newline at end of file
diff --git a/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs.meta b/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs.meta
new file mode 100644
index 0000000..14572b5
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/Title_MachineExpert.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 04cbd0ce5b1783349bbb4aa079d7ab2f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs b/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs
new file mode 100644
index 0000000..e13a484
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs
@@ -0,0 +1,13 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+/// <summary>
+/// 剑术大师(剑圣)
+/// </summary>
+public class Title_SwordMaster : TitleBase
+{
+
+
+
+} \ No newline at end of file
diff --git a/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs.meta b/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs.meta
new file mode 100644
index 0000000..5078ca4
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Titles/Title_SwordMaster.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 088efd501bf4839468e9097d3a338f27
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIStateSection.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIStateSection.cs
index 991ec3a..ab192e7 100644
--- a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIStateSection.cs
+++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIStateSection.cs
@@ -7,9 +7,25 @@ public class UIStateSection : MonoBehaviour
public GameObject m_AutoFire;
public GameObject m_LockAim;
- private void Update()
+ private void Start()
+ {
+ EventCenter.Instance.Register(EventMsgType.ToggleAutoFire, OnToggleAutoFire);
+ EventCenter.Instance.Register(EventMsgType.ToggleLockAim, OnToggleLockAim);
+ }
+
+ private void OnDestroy()
+ {
+ EventCenter.Instance.UnRegister(EventMsgType.ToggleAutoFire, OnToggleAutoFire);
+ EventCenter.Instance.UnRegister(EventMsgType.ToggleLockAim, OnToggleLockAim);
+ }
+
+ void OnToggleAutoFire(params object[] objs)
{
m_AutoFire.SetActive(PlayerManager.Instance.autoFire);
+ }
+
+ void OnToggleLockAim(params object[] objs)
+ {
m_LockAim.SetActive(PlayerManager.Instance.lockAim);
}
diff --git a/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs b/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs
new file mode 100644
index 0000000..eef3646
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs
@@ -0,0 +1,48 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class EventCenter : Singleton<EventCenter>
+{
+ public delegate void EventHandler(params object [] param);
+
+ private Dictionary<EventMsgType, List<EventHandler>> m_EventHandlers = new Dictionary<EventMsgType, List<EventHandler>>();
+
+ public void Register(EventMsgType evt, EventHandler handler)
+ {
+ List<EventHandler> handlers;
+ if (!m_EventHandlers.TryGetValue(evt, out handlers))
+ {
+ handlers = new List<EventHandler>();
+ m_EventHandlers.Add(evt, handlers);
+ }
+ if (!handlers.Contains(handler))
+ {
+ handlers.Add(handler);
+ }
+ else
+ {
+ Debug.LogError("Event has already registed, eventType=" + evt);
+ }
+ }
+
+ public void UnRegister(EventMsgType evt, EventHandler handler)
+ {
+ List<EventHandler> handlers;
+ if (m_EventHandlers.TryGetValue(evt, out handlers))
+ {
+ if(handlers.Contains(handler))
+ handlers.Remove(handler);
+ }
+ }
+
+ public void Publish(EventMsgType evt, params object[] objs)
+ {
+ List<EventHandler> handlers;
+ if (m_EventHandlers.TryGetValue(evt, out handlers))
+ {
+ handlers.ForEach(h => h(objs));
+ }
+ }
+
+} \ No newline at end of file
diff --git a/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs.meta b/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs.meta
new file mode 100644
index 0000000..f87c419
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Utils/EventCenter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 224d79fa30383194d86f18f391400340
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/SurvivalTest/Assets/Scripts/Utils/EventType.cs b/SurvivalTest/Assets/Scripts/Utils/EventType.cs
new file mode 100644
index 0000000..92bc690
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Utils/EventType.cs
@@ -0,0 +1,12 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public enum EventMsgType
+{
+
+ // UI
+ ToggleAutoFire, // 自动开火
+ ToggleLockAim, // 锁定方向
+}
+
diff --git a/SurvivalTest/Assets/Scripts/Utils/EventType.cs.meta b/SurvivalTest/Assets/Scripts/Utils/EventType.cs.meta
new file mode 100644
index 0000000..90ea046
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Utils/EventType.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2cca452167d1ce34cb98da00cae563b0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: