my生成流程优化
This commit is contained in:
parent
59234a2201
commit
dbc0ccb565
@ -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
|
||||
|
@ -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<mengyaoInfo> mengyaoItems=new List<mengyaoInfo>();
|
||||
public Dictionary<string, mengyaoInfo> mengyaoItemsDic=new Dictionary<string, mengyaoInfo>();
|
||||
|
||||
public MY_Infos instane;
|
||||
public static MY_Infos instane;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public class SpawnMonster : Base
|
||||
{
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay += this.StartSpawning;
|
||||
|
||||
StartSpawning();
|
||||
//StartSpawning();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<MengyaoCardData> mengyaoCardDataList = new List<MengyaoCardData>();
|
||||
// [Header("萌妖卡数据列表")] public List<MengyaoCardData> mengyaoCardDataList = new List<MengyaoCardData>();
|
||||
|
||||
[Header("萌妖卡生成父节点")] public Transform parentPos;
|
||||
|
||||
@ -54,8 +45,6 @@ public class cardBox : Base
|
||||
}
|
||||
|
||||
btnObj.SetActive(false);
|
||||
|
||||
InitializeDictionary();
|
||||
Init();
|
||||
mengyaoNumber = Base.GlobalObj.GetComponent<gameGlobal>().CarryCardId.Count;
|
||||
}
|
||||
@ -77,47 +66,7 @@ public class cardBox : Base
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化ID到萌妖卡预制体的映射字典
|
||||
/// </summary>
|
||||
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}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据CarryCardId列表生成对应的萌妖卡牌
|
||||
/// </summary>
|
||||
@ -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<enemy>().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}' 的萌妖卡预制体!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,9 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
||||
|
||||
|
||||
MengyaoInfo.Instance.mengyaoIdToRole.Add(mY.GetComponent<Role>().id, mY);
|
||||
SpawnPool.intance.Enemys.Add(mY);//存入图层排序的数组
|
||||
//SpawnPool.intance.Enemys.Add(mY);//存入图层排序的数组
|
||||
|
||||
|
||||
this.enabled = false;
|
||||
cardBox.instance.ChangeInPlaceNumber(1);
|
||||
mask.SetActive(true);
|
||||
|
@ -35,7 +35,7 @@ public class gameGlobal : Base
|
||||
/// </summary>
|
||||
public static void GamePlay()
|
||||
{
|
||||
Debug.Log("ÓÎÏ·¿ªÊ¼");
|
||||
Debug.LogError("ÓÎÏ·¿ªÊ¼");
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay?.Invoke();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user