From dbc0ccb56570afcd2f174f4e94235ccbe4ead7b6 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Mon, 6 Jan 2025 16:13:39 +0800 Subject: [PATCH] =?UTF-8?q?my=E7=94=9F=E6=88=90=E6=B5=81=E7=A8=8B=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/Scenes/New/Scene_map_1.unity | 46 ++----------- meng_yao/Assets/script/A_Fight/MY_Infos.cs | 4 +- .../Assets/script/A_Fight/SpawnMonster.cs | 2 +- meng_yao/Assets/script/A_Fight/cardBox.cs | 65 ++----------------- meng_yao/Assets/script/A_Fight/cardContorl.cs | 4 +- meng_yao/Assets/script/A_Fight/gameGlobal.cs | 2 +- 6 files changed, 20 insertions(+), 103 deletions(-) diff --git a/meng_yao/Assets/Scenes/New/Scene_map_1.unity b/meng_yao/Assets/Scenes/New/Scene_map_1.unity index 4ce7ce53..c4ff90d6 100644 --- a/meng_yao/Assets/Scenes/New/Scene_map_1.unity +++ b/meng_yao/Assets/Scenes/New/Scene_map_1.unity @@ -3601,21 +3601,6 @@ MonoBehaviour: inPlaceNumber: 0 btnObj: {fileID: 1942153352} IconTipObj: {fileID: 0} - mengyaoCardDataList: - - cardID: M_M_001 - cardPrefab: {fileID: 6655435212987556048, guid: 383e65ed01369d345a73d626ab713888, type: 3} - - cardID: M_S_001 - cardPrefab: {fileID: 5508436327438263543, guid: 12644a2c53bfc72489ad76e8f81628f5, type: 3} - - cardID: M_H_001 - cardPrefab: {fileID: 1126466392417920613, guid: 0dd4a50e59d08e84fb1439c946c24fdc, type: 3} - - cardID: M_T_002 - cardPrefab: {fileID: 6655435212987556048, guid: c7cffe9eb5ea6bb4791fe5c8bb025f01, type: 3} - - cardID: M_S_002 - cardPrefab: {fileID: 5508436327438263543, guid: db8f2924fd8bba94e881e4b275b8b48a, type: 3} - - cardID: M_M_002 - cardPrefab: {fileID: 6655435212987556048, guid: edec2410bf23cdd40a210a28e9c3624f, type: 3} - - cardID: M_J_001 - cardPrefab: {fileID: 5508436327438263543, guid: c61070f2dd2a750439bf3913156d4f7b, type: 3} parentPos: {fileID: 1136445683} scaleUpDuration: 0.5 fadeInDuration: 0.5 @@ -5875,7 +5860,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1884241085} - - component: {fileID: 1884241086} - component: {fileID: 1884241087} m_Layer: 0 m_Name: SpawnMonster @@ -5899,28 +5883,6 @@ Transform: m_Father: {fileID: 284432670} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1884241086 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1884241084} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fdf69f16194abb24d9e887468940e1cb, type: 3} - m_Name: - m_EditorClassIdentifier: - retbutton: {fileID: 0} - ClosureObj: {fileID: 0} - Enemys: [] - Prefab: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3} - SpawnLocation: {fileID: 734893407} - GenerationInterval: 15 - GenerationIntervalOfOne: 2 - GenerateQuantityMax: 20 - GenerateQuantity: 5 - deadNumber: 0 --- !u!114 &1884241087 MonoBehaviour: m_ObjectHideFlags: 0 @@ -5988,31 +5950,37 @@ MonoBehaviour: imge: {fileID: 0} cardimge: {fileID: 21300000, guid: 948b21abbed4a124bbe3d02caa37f317, type: 3} prefab: {fileID: 8433650275485930554, guid: 0e629856be1575e4a9258394dee87cc7, type: 3} + cardprefab: {fileID: 6655435212987556048, guid: c7cffe9eb5ea6bb4791fe5c8bb025f01, type: 3} - id: M_J_001 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: df5f98317f7ecb54bac7b97052a8d2dc, type: 3} prefab: {fileID: 8433650275485930554, guid: 1e8a70ff26520dd4a8744ae2156d16d3, type: 3} + cardprefab: {fileID: 5508436327438263543, guid: c61070f2dd2a750439bf3913156d4f7b, type: 3} - id: M_H_001 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: 492e5984b518a80458cf575c0b57335c, type: 3} prefab: {fileID: 8433650275485930554, guid: 67d13a9263159eb49993b8cc68eb3785, type: 3} + cardprefab: {fileID: 1126466392417920613, guid: 0dd4a50e59d08e84fb1439c946c24fdc, type: 3} - id: M_M_001 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: 5e3fd295650deeb4fa3395de2d789b8a, type: 3} prefab: {fileID: 8433650275485930554, guid: 4f81cc16b1203d549b927ed7da53fdbf, type: 3} + cardprefab: {fileID: 6655435212987556048, guid: 383e65ed01369d345a73d626ab713888, type: 3} - id: M_M_002 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: d6cae85a1dbf95e48a035af3e65d974f, type: 3} prefab: {fileID: 8433650275485930554, guid: b7a992fcbbc242e4eb0b83eea3bfab81, type: 3} + cardprefab: {fileID: 6655435212987556048, guid: edec2410bf23cdd40a210a28e9c3624f, type: 3} - id: M_S_001 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: a95e23a2fb1de5b429b428575fc6d229, type: 3} prefab: {fileID: 8433650275485930554, guid: 1ce7ba2999a588840be40787ac4fb7fc, type: 3} + cardprefab: {fileID: 5508436327438263543, guid: 12644a2c53bfc72489ad76e8f81628f5, type: 3} - id: M_S_002 imge: {fileID: 0} cardimge: {fileID: 21300000, guid: 8e7daa6a68986b944aae00387aabf4ea, type: 3} prefab: {fileID: 8433650275485930554, guid: 71d5f6e53fdb1674aae2e6fa1acf423d, type: 3} - instane: {fileID: 0} + cardprefab: {fileID: 5508436327438263543, guid: db8f2924fd8bba94e881e4b275b8b48a, type: 3} --- !u!114 &1910338487 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/script/A_Fight/MY_Infos.cs b/meng_yao/Assets/script/A_Fight/MY_Infos.cs index 402c5d30..8aca2359 100644 --- a/meng_yao/Assets/script/A_Fight/MY_Infos.cs +++ b/meng_yao/Assets/script/A_Fight/MY_Infos.cs @@ -7,8 +7,8 @@ public class mengyaoInfo { public string id; public Sprite imge; - public Sprite cardimge; public GameObject prefab; + public GameObject cardprefab; } public class MY_Infos : MonoBehaviour @@ -16,7 +16,7 @@ public class MY_Infos : MonoBehaviour public List mengyaoItems=new List(); public Dictionary mengyaoItemsDic=new Dictionary(); - public MY_Infos instane; + public static MY_Infos instane; void Awake() { diff --git a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs index 66e3f529..0481b6e6 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs @@ -38,7 +38,7 @@ public class SpawnMonster : Base { Base.GlobalObj.GetComponent().OnGamePlay += this.StartSpawning; - StartSpawning(); + //StartSpawning(); } diff --git a/meng_yao/Assets/script/A_Fight/cardBox.cs b/meng_yao/Assets/script/A_Fight/cardBox.cs index fffd2eaa..1ba3c4bf 100644 --- a/meng_yao/Assets/script/A_Fight/cardBox.cs +++ b/meng_yao/Assets/script/A_Fight/cardBox.cs @@ -4,15 +4,6 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -[System.Serializable] -public class MengyaoCardData -{ - [Tooltip("萌妖卡ID")] - public string cardID; - - [Tooltip("萌妖卡预制体")] - public GameObject cardPrefab; -} public class cardBox : Base { @@ -23,7 +14,7 @@ public class cardBox : Base [Header("怪物信息提示按钮obj")] public GameObject IconTipObj; - [Header("萌妖卡数据列表")] public List mengyaoCardDataList = new List(); + // [Header("萌妖卡数据列表")] public List mengyaoCardDataList = new List(); [Header("萌妖卡生成父节点")] public Transform parentPos; @@ -54,8 +45,6 @@ public class cardBox : Base } btnObj.SetActive(false); - - InitializeDictionary(); Init(); mengyaoNumber = Base.GlobalObj.GetComponent().CarryCardId.Count; } @@ -77,47 +66,7 @@ public class cardBox : Base } } - /// - /// 初始化ID到萌妖卡预制体的映射字典 - /// - void InitializeDictionary() - { - foreach (var cardData in mengyaoCardDataList) - { - string id = cardData.cardID; - GameObject prefab = cardData.cardPrefab; - - // 检查ID和预制体是否为空 - if (string.IsNullOrEmpty(id)) - { - Debug.LogWarning("萌妖卡ID为空,跳过该条数据!"); - continue; - } - - if (prefab == null) - { - Debug.LogWarning($"萌妖卡ID '{id}' 对应的预制体为空,跳过该条数据!"); - continue; - } - - // 检查ID是否重复 - if (IDTomangyaoPrefab.ContainsKey(id)) - { - Debug.LogWarning($"萌妖卡ID '{id}' 在字典中已经存在,预制体将被忽略。"); - continue; - } - - // 添加到字典 - IDTomangyaoPrefab.Add(id, prefab); - } - - // 测试输出 - foreach (var kvp in IDTomangyaoPrefab) - { - Debug.Log($"初始化字典 - ID: {kvp.Key}, Prefab: {kvp.Value.name}"); - } - } - + /// /// 根据CarryCardId列表生成对应的萌妖卡牌 /// @@ -128,10 +77,12 @@ public class cardBox : Base foreach (string id in carryCardIdList) { - if (IDTomangyaoPrefab.TryGetValue(id, out GameObject prefab)) + mengyaoInfo info= MY_Infos.instane.GetMY(id); + if (info != null) { + // 实例化预制体,设置父节点为 parentPos - GameObject card = Instantiate(prefab, parentPos); + GameObject card = Instantiate(info.cardprefab, parentPos); //card.GetComponent().enemyId = id; //this.card.Add(card); // 确保卡牌的缩放为0,准备进行放大动画 @@ -142,10 +93,6 @@ public class cardBox : Base // 播放放大动画 card.transform.DOScale(Vector3.one, scaleUpDuration).SetEase(Ease.OutBack); } - else - { - Debug.LogWarning($"未找到ID为 '{id}' 的萌妖卡预制体!"); - } } } diff --git a/meng_yao/Assets/script/A_Fight/cardContorl.cs b/meng_yao/Assets/script/A_Fight/cardContorl.cs index 551e4c0d..71e2c112 100644 --- a/meng_yao/Assets/script/A_Fight/cardContorl.cs +++ b/meng_yao/Assets/script/A_Fight/cardContorl.cs @@ -85,7 +85,9 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD MengyaoInfo.Instance.mengyaoIdToRole.Add(mY.GetComponent().id, mY); - SpawnPool.intance.Enemys.Add(mY);//瀛樺叆鍥惧眰鎺掑簭鐨勬暟缁 + //SpawnPool.intance.Enemys.Add(mY);//瀛樺叆鍥惧眰鎺掑簭鐨勬暟缁 + + this.enabled = false; cardBox.instance.ChangeInPlaceNumber(1); mask.SetActive(true); diff --git a/meng_yao/Assets/script/A_Fight/gameGlobal.cs b/meng_yao/Assets/script/A_Fight/gameGlobal.cs index 126d8e0d..bcb17714 100644 --- a/meng_yao/Assets/script/A_Fight/gameGlobal.cs +++ b/meng_yao/Assets/script/A_Fight/gameGlobal.cs @@ -35,7 +35,7 @@ public class gameGlobal : Base /// public static void GamePlay() { - Debug.Log("游戏开始"); + Debug.LogError("游戏开始"); Base.GlobalObj.GetComponent().OnGamePlay?.Invoke(); }