·
This commit is contained in:
parent
cf74453414
commit
23e93aa5a2
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -225,8 +225,15 @@ namespace Assets.Scripts
|
||||
{
|
||||
transform.position = point;
|
||||
Quaternion rot = Quaternion.FromToRotation(Vector3.forward, toDirection);
|
||||
var impact = Instantiate(impactPrefab, point, rot);
|
||||
return impact.transform;
|
||||
var impact = PoolTool.GetFromPool(PoolTool.impactPool); //Instantiate(impactPrefab, point, rot);
|
||||
if (impact != null)
|
||||
{
|
||||
impact.position = point;
|
||||
impact.rotation = rot;
|
||||
impact.gameObject.SetActive(true);
|
||||
return impact;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision collision)
|
||||
|
||||
39
Assets/Scripts/RecycleImpact.cs
Normal file
39
Assets/Scripts/RecycleImpact.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RecycleImpact : MonoBehaviour
|
||||
{
|
||||
public float timer { get; set; } = 0;
|
||||
public float deathtimer = 5;
|
||||
|
||||
public bool isNeedDestroyInRecycle { get; set; } = false;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (timer >= deathtimer)
|
||||
{
|
||||
timer = 0;
|
||||
if (isNeedDestroyInRecycle)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
//isNeedDestroyInRecycle = false;
|
||||
PoolTool.RecycleImpactToPool(transform);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/RecycleImpact.cs.meta
Normal file
11
Assets/Scripts/RecycleImpact.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: CSlNvX+pW36vfy5e5XuhCmuoIt2voyxaZtk+cnr7dupJAL8+4Flj/V0=
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -102,6 +102,25 @@ public class Shot : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var impact in PoolTool.activeImpactPool)
|
||||
{
|
||||
if (impact != null)
|
||||
{
|
||||
impact.DOKill();
|
||||
var recycle = impact.GetComponent<RecycleImpact>();
|
||||
recycle.isNeedDestroyInRecycle = true;
|
||||
}
|
||||
}
|
||||
foreach (var impact in PoolTool.impactPool)
|
||||
{
|
||||
if (impact != null)
|
||||
{
|
||||
impact.DOKill(true);
|
||||
Destroy(impact.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//foreach (var bullet in activeBullets)
|
||||
//{
|
||||
// if (bullet != null)
|
||||
@ -120,9 +139,11 @@ public class Shot : MonoBehaviour
|
||||
// }
|
||||
//}
|
||||
// Çå¿Õ¾ÉÊý¾Ý
|
||||
PoolTool.activeImpactPool.Clear();
|
||||
PoolTool.activeBulletPool.Clear();
|
||||
PoolTool.bulletPool.Clear();
|
||||
PoolTool.muzzlePool.Clear();
|
||||
PoolTool.impactPool.Clear();
|
||||
}
|
||||
|
||||
public void InitializePool()
|
||||
@ -147,6 +168,16 @@ public class Shot : MonoBehaviour
|
||||
muzzleObj.SetParent(null);
|
||||
muzzleObj.name = $"Muzzle_{i}";
|
||||
PoolTool.muzzlePool.Enqueue(muzzleObj);
|
||||
|
||||
for (int j = 0; j < continueShotCount / 3; j++)
|
||||
{
|
||||
// ±¬Õ¨»ðÑæ¶ÔÏó
|
||||
var impactObj = Instantiate(impact);
|
||||
impactObj.gameObject.SetActive(false);
|
||||
impactObj.SetParent(null);
|
||||
impactObj.name = $"Impact_{i}";
|
||||
PoolTool.impactPool.Enqueue(impactObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class PoolTool
|
||||
@ -13,7 +14,9 @@ public class PoolTool
|
||||
// 使用Queue代替List,避免重复分配同一对象
|
||||
public static ConcurrentQueue<Transform> bulletPool = new();
|
||||
public static ConcurrentQueue<Transform> muzzlePool = new();
|
||||
public static ConcurrentQueue<Transform> impactPool = new();
|
||||
public static List<Transform> activeBulletPool = new();
|
||||
public static List<Transform> activeImpactPool = new();
|
||||
|
||||
|
||||
// 从池中获取对象
|
||||
@ -32,6 +35,10 @@ public class PoolTool
|
||||
{
|
||||
activeBulletPool.Add(obj);
|
||||
}
|
||||
else if (obj.GetComponent<RecycleImpact>() != null)
|
||||
{
|
||||
activeImpactPool.Add(obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@ -43,7 +50,7 @@ public class PoolTool
|
||||
// 回收对象到池
|
||||
public static void RecycleToPool(Transform obj, ConcurrentQueue<Transform> pool)
|
||||
{
|
||||
if (obj == null) return;
|
||||
if (obj == null || obj.IsDestroyed()) return;
|
||||
// 避免重复入队
|
||||
if (!pool.Contains(obj))
|
||||
{
|
||||
@ -121,7 +128,14 @@ public class PoolTool
|
||||
|
||||
public static void RecycleMuzzleToPool(Transform muzzleObj)
|
||||
{
|
||||
activeImpactPool.Remove(muzzleObj);
|
||||
// 回收对象
|
||||
RecycleToPool(muzzleObj, muzzlePool);
|
||||
}
|
||||
|
||||
public static void RecycleImpactToPool(Transform impactObj)
|
||||
{
|
||||
// »ØÊÕ¶ÔÏó
|
||||
RecycleToPool(impactObj, impactPool);
|
||||
}
|
||||
}
|
||||
|
||||
@ -780,6 +780,9 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 2088730278}
|
||||
- {fileID: 194344596}
|
||||
- {fileID: 1089566221}
|
||||
- {fileID: 1162584676}
|
||||
- {fileID: 1581003590}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &832575517
|
||||
@ -1025,7 +1028,7 @@ MonoBehaviour:
|
||||
- {fileID: 456072, guid: 961ddd3dd5b4e4c45bfa80f72977c2fb, type: 3}
|
||||
- {fileID: 410446, guid: fe9effd36d82932419a7254b415acfac, type: 3}
|
||||
attackInterval: 5
|
||||
enemyMoveSpeed: 1
|
||||
enemyMoveSpeed: 0.8
|
||||
boomClip: {fileID: 8300000, guid: 66e0e24e6ada67b4ba418891e0d2460a, type: 3}
|
||||
audioSource: {fileID: 875388860}
|
||||
initEachEnemyCount: 300
|
||||
@ -1188,6 +1191,9 @@ MonoBehaviour:
|
||||
shotTypeInfos:
|
||||
- {fileID: 2088730279}
|
||||
- {fileID: 194344597}
|
||||
- {fileID: 1089566222}
|
||||
- {fileID: 1162584677}
|
||||
- {fileID: 1581003591}
|
||||
--- !u!1 &1060461332
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1378,6 +1384,110 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1064514691}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1089566220
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 7
|
||||
m_Component:
|
||||
- component: {fileID: 1089566221}
|
||||
- component: {fileID: 1089566222}
|
||||
m_Layer: 0
|
||||
m_HasEditorInfo: 1
|
||||
m_Name: Plasma_Small_RagingRed
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1089566221
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1089566220}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 661400241}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1089566222
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1089566220}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2d07d5c5aa1d2614898139699d11349c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
bulletPrefab: {fileID: 4010437552377404, guid: 3e8f90cf5ace53541b8523ce5200cdc5,
|
||||
type: 3}
|
||||
muzzlePrefab: {fileID: 4000010921236120, guid: 6a0a0f7a97e0e7747accda091cb14743,
|
||||
type: 3}
|
||||
impactPrefab: {fileID: 4541196389373984, guid: b2123df6038fb164faef17d57b22aab8,
|
||||
type: 3}
|
||||
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
|
||||
--- !u!1 &1162584675
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 7
|
||||
m_Component:
|
||||
- component: {fileID: 1162584676}
|
||||
- component: {fileID: 1162584677}
|
||||
m_Layer: 0
|
||||
m_HasEditorInfo: 1
|
||||
m_Name: Plasma_Medium_RagingRed
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1162584676
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1162584675}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 661400241}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1162584677
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1162584675}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2d07d5c5aa1d2614898139699d11349c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
bulletPrefab: {fileID: 4836675779974994, guid: 46bf08350ee566542b0bb087e35a1020,
|
||||
type: 3}
|
||||
muzzlePrefab: {fileID: 4000010921236120, guid: 033d08e548a8e0c4b85a2110d068aaa0,
|
||||
type: 3}
|
||||
impactPrefab: {fileID: 4541196389373984, guid: 194f033b43d363949850b7e8cf1cff4d,
|
||||
type: 3}
|
||||
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
|
||||
--- !u!1 &1291040292
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1569,7 +1679,7 @@ PrefabInstance:
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
propertyPath: lerpSpeed
|
||||
value: 12
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
@ -1599,12 +1709,12 @@ PrefabInstance:
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
propertyPath: shotDuration
|
||||
value: 0.8
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
propertyPath: initBulletCount
|
||||
value: 120
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
@ -1614,7 +1724,7 @@ PrefabInstance:
|
||||
- target: {fileID: 4223598142436431064, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
propertyPath: continueShotCount
|
||||
value: 18
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223598142436519823, guid: dff892f3d9e393b4b917d5e340840461,
|
||||
type: 3}
|
||||
@ -1855,6 +1965,58 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1581003589
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 7
|
||||
m_Component:
|
||||
- component: {fileID: 1581003590}
|
||||
- component: {fileID: 1581003591}
|
||||
m_Layer: 0
|
||||
m_HasEditorInfo: 1
|
||||
m_Name: Plasma_Big_RagingRed
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1581003590
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1581003589}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 661400241}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1581003591
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1581003589}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2d07d5c5aa1d2614898139699d11349c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
bulletPrefab: {fileID: 4836675779974994, guid: 659fe3ff3c5cb6640a2decc431b3351b,
|
||||
type: 3}
|
||||
muzzlePrefab: {fileID: 4000010921236120, guid: 3735129208580034781b585da5229bda,
|
||||
type: 3}
|
||||
impactPrefab: {fileID: 4636209284918014, guid: cfd26614dff7742469a59d19d1403e93,
|
||||
type: 3}
|
||||
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
|
||||
--- !u!1 &1647833152
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -42,7 +42,7 @@ PlayerSettings:
|
||||
height: 1
|
||||
m_SplashScreenLogos: []
|
||||
m_VirtualRealitySplashScreen: {fileID: 0}
|
||||
expectedBundleIdentifier: com.Unity-Technologies.com.unity.template.urp-blank
|
||||
expectedBundleIdentifier: com.xsoft.UMiniGame
|
||||
integrityHash:
|
||||
m_HolographicTrackingLossScreen: {fileID: 0}
|
||||
defaultScreenWidth: 1024
|
||||
@ -1020,7 +1020,7 @@ PlayerSettings:
|
||||
-s ERROR_ON_UNDEFINED_SYMBOLS=0 -s TOTAL_MEMORY=256MB -s EXPORTED_RUNTIME_METHODS=''["ccall","cwrap","stackTrace","addRunDependency","removeRunDependency","FS_createPath","FS_createDataFile","stackTrace","writeStackCookie","checkStackCookie","lengthBytesUTF8","stringToUTF8"]''
|
||||
--profiling-funcs '
|
||||
weixinMiniGameModulesDirectory:
|
||||
weixinMiniGameTemplate: PATH:E:\Dev\UMiniGame\Library\PackageCache\com.qq.weixin.minigame@4443e5a9bc\WebGLTemplates\WXTemplate2022TJ
|
||||
weixinMiniGameTemplate: PATH:E:\Dev3\UMiniGame\Library\PackageCache\com.qq.weixin.minigame@4443e5a9bc\WebGLTemplates\WXTemplate2022TJ
|
||||
weixinMiniGameAnalyzeBuildSize: 0
|
||||
weixinMiniGameUseEmbeddedResources: 0
|
||||
weixinMiniGameCompressionFormat: 2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user