可以出怪了
This commit is contained in:
parent
d3f6d3b850
commit
5a1e673363
@ -15,7 +15,7 @@ GameObject:
|
||||
- component: {fileID: 5307107303863668509}
|
||||
- component: {fileID: 7795976296569843979}
|
||||
m_Layer: 0
|
||||
m_Name: min_1
|
||||
m_Name: wood_min
|
||||
m_TagString: Enemy
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -53,17 +53,8 @@ MonoBehaviour:
|
||||
retbutton: {fileID: 0}
|
||||
ClosureObj: {fileID: 0}
|
||||
waypoints:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
moveSpeed: 0.005
|
||||
_waypoints: []
|
||||
moveSpeed: 1
|
||||
--- !u!114 &4703411402755586929
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
@ -73,7 +73,7 @@ SpriteRenderer:
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 3d9fbac889d5ad5409d8a8bb65c7ba3a, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 3377bd6700dff1f4ebe4454a514d3822, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
@ -131,7 +131,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
bulletPrefab: {fileID: 6998733212867311352, guid: 95e4d74ef33230c4380bb2d0780887b2, type: 3}
|
||||
role: {fileID: 8433650274028726420}
|
||||
attackScope: 5
|
||||
attackScope: 3
|
||||
damageTyp: 2
|
||||
--- !u!58 &1338343970434073545
|
||||
CircleCollider2D:
|
||||
|
@ -1503,6 +1503,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 284432670}
|
||||
- component: {fileID: 284432671}
|
||||
m_Layer: 0
|
||||
m_Name: Map
|
||||
m_TagString: Untagged
|
||||
@ -1532,6 +1533,30 @@ Transform:
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &284432671
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 284432669}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4a6960ebcba29544a8785122fac8093a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mywaypoints:
|
||||
- _waypoints:
|
||||
- {fileID: 734893407}
|
||||
- {fileID: 1597666921}
|
||||
- {fileID: 530562779}
|
||||
- {fileID: 1116367165}
|
||||
- {fileID: 1552201272}
|
||||
- {fileID: 920394797}
|
||||
- {fileID: 7595786}
|
||||
- {fileID: 3435906}
|
||||
- {fileID: 16085906}
|
||||
- {fileID: 11828202}
|
||||
--- !u!1 &294282775
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2828,6 +2853,7 @@ GameObject:
|
||||
- component: {fileID: 453763631}
|
||||
- component: {fileID: 453763630}
|
||||
- component: {fileID: 453763629}
|
||||
- component: {fileID: 453763634}
|
||||
m_Layer: 5
|
||||
m_Name: SkillBox
|
||||
m_TagString: Untagged
|
||||
@ -2948,6 +2974,18 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 453763627}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &453763634
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 453763627}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d98d344c0c9573d45a72a1677d806d7d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &457244935
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -6753,8 +6791,8 @@ GameObject:
|
||||
- component: {fileID: 1136445686}
|
||||
- component: {fileID: 1136445685}
|
||||
- component: {fileID: 1136445684}
|
||||
- component: {fileID: 1136445687}
|
||||
- component: {fileID: 1136445688}
|
||||
- component: {fileID: 1136445687}
|
||||
m_Layer: 5
|
||||
m_Name: cardBox
|
||||
m_TagString: Untagged
|
||||
@ -9407,11 +9445,6 @@ Rigidbody2D:
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
--- !u!4 &1500347571 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
m_PrefabInstance: {fileID: 4703411402755586925}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1520004766
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -10540,13 +10573,14 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 55658941a61a95a449a60aa939a8c641, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
retbutton: {fileID: 0}
|
||||
ClosureObj: {fileID: 0}
|
||||
BloodText: {fileID: 1288391609}
|
||||
KIllNumber: {fileID: 1595305660}
|
||||
allNumer: 0
|
||||
Battle_Time: {fileID: 971885053}
|
||||
Levels_number: {fileID: 744270342}
|
||||
Going_to_warNumber: 0
|
||||
FightBtn: {fileID: 1942153354}
|
||||
--- !u!1 &1691173992
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -11504,8 +11538,9 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1884241085}
|
||||
- component: {fileID: 1884241086}
|
||||
m_Layer: 0
|
||||
m_Name: InitEnemy
|
||||
m_Name: SpawnMonster
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -11522,11 +11557,31 @@ Transform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1500347571}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 284432670}
|
||||
m_RootOrder: 5
|
||||
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: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fdf69f16194abb24d9e887468940e1cb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
retbutton: {fileID: 0}
|
||||
ClosureObj: {fileID: 0}
|
||||
Prefab: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
SpawnLocation: {fileID: 734893407}
|
||||
GenerateParentNode: {fileID: 1884241085}
|
||||
GenerationInterval: 15
|
||||
GenerationIntervalOfOne: 3
|
||||
GenerateQuantityMax: 5
|
||||
GenerateQuantity: 5
|
||||
--- !u!1 &1893328339
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -11987,7 +12042,31 @@ MonoBehaviour:
|
||||
m_TargetGraphic: {fileID: 1942153355}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1136445682}
|
||||
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 453763627}
|
||||
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
--- !u!114 &1942153355
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -13281,112 +13360,3 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8d398c914061e5842b409729ac3d43c1, type: 3}
|
||||
--- !u!1001 &4703411402755586925
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 1884241085}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -4.64
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 6.6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954782, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: wood
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: moveSpeed
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[0]
|
||||
value:
|
||||
objectReference: {fileID: 734893407}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[1]
|
||||
value:
|
||||
objectReference: {fileID: 1597666921}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[2]
|
||||
value:
|
||||
objectReference: {fileID: 530562779}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[3]
|
||||
value:
|
||||
objectReference: {fileID: 1116367165}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[4]
|
||||
value:
|
||||
objectReference: {fileID: 1552201272}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[5]
|
||||
value:
|
||||
objectReference: {fileID: 920394797}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[6]
|
||||
value:
|
||||
objectReference: {fileID: 7595786}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[7]
|
||||
value:
|
||||
objectReference: {fileID: 3435906}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[8]
|
||||
value:
|
||||
objectReference: {fileID: 16085906}
|
||||
- target: {fileID: 4703411402755586928, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: waypoints.Array.data[9]
|
||||
value:
|
||||
objectReference: {fileID: 11828202}
|
||||
- target: {fileID: 4703411402842800734, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
propertyPath: m_Sprite
|
||||
value:
|
||||
objectReference: {fileID: 21300000, guid: 84a26d718c953fb4f86bb6bb6a84f089, type: 3}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
|
||||
|
40
meng_yao/Assets/script/A_Fight/InitEnenyData.cs
Normal file
40
meng_yao/Assets/script/A_Fight/InitEnenyData.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.GlobalIllumination;
|
||||
|
||||
|
||||
public class InitEnenyData : MonoBehaviour
|
||||
{
|
||||
public static InitEnenyData instance;
|
||||
[Header("路径点集合")] public List<waypoints> mywaypoints = new List<waypoints>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
Debug.Log(mywaypoints.Count);
|
||||
}
|
||||
|
||||
// 返回一个随机选择的路径点集合
|
||||
public waypoints GetRandomWaypoints()
|
||||
{
|
||||
// 检查列表是否为空,避免数组越界错误
|
||||
if (mywaypoints.Count == 0)
|
||||
{
|
||||
Debug.LogError("路径点集合为空!");
|
||||
return null; // 或者返回一个默认值
|
||||
}
|
||||
|
||||
// 如果只有一个路径点集合,直接返回
|
||||
if (mywaypoints.Count == 1)
|
||||
{
|
||||
return mywaypoints[0];
|
||||
}
|
||||
|
||||
// 随机选择一个索引,范围是 [0, mywaypoints.Count - 1]
|
||||
int randomIndex = Random.Range(0, mywaypoints.Count);
|
||||
|
||||
// 返回随机选择的路径点集合
|
||||
return mywaypoints[randomIndex];
|
||||
}
|
||||
}
|
11
meng_yao/Assets/script/A_Fight/InitEnenyData.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/InitEnenyData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a6960ebcba29544a8785122fac8093a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
meng_yao/Assets/script/A_Fight/SkillBox.cs
Normal file
18
meng_yao/Assets/script/A_Fight/SkillBox.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SkillBox : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
meng_yao/Assets/script/A_Fight/SkillBox.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/SkillBox.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d98d344c0c9573d45a72a1677d806d7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
165
meng_yao/Assets/script/A_Fight/SpawnPool.cs
Normal file
165
meng_yao/Assets/script/A_Fight/SpawnPool.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ObJPool<T>
|
||||
{
|
||||
public List<T> SurvivalPool = new List<T>();
|
||||
public List<T> DeathPool = new List<T>();
|
||||
|
||||
// 获取一个对象
|
||||
public T Get()
|
||||
{
|
||||
if (DeathPool.Count > 0)
|
||||
{
|
||||
// 如果死亡池中有对象,则从死亡池中取出并转移到生存池
|
||||
T obj = DeathPool[0];
|
||||
DeathPool.RemoveAt(0);
|
||||
SurvivalPool.Add(obj);
|
||||
return obj;
|
||||
}
|
||||
return default(T); // 如果没有可用对象,则返回默认值
|
||||
}
|
||||
|
||||
// 回收一个对象
|
||||
public void Return(T obj)
|
||||
{
|
||||
if (SurvivalPool.Contains(obj))
|
||||
{
|
||||
SurvivalPool.Remove(obj);
|
||||
DeathPool.Add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SpawnPool : Base
|
||||
{
|
||||
public ObJPool<GameObject> EnemyPool = new ObJPool<GameObject>();
|
||||
|
||||
[Header("生成预制体")]
|
||||
public GameObject Prefab;
|
||||
|
||||
[Header("生成位置")]
|
||||
public Transform SpawnLocation;
|
||||
|
||||
[Header("生成父节点")]
|
||||
public Transform GenerateParentNode;
|
||||
|
||||
[Header("一波生成间隔")]
|
||||
public float GenerationInterval;
|
||||
|
||||
[Header("一次生成间隔")]
|
||||
public float GenerationIntervalOfOne;
|
||||
|
||||
[Header("生成总数量")]
|
||||
public float GenerateQuantityMax;
|
||||
|
||||
[Header("每一波生成数量")]
|
||||
public float GenerateQuantity;
|
||||
|
||||
private float lastGenerationTime = 0f; // 记录上一波生成的时间
|
||||
private float lastSingleGenerationTime = 0f; // 记录生成单个敌人之间的时间
|
||||
private int generatedCount = 0; // 记录已生成敌人的数量
|
||||
private int currentWave = 0; // 当前波数
|
||||
private bool isGenerating = false; // 标记是否在生成敌人
|
||||
private bool isWaveComplete = false; // 标记当前波是否完成
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay += this.StartSpawning;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (isGenerating)
|
||||
{
|
||||
if (isWaveComplete)
|
||||
{
|
||||
// 如果当前波已完成,等待下一波
|
||||
if (Time.time - lastGenerationTime >= GenerationInterval)
|
||||
{
|
||||
StartNextWave(); // 启动下一波生成
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 判断是否到了生成一波敌人的时间
|
||||
if (Time.time - lastSingleGenerationTime >= GenerationIntervalOfOne && generatedCount < GenerateQuantity)
|
||||
{
|
||||
GenerateEnemy(); // 生成单个敌人
|
||||
lastSingleGenerationTime = Time.time; // 更新生成单个敌人的时间
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StartSpawning()
|
||||
{
|
||||
// 重置生成计数,开始生成敌人
|
||||
generatedCount = 0;
|
||||
currentWave = 0;
|
||||
lastGenerationTime = Time.time; // 记录开始生成的时间
|
||||
isGenerating = true; // 启动生成敌人
|
||||
isWaveComplete = false; // 当前波尚未完成
|
||||
}
|
||||
|
||||
void StartNextWave()
|
||||
{
|
||||
currentWave++; // 增加波数
|
||||
if (generatedCount < GenerateQuantityMax) // 如果生成的敌人数量未达到最大值
|
||||
{
|
||||
generatedCount = 0; // 重置每波生成数量
|
||||
lastGenerationTime = Time.time; // 记录下一波开始的时间
|
||||
isWaveComplete = false; // 当前波未完成
|
||||
}
|
||||
else
|
||||
{
|
||||
isGenerating = false; // 如果已经生成完所有敌人,则停止生成
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateEnemy()
|
||||
{
|
||||
if (generatedCount < GenerateQuantity && generatedCount < GenerateQuantityMax)
|
||||
{
|
||||
GameObject enemy = EnemyPool.Get(); // 获取一个敌人对象
|
||||
|
||||
// 如果池子中没有可用的对象,创建新的敌人
|
||||
if (enemy == null)
|
||||
{
|
||||
if (Prefab == null)
|
||||
{
|
||||
Debug.LogError("Prefab is not assigned.");
|
||||
return;
|
||||
}
|
||||
|
||||
enemy = Instantiate(Prefab, SpawnLocation.position, Quaternion.identity, GenerateParentNode);
|
||||
}
|
||||
|
||||
// 设置敌人的位置和其他属性
|
||||
enemy.SetActive(true); // 激活敌人对象
|
||||
enemy.transform.position = SpawnLocation.position;
|
||||
|
||||
generatedCount++; // 更新生成计数
|
||||
|
||||
// 每波生成数量达到上限时,标记当前波已完成
|
||||
if (generatedCount >= GenerateQuantity)
|
||||
{
|
||||
isWaveComplete = true; // 当前波生成完毕
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当池子中敌人死亡或者被回收时,将其回收到池中
|
||||
public void ReturnEnemyToPool(GameObject enemy)
|
||||
{
|
||||
enemy.SetActive(false); // 禁用敌人对象
|
||||
EnemyPool.Return(enemy); // 将敌人回收到池中
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay -= this.StartSpawning;
|
||||
}
|
||||
}
|
11
meng_yao/Assets/script/A_Fight/SpawnPool.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/SpawnPool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdf69f16194abb24d9e887468940e1cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIContorl : MonoBehaviour
|
||||
public class UIContorl : Base
|
||||
{
|
||||
public static UIContorl instance;
|
||||
public Text BloodText;
|
||||
@ -12,8 +12,7 @@ public class UIContorl : MonoBehaviour
|
||||
public Text Battle_Time;
|
||||
public Text Levels_number;
|
||||
public int Going_to_warNumber;
|
||||
public Button FightBtn;
|
||||
|
||||
|
||||
|
||||
|
||||
private float timeElapsed = 0f; // ¼Ç¼¾¹ýµÄʱ¼ä
|
||||
@ -24,20 +23,20 @@ public class UIContorl : MonoBehaviour
|
||||
if (instance != null) return;
|
||||
instance = this;
|
||||
|
||||
FightBtn.onClick.AddListener(FightClick);
|
||||
//FightBtn.onClick.AddListener(FightClick);
|
||||
Battle_Time.text = "00:00";
|
||||
StopTimer();
|
||||
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay += this.StartTimer;
|
||||
}
|
||||
|
||||
void FightClick()
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StartTimer();
|
||||
|
||||
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay -= this.StartTimer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@ -75,5 +74,13 @@ public class UIContorl : MonoBehaviour
|
||||
Battle_Time.text = "00:00";
|
||||
}
|
||||
|
||||
public void GameVitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GameOver()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ public class cardBox : MonoBehaviour
|
||||
btnObj.SetActive(true);
|
||||
btnObj.GetComponent<Button>().onClick.AddListener(() => {
|
||||
gameGlobal.GamePlay();
|
||||
btnObj.SetActive(false);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,33 @@ public class enemy : Role
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
if (camp == Camp.Enemy)
|
||||
{
|
||||
//开始移动
|
||||
Navigation.MoveToNextWaypoint(this.gameObject);
|
||||
Init(InitEnenyData.instance.GetRandomWaypoints());
|
||||
}
|
||||
}
|
||||
|
||||
public void Init(waypoints _waypoints)
|
||||
{
|
||||
base.Navigation.waypoints = _waypoints;
|
||||
|
||||
//开始移动
|
||||
Navigation.MoveToNextWaypoint(this.gameObject);
|
||||
|
||||
}
|
||||
|
||||
public override void die()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
// 将当前敌人对象放入死亡池
|
||||
SpawnPool spawnPool = Base.GlobalObj.GetComponent<SpawnPool>(); // 获取 SpawnPool 组件
|
||||
if (spawnPool != null)
|
||||
{
|
||||
spawnPool.ReturnEnemyToPool(this.gameObject); // 回收当前敌人到池中
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user