From c7df1cdf741115adb0daa83d86eb5ca190372bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Mon, 6 Jan 2025 09:15:44 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=B2=9B=E4=B8=BB=E7=AB=9E=E6=8B=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/script/Panel/Islandpanel.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meng_yao/Assets/script/Panel/Islandpanel.cs b/meng_yao/Assets/script/Panel/Islandpanel.cs index 4fe01740..588064ca 100644 --- a/meng_yao/Assets/script/Panel/Islandpanel.cs +++ b/meng_yao/Assets/script/Panel/Islandpanel.cs @@ -30,6 +30,11 @@ public class Islandpanel : MonoBehaviour introtext.text = response.Data.intro_text; InvesttotalText.text = response.Data.invest_total.ToString(); remainingTime = response.Data.countdown; + if(response.Data.island_id==0) + { + Dao.gameObject.SetActive(false); + islandname.gameObject.SetActive(false); + } islandname.text = response.Data.island_name; UpdateCountdownText(remainingTime); Dao.sprite = dao[response.Data.island_id]; From 77911ba084ce9d7d7bb8bc07642cce62bb796704 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Mon, 6 Jan 2025 09:36:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/script/A_Fight/MY_Infos.cs | 18 ++ .../Assets/script/A_Fight/MY_Infos.cs.meta | 11 + .../Assets/script/A_Fight/SpawnMonster.cs | 211 ++++++++++++++++++ .../script/A_Fight/SpawnMonster.cs.meta | 11 + 4 files changed, 251 insertions(+) create mode 100644 meng_yao/Assets/script/A_Fight/MY_Infos.cs create mode 100644 meng_yao/Assets/script/A_Fight/MY_Infos.cs.meta create mode 100644 meng_yao/Assets/script/A_Fight/SpawnMonster.cs create mode 100644 meng_yao/Assets/script/A_Fight/SpawnMonster.cs.meta diff --git a/meng_yao/Assets/script/A_Fight/MY_Infos.cs b/meng_yao/Assets/script/A_Fight/MY_Infos.cs new file mode 100644 index 00000000..ed2957b4 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/MY_Infos.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MY_Infos : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/meng_yao/Assets/script/A_Fight/MY_Infos.cs.meta b/meng_yao/Assets/script/A_Fight/MY_Infos.cs.meta new file mode 100644 index 00000000..e520eda3 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/MY_Infos.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6c570b2c3c14994fa8337757d1d492e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs new file mode 100644 index 00000000..877326d3 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs @@ -0,0 +1,211 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; + + +public class SpawnMonster : Base +{ + public static SpawnMonster intance; + + public ObJPool EnemyPool = new ObJPool(); + public List Enemys = new List(); + + [Header("生成预制体")] + public GameObject Prefab; + + [Header("生成位置")] + public Transform SpawnLocation; + + [Header("一波生成间隔")] + public float GenerationInterval; + + [Header("一次生成间隔")] + public float GenerationIntervalOfOne; + + [Header("生成总数量")] + public float GenerateQuantityMax; + + [Header("每一波生成数量")] + public float GenerateQuantity; + + [HideInInspector] + public int deadNumber = 0; + public int DeadNumber + { + get => deadNumber; + set + { + deadNumber = value; + if (deadNumber >= GenerateQuantityMax) + { + // gameGlobal.GameVictory(); + } + } + } + + + // 状态变量 + private bool IsStartGet = false; // 是否开始生成 + private bool IsWave = true; // 当前是否在生成波 + private float timerOfOne = 0f; // 记录每个敌人生成的时间 + private float timerOfOneWave = 0f; // 记录波与波之间的时间 + private int generatedCount = 0; // 总已生成敌人数量 + private int waveGeneratedCount = 0; // 当前波已生成敌人数量 + private int currentWave = 0; // 当前波数 + + + private void Awake() + { + intance = this; + } + + void Start() + { + Base.GlobalObj.GetComponent().OnGamePlay += this.StartSpawning; + } + public void UpdateNodeList() + { + // 获取所有带有 SortingGroup 组件的敌人对象 + List gameObjectsList = new List(); + + foreach (GameObject go in Enemys) + { + // 获取该物体上的 SortingGroup 组件 + if (go != null) + { + SortingGroup sortingGroup = go.GetComponent(); + if (sortingGroup != null && go.activeSelf) + { + // 添加到列表中 + gameObjectsList.Add(go); + } + } + + } + + // 按照 y 轴排序 + gameObjectsList.Sort((a, b) => a.transform.position.y.CompareTo(b.transform.position.y)); + + // 设置 SortingGroup 和子 Canvas 的 sortingOrder + for (int i = 0; i < gameObjectsList.Count; i++) + { + SortingGroup sortingGroup = gameObjectsList[i].GetComponent(); + if (sortingGroup != null) + { + // 计算排序顺序 + int order = gameObjectsList.Count - i + 2; + sortingGroup.sortingOrder = order; + + // 获取子 Canvas 并设置其 sortingOrder + Canvas canvas = gameObjectsList[i].GetComponentInChildren(); + if (canvas != null) + { + canvas.sortingOrder = order; + } + } + } + } + + + + void Update() + { + if (IsStartGet) + { + if (IsWave) + { + timerOfOne += Time.deltaTime; + if (timerOfOne >= GenerationIntervalOfOne && waveGeneratedCount < GenerateQuantity) + { + GenerateEnemy(); // 生成敌人 + timerOfOne = 0f; // 重置计时器 + waveGeneratedCount++; // 增加当前波的生成数量 + + // 如果当前波的敌人数量已达上限,则标记波结束 + if (waveGeneratedCount >= GenerateQuantity) + { + IsWave = false; // 当前波生成完毕,切换到等待下一波 + } + } + } + else + { + timerOfOneWave += Time.deltaTime; + if (timerOfOneWave >= GenerationInterval) + { + // 当前波生成完毕,等待下一波 + currentWave++; + if (generatedCount < GenerateQuantityMax) + { + waveGeneratedCount = 0; + timerOfOneWave = 0f; // 重置波间隔计时器 + IsWave = true; // 启动新的一波 + } + else + { + IsStartGet = false; // 所有敌人生成完毕,停止生成 + } + } + } + } + } + + private void FixedUpdate() + { + UpdateNodeList(); + } + public void StartSpawning() + { + if (GenerateQuantity >= GenerateQuantityMax) + { + GenerateQuantity = GenerateQuantityMax; + } + // 初始化状态,开始生成 + IsStartGet = true; + waveGeneratedCount = 0; + currentWave = 0; + generatedCount = 0; + timerOfOne = 0f; + timerOfOneWave = 0f; + } + + void GenerateEnemy() + { + + GameObject enemy = EnemyPool.Get(); // 获取一个敌人对象 + + // 如果池子中没有可用的对象,创建新的敌人 + if (enemy == null) + { + if (Prefab == null) + { + Debug.LogError("Prefab is not assigned."); + return; + } + + enemy = Instantiate(Prefab); + //EnemyPool.SurvivalPool.Add(enemy); + Enemys.Add(enemy); + } + + //enemy.GetComponent().ResetAllStatus(); + // 设置敌人的位置和其他属性 + enemy.SetActive(true); // 激活敌人对象 + enemy.transform.position = SpawnLocation.position; + + // 更新生成计数 + generatedCount++; + } + + + + + private void OnDisable() + { + Base.GlobalObj.GetComponent().OnGamePlay -= this.StartSpawning; + } +} + + + diff --git a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs.meta b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs.meta new file mode 100644 index 00000000..6e1d61e2 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97664c5246bb0d242997921b3560d036 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 1141b010d8504acb525be7e355f722d069e40e93 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Mon, 6 Jan 2025 09:56:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/script/A_Fight/MY_Infos.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/meng_yao/Assets/script/A_Fight/MY_Infos.cs b/meng_yao/Assets/script/A_Fight/MY_Infos.cs index ed2957b4..6e0cabbc 100644 --- a/meng_yao/Assets/script/A_Fight/MY_Infos.cs +++ b/meng_yao/Assets/script/A_Fight/MY_Infos.cs @@ -2,17 +2,23 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +[System.Serializable] +public class mengyaoInfo +{ + public string id; + public Sprite imge; + public Sprite cardimge; + public GameObject prefab; +} + public class MY_Infos : MonoBehaviour { - // Start is called before the first frame update - void Start() + public List mengyaoItems=new List(); + + public MY_Infos instane; + void Awake() { - + instane = this; } - // Update is called once per frame - void Update() - { - - } } From 9bff71e4bf0090502bd7d8f3d8bf07f92f5f30b0 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Mon, 6 Jan 2025 10:13:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/Scenes/New/Scene_map_1.unity | 69 ++++++++- .../Assets/script/A_Fight/Monster_Infos.cs | 23 +++ .../script/A_Fight/Monster_Infos.cs.meta | 11 ++ .../Assets/script/A_Fight/SpawnMonster.cs | 135 ++---------------- meng_yao/Assets/script/A_Fight/SpawnPool.cs | 1 + 5 files changed, 113 insertions(+), 126 deletions(-) create mode 100644 meng_yao/Assets/script/A_Fight/Monster_Infos.cs create mode 100644 meng_yao/Assets/script/A_Fight/Monster_Infos.cs.meta diff --git a/meng_yao/Assets/Scenes/New/Scene_map_1.unity b/meng_yao/Assets/Scenes/New/Scene_map_1.unity index 23bd39ed..1e6ca7db 100644 --- a/meng_yao/Assets/Scenes/New/Scene_map_1.unity +++ b/meng_yao/Assets/Scenes/New/Scene_map_1.unity @@ -841,7 +841,7 @@ Transform: - {fileID: 995271151} - {fileID: 1932457213} m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &284432671 MonoBehaviour: @@ -1570,7 +1570,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &459650026 MonoBehaviour: @@ -5919,6 +5919,71 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 97664c5246bb0d242997921b3560d036, type: 3} m_Name: m_EditorClassIdentifier: + retbutton: {fileID: 0} + ClosureObj: {fileID: 0} +--- !u!1 &1910338484 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1910338485} + - component: {fileID: 1910338487} + - component: {fileID: 1910338486} + m_Layer: 0 + m_Name: Infos + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1910338485 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1910338484} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 524.29224, y: 1319.394, z: -1.7705407} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1910338486 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1910338484} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f6c570b2c3c14994fa8337757d1d492e, type: 3} + m_Name: + m_EditorClassIdentifier: + mengyaoItems: [] + instane: {fileID: 0} +--- !u!114 &1910338487 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1910338484} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3ee6cb1a8b4020040bddd9c037e404b4, type: 3} + m_Name: + m_EditorClassIdentifier: + monsters: + - id: + prefab: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3} + instance: {fileID: 0} --- !u!1 &1932457212 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/script/A_Fight/Monster_Infos.cs b/meng_yao/Assets/script/A_Fight/Monster_Infos.cs new file mode 100644 index 00000000..8c730b2f --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/Monster_Infos.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[System.Serializable] +public class monster +{ + public string id; + public GameObject prefab; + +} + +public class Monster_Infos : MonoBehaviour +{ + public List monsters = new List(); + public Monster_Infos instance; + + void Awake() + { + instance = this; + } +} + diff --git a/meng_yao/Assets/script/A_Fight/Monster_Infos.cs.meta b/meng_yao/Assets/script/A_Fight/Monster_Infos.cs.meta new file mode 100644 index 00000000..4897a60f --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/Monster_Infos.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ee6cb1a8b4020040bddd9c037e404b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs index 877326d3..97b2abab 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs @@ -4,56 +4,13 @@ using UnityEngine; using UnityEngine.Rendering; + + + public class SpawnMonster : Base { public static SpawnMonster intance; - public ObJPool EnemyPool = new ObJPool(); - public List Enemys = new List(); - - [Header("生成预制体")] - public GameObject Prefab; - - [Header("生成位置")] - public Transform SpawnLocation; - - [Header("一波生成间隔")] - public float GenerationInterval; - - [Header("一次生成间隔")] - public float GenerationIntervalOfOne; - - [Header("生成总数量")] - public float GenerateQuantityMax; - - [Header("每一波生成数量")] - public float GenerateQuantity; - - [HideInInspector] - public int deadNumber = 0; - public int DeadNumber - { - get => deadNumber; - set - { - deadNumber = value; - if (deadNumber >= GenerateQuantityMax) - { - // gameGlobal.GameVictory(); - } - } - } - - - // 状态变量 - private bool IsStartGet = false; // 是否开始生成 - private bool IsWave = true; // 当前是否在生成波 - private float timerOfOne = 0f; // 记录每个敌人生成的时间 - private float timerOfOneWave = 0f; // 记录波与波之间的时间 - private int generatedCount = 0; // 总已生成敌人数量 - private int waveGeneratedCount = 0; // 当前波已生成敌人数量 - private int currentWave = 0; // 当前波数 - private void Awake() { @@ -64,7 +21,9 @@ public class SpawnMonster : Base { Base.GlobalObj.GetComponent().OnGamePlay += this.StartSpawning; } - public void UpdateNodeList() + + + /*public void UpdateNodeList() { // 获取所有带有 SortingGroup 组件的敌人对象 List gameObjectsList = new List(); @@ -105,97 +64,25 @@ public class SpawnMonster : Base } } } - } + }*/ void Update() { - if (IsStartGet) - { - if (IsWave) - { - timerOfOne += Time.deltaTime; - if (timerOfOne >= GenerationIntervalOfOne && waveGeneratedCount < GenerateQuantity) - { - GenerateEnemy(); // 生成敌人 - timerOfOne = 0f; // 重置计时器 - waveGeneratedCount++; // 增加当前波的生成数量 - - // 如果当前波的敌人数量已达上限,则标记波结束 - if (waveGeneratedCount >= GenerateQuantity) - { - IsWave = false; // 当前波生成完毕,切换到等待下一波 - } - } - } - else - { - timerOfOneWave += Time.deltaTime; - if (timerOfOneWave >= GenerationInterval) - { - // 当前波生成完毕,等待下一波 - currentWave++; - if (generatedCount < GenerateQuantityMax) - { - waveGeneratedCount = 0; - timerOfOneWave = 0f; // 重置波间隔计时器 - IsWave = true; // 启动新的一波 - } - else - { - IsStartGet = false; // 所有敌人生成完毕,停止生成 - } - } - } - } + } - private void FixedUpdate() - { - UpdateNodeList(); - } + public void StartSpawning() { - if (GenerateQuantity >= GenerateQuantityMax) - { - GenerateQuantity = GenerateQuantityMax; - } - // 初始化状态,开始生成 - IsStartGet = true; - waveGeneratedCount = 0; - currentWave = 0; - generatedCount = 0; - timerOfOne = 0f; - timerOfOneWave = 0f; + } void GenerateEnemy() { - GameObject enemy = EnemyPool.Get(); // 获取一个敌人对象 - - // 如果池子中没有可用的对象,创建新的敌人 - if (enemy == null) - { - if (Prefab == null) - { - Debug.LogError("Prefab is not assigned."); - return; - } - - enemy = Instantiate(Prefab); - //EnemyPool.SurvivalPool.Add(enemy); - Enemys.Add(enemy); - } - - //enemy.GetComponent().ResetAllStatus(); - // 设置敌人的位置和其他属性 - enemy.SetActive(true); // 激活敌人对象 - enemy.transform.position = SpawnLocation.position; - - // 更新生成计数 - generatedCount++; + } diff --git a/meng_yao/Assets/script/A_Fight/SpawnPool.cs b/meng_yao/Assets/script/A_Fight/SpawnPool.cs index e51bbbe4..573ffb1a 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnPool.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnPool.cs @@ -34,6 +34,7 @@ public class ObJPool } } + public class SpawnPool : Base { public static SpawnPool intance;