This commit is contained in:
wuyanchen 2025-12-14 02:47:24 +08:00
parent 73e6e23b25
commit baf4650de4
12 changed files with 555 additions and 217 deletions

View File

@ -9834,7 +9834,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 913389bb25514f945a75c1f728a4c72c, type: 3}
m_Name:
m_EditorClassIdentifier:
power: 20
power: 10
impactPrefab: {fileID: 1879272669879180, guid: af3f3fa832ef8314bb22c5462402c60c,
type: 3}
explosionPrefab: {fileID: 0}

View File

@ -343,9 +343,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8fbf64442775d0c4588c964ad8189b6f, type: 3}
m_Name:
m_EditorClassIdentifier:
minHealthPercent: 30
minHealthPercent: 50
maxHealthPercent: 100
health: 600
health: 800
boomClip: {fileID: 0}
addEulerX: 0
randomColors:

View File

@ -643,27 +643,22 @@ MonoBehaviour:
muzzleFlare: {fileID: 4000010921236120, guid: 6a0a0f7a97e0e7747accda091cb14743,
type: 3}
bullet: {fileID: 4010437552377404, guid: 3e8f90cf5ace53541b8523ce5200cdc5, type: 3}
continueShotCount: 3
continueShotCount: 6
turret: {fileID: 1898544591301130533}
gun: {fileID: 5342608149001152939}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: 66e0e24e6ada67b4ba418891e0d2460a, type: 3}
shotDuration: 0.6
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.3
shotNextDuration: 0.1
shotDistance: 20
shotSpeed: 15
initBulletCount: 50
shotSpeed: 8
initBulletCount: 60
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 5
isAutoLock: 1
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
bulletPool: []
muzzlePool: []
impactPool: []
activeBulletPool: []
activeImpactPool: []
--- !u!114 &7274453853465530569
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -279,7 +279,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 18e44bc2064cb1c46b4422845bd22c3c, type: 3}
m_Name:
m_EditorClassIdentifier:
initCount: 5
initCount: 2
radius: 1.8
splitAngle: 0
isAlwaysForward: 1
@ -617,7 +617,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5478a23f7df147343a281b57c8c1266b, type: 3}
m_Name:
m_EditorClassIdentifier:
scrollSpeed: 80
scrollSpeed: 100
autoGetImages: 1
bgImage1: {fileID: 1138813635}
bgImage2: {fileID: 2083258310}
@ -1597,6 +1597,72 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 675573596}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &767662249
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 767662250}
- component: {fileID: 767662251}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: gun4
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &767662250
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 767662249}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 6, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1393153739}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &767662251
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 767662249}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 3
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.2
shotNextDuration: 0
shotDistance: 20
shotSpeed: 10
initBulletCount: 100
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
--- !u!1 &832575517
GameObject:
m_ObjectHideFlags: 0
@ -2087,7 +2153,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ea61fc73ec358734a88958690331a363, type: 3}
m_Name:
m_EditorClassIdentifier:
towerShot: {fileID: 1393153741}
towerShots:
- {fileID: 1687021955}
- {fileID: 1634638536}
- {fileID: 2060519314}
- {fileID: 767662251}
- {fileID: 1067060385}
shotTypeInfos:
- {fileID: 194344597}
- {fileID: 2088730279}
@ -2204,6 +2275,72 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1067060383
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 1067060384}
- component: {fileID: 1067060385}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: gun5
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &1067060384
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1067060383}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -6, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1393153739}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1067060385
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1067060383}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 3
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.2
shotNextDuration: 0
shotDistance: 20
shotSpeed: 10
initBulletCount: 100
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
--- !u!1 &1089566220
GameObject:
m_ObjectHideFlags: 0
@ -2285,7 +2422,7 @@ RectTransform:
m_GameObject: {fileID: 1138813630}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 4.064236, y: 4.064236, z: 1}
m_LocalScale: {x: 4.314236, y: 4.314236, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 97192695}
@ -2800,12 +2937,28 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 1110803909258152, guid: 2d237edc016bc304b97f97864fdb21e3,
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 4757137707858686, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
addedObject: {fileID: 1393153741}
addedObject: {fileID: 1687021954}
- targetCorrespondingSourceObject: {fileID: 4757137707858686, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
addedObject: {fileID: 1634638535}
- targetCorrespondingSourceObject: {fileID: 4757137707858686, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
addedObject: {fileID: 2060519313}
- targetCorrespondingSourceObject: {fileID: 4757137707858686, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
addedObject: {fileID: 767662250}
- targetCorrespondingSourceObject: {fileID: 4757137707858686, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
addedObject: {fileID: 1067060384}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 1110803909258152, guid: 2d237edc016bc304b97f97864fdb21e3,
type: 3}
insertIndex: -1
@ -2827,44 +2980,6 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 1393153738}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1393153741
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1393153740}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 0
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: 66e0e24e6ada67b4ba418891e0d2460a, type: 3}
shotDuration: 0.35
shotNextDuration: 0.1
shotDistance: 20
shotSpeed: 20
initBulletCount: 3
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
bulletPool: []
muzzlePool: []
impactPool: []
activeBulletPool: []
activeImpactPool: []
--- !u!65 &1393153744
BoxCollider:
m_ObjectHideFlags: 0
@ -3062,6 +3177,72 @@ MonoBehaviour:
muzzlePrefab: {fileID: 4000010921236120, guid: 3735129208580034781b585da5229bda,
type: 3}
shotAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
--- !u!1 &1634638534
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 1634638535}
- component: {fileID: 1634638536}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: gun2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1634638535
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1634638534}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1393153739}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1634638536
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1634638534}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 3
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.2
shotNextDuration: 0
shotDistance: 20
shotSpeed: 10
initBulletCount: 100
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
--- !u!1 &1647833152
GameObject:
m_ObjectHideFlags: 0
@ -3217,6 +3398,72 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1687021953
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 1687021954}
- component: {fileID: 1687021955}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: gun1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1687021954
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1687021953}
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: 1393153739}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1687021955
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1687021953}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 3
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.2
shotNextDuration: 0
shotDistance: 20
shotSpeed: 10
initBulletCount: 100
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
--- !u!1 &1688022838
GameObject:
m_ObjectHideFlags: 0
@ -3491,6 +3738,72 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2060519312
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 2060519313}
- component: {fileID: 2060519314}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: gun3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2060519313
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2060519312}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1393153739}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2060519314
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2060519312}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a739626fceb3d447a4f4b5c690de189, type: 3}
m_Name:
m_EditorClassIdentifier:
ringManager: {fileID: 46038312}
impact: {fileID: 4541196389373984, guid: af3f3fa832ef8314bb22c5462402c60c, type: 3}
muzzleFlare: {fileID: 4000010921236120, guid: 66ce0f27574363a4dabe7162e2636e3f,
type: 3}
bullet: {fileID: 4638688750665566, guid: 1b81ed6643072854688c442ec72032d6, type: 3}
continueShotCount: 3
turret: {fileID: 0}
gun: {fileID: 0}
shotAudioClip: {fileID: 8300000, guid: 038911361e37ae84b8fdc585b7b83895, type: 3}
hitAudioClip: {fileID: 8300000, guid: a6290313a43dc7c4fb5c684559b9b776, type: 3}
shotDuration: 0.2
shotNextDuration: 0
shotDistance: 20
shotSpeed: 10
initBulletCount: 100
shotOffsetZMul: 0
shotFixAngleX: 0
lerpSpeed: 8
isAutoLock: 0
pressAction: {fileID: 76562581802851548, guid: 50486e0197319e948b872b25ef15b507,
type: 3}
--- !u!1 &2083258305
GameObject:
m_ObjectHideFlags: 0
@ -3520,7 +3833,7 @@ RectTransform:
m_GameObject: {fileID: 2083258305}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 4.064236, y: 4.064236, z: 1}
m_LocalScale: {x: 4.314236, y: 4.314236, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 97192695}

View File

@ -4,11 +4,11 @@ using UnityEngine;
public class NextShotInfo
{
public Transform bulletObj { get; set; } = null;
public Enemy Enemy { get; set; } = null;
public int CurrentShotCount { get; set; } = 0;
public Vector3? InitBulletPos { get; set; } = null;
public Transform BulletObj { get; set; } = null;
}

View File

@ -4,7 +4,7 @@ using UnityEngine;
public class TowerManager : MonoBehaviour
{
public Shot towerShot = null;
public Shot[] towerShots = new Shot[] { };
public ShotTypeInfo[] shotTypeInfos = new ShotTypeInfo[] { };
private int currentShotTypeIndex = 0;
// Start is called before the first frame update
@ -23,6 +23,10 @@ public class TowerManager : MonoBehaviour
}
var shotTypeInfo = shotTypeInfos[currentShotTypeIndex];
for (int i = 0; i < towerShots.Length; i++)
{
var towerShot = towerShots[i];
towerShot.bullet = shotTypeInfo.bulletPrefab;
towerShot.muzzleFlare = shotTypeInfo.muzzlePrefab;
towerShot.impact = shotTypeInfo.impactPrefab;
@ -30,6 +34,7 @@ public class TowerManager : MonoBehaviour
towerShot.InitializePool();
towerShot.shotAudioClip = shotTypeInfo.shotAudioClip;
}
}
//// Update is called once per frame
//void Update()

View File

@ -40,13 +40,15 @@ namespace Assets.Scripts
///// </summary>
//public bool IsLockedTarget { get; set; } = false;
public Enemy LockTarget { get; set; } = null;
public Enemy HitTarget { get; set; } = null;
public Enemy BeforeHitTarget { get; set; } = null;
private Vector3 _shotTargetPosition = Vector3.zero;
public Vector3 ShotTargetPosition
{
get
{
if (IsAutoLock && LockTarget != null)
if (LockTarget != null)
{
_shotTargetPosition = LockTarget.transform.position;
//return LockTarget.transform.position;
@ -58,7 +60,6 @@ namespace Assets.Scripts
_shotTargetPosition = value;
}
}
public Enemy hittedEnemy { get; set; } = null;
public bool LookRotation = true;
public bool Missile = false;
public Transform missileTarget;
@ -151,7 +152,7 @@ namespace Assets.Scripts
return null;
}
var enemy = hit.collider.gameObject.GetComponent<Enemy>();
if (enemy != null)
if (enemy != null && enemy != BeforeHitTarget)
{
rthit = hit;
minDistance = hit.distance;
@ -215,7 +216,6 @@ namespace Assets.Scripts
return;//穿过
}
bool isHitted = false;
if (enemy != null)
{
////如果子弹在怪物前面或者相交
@ -238,8 +238,13 @@ namespace Assets.Scripts
//}
if (VisibilityTool.IsObjectInFrustum(enemy.gameObject, _cam))
{
if (BeforeHitTarget != enemy)
{
BeforeHitTarget = enemy;//保证只触发一次
HitTarget = enemy;
currentHitPosition = enemy.transform.position;
isHitted = true;
Hitted();
}
}
//}
}
@ -260,13 +265,13 @@ namespace Assets.Scripts
// Tweener.Kill(true);
//}
if (isHitted)
{
hittedEnemy = enemy;
Hitted();
//ResetBullet(transform, impact);
//transform.DOKill(true);
}
//if (isHitted)
//{
// LockTarget = enemy;
// Hitted();
// //ResetBullet(transform, impact);
// //transform.DOKill(true);
//}
}
}
}
@ -334,6 +339,19 @@ namespace Assets.Scripts
Hitted();
}
/// <summary>
/// 重置锁定的敌方对象,以及击中的敌方对象
/// </summary>
public void ResetEnemyTargets()
{
//IsLockedTarget = false;
HitTarget = null;
LockTarget = null;
}
/// <summary>
/// 重置当前复用变量状态
/// </summary>
public void ResetBullet()
{
Tweener = null;
@ -341,9 +359,8 @@ namespace Assets.Scripts
currentHitPosition = Vector3.zero;
IsAutoLock = false;
//IsLockedTarget = false;
hittedEnemy = null;
LockTarget = null;
ResetEnemyTargets();
BeforeHitTarget = null;
_shotTargetPosition = Vector3.zero;
//currentShotCount = 0;

View File

@ -93,6 +93,7 @@ public class EnemyManager : MonoBehaviour
//}
//else
//{
enemyComp.transform.name = $"Enemy_{i}";
if (enemyComp != null)
{
yield return null; // Adjust the interval as needed

View File

@ -66,7 +66,7 @@ public class Shot : MonoBehaviour
private Vector3 turretLerpEuler = Vector3.zero;
private float smoothXAngle = 0f;
private float targetXAngle = 0f;
private float hitDistance = 0.2f; // 命中检测距离阈值
private float hitDistance = 0.1f; // 命中检测距离阈值
private bool isCanShot = false;
private bool isStartAttack = false;
private ConcurrentQueue<NextShotInfo> nextShotInfos = new();
@ -74,12 +74,12 @@ public class Shot : MonoBehaviour
// 使用Queue代替List避免重复分配同一对象
public List<Transform> bulletPool = new();
public List<Transform> muzzlePool = new();
public List<Transform> impactPool = new();
public List<Transform> activeBulletPool = new();
public List<Transform> activeImpactPool = new();
// 弹仓List避免重复分配对象
private List<Transform> bulletPool = new();
private List<Transform> muzzlePool = new();
private List<Transform> impactPool = new();
private List<Transform> activeBulletPool = new();
private List<Transform> activeImpactPool = new();
private Camera _cam = null;
@ -144,7 +144,7 @@ public class Shot : MonoBehaviour
{
if (muzzle != null)
{
muzzle.DOKill();
//muzzle.DOKill();
Destroy(muzzle.gameObject);
}
}
@ -153,7 +153,7 @@ public class Shot : MonoBehaviour
{
if (impact != null)
{
impact.DOKill();
//impact.DOKill();
var recycle = impact.GetComponent<RecycleImpact>();
recycle.IsNeedDestroyInRecycle = true;
}
@ -162,7 +162,7 @@ public class Shot : MonoBehaviour
{
if (impact != null)
{
impact.DOKill(true);
//impact.DOKill(true);
Destroy(impact.gameObject);
}
}
@ -287,10 +287,6 @@ public class Shot : MonoBehaviour
while (true)
{
if (nextShotInfos.TryDequeue(out NextShotInfo info))
{
SingleShot(info.Enemy, true, info.CurrentShotCount, info.InitBulletPos, info.BulletObj);
}
if (shotNextDuration == 0)
{
yield return null;
@ -299,6 +295,10 @@ public class Shot : MonoBehaviour
{
yield return new WaitForSeconds(shotNextDuration);
}
if (nextShotInfos.TryDequeue(out NextShotInfo info))
{
SingleShot(info.Enemy, true, info.CurrentShotCount, info.InitBulletPos, info.bulletObj);
}
}
}
@ -311,6 +311,7 @@ public class Shot : MonoBehaviour
/// <param name="bulletObj"></param>
private void SingleShot(Enemy lockEnemy, bool isNextLineShot, int currentShotCount = 0, Vector3? initBulletPos = null, Transform bulletObj = null)
{
//Debug.Log(currentShotCount + ":" + initBulletPos);
Transform muzzleObj = null;
if (bulletObj == null || bulletObj.IsDestroyed())
{
@ -324,6 +325,8 @@ public class Shot : MonoBehaviour
if (bulletObj != null)
{
// 1. 强制重置所有状态
//PoolTool.ResetTransform(bulletObj);
// 6. 激活对象
bulletObj.gameObject.SetActive(true);
// 10. 播放音效
@ -332,8 +335,6 @@ public class Shot : MonoBehaviour
AudioTool.AudioSource.PlayOneShot(shotAudioClip);
}
//// 1. 强制重置所有状态
//PoolTool.ResetTransform(bulletObj);
//PoolTool.ResetTransform(muzzleObj);
// 2. 计算发射位置(确保使用世界坐标)
@ -356,11 +357,14 @@ public class Shot : MonoBehaviour
var bulletComp = bulletObj.GetComponent<Bullet>();
bulletComp.IsAutoLock = isAutoLock;
bulletComp.IsShoting = true;
if ((isAutoLock || initBulletPos != null) && lockEnemy != null && !lockEnemy.IsDestroyed())
var beforeHitTargetTransform = bulletComp.BeforeHitTarget == null ? null : bulletComp.BeforeHitTarget.transform;
if (isNextLineShot)
{
bulletComp.LockTarget = lockEnemy;
bulletComp.ShotTargetPosition = lockEnemy.transform.position;
//bulletObj.transform.LookAt(targetPos);
bulletComp.LockTarget = GetNearestEnemyFromTransform(bulletObj, beforeHitTargetTransform);
if (bulletComp.LockTarget != null)
{
//Debug.Log((bulletComp.BeforeHitTarget == null ? null : bulletComp.BeforeHitTarget.name) + ":" + bulletComp.LockTarget.name);
bulletComp.ShotTargetPosition = bulletComp.LockTarget.transform.position;
}
else
{
@ -368,7 +372,20 @@ public class Shot : MonoBehaviour
pos.y = gun.position.y;
bulletComp.ShotTargetPosition = pos;
}
var tmpTargetPos = bulletComp.ShotTargetPosition;
}
else if (isAutoLock && lockEnemy != null && !lockEnemy.IsDestroyed())
{
bulletComp.LockTarget = lockEnemy;
bulletComp.ShotTargetPosition = lockEnemy.transform.position;
}
else
{
var pos = gun.position + gun.forward * shotDistance;
pos.y = gun.position.y;
bulletComp.ShotTargetPosition = pos;
}
//var tmpTargetPos = bulletComp.ShotTargetPosition;
//bulletObj.LookAt(bulletComp.ShotTargetPosition);
bulletObj.transform.eulerAngles = Vector3.zero;
@ -381,26 +398,33 @@ public class Shot : MonoBehaviour
muzzleObj.transform.LookAt(bulletComp.ShotTargetPosition);
}
Vector3? lockTargetPos = null;
//每次创建前 Kill 旧 Tween
bulletComp.Tweener?.Kill(false);
//var worldTop = _cam.ScreenToWorldPoint(new Vector3(0, Screen.height, _cam.nearClipPlane));
//var yDistance = worldTop.z - transform.position.z;
//float shotDuration = 1f / shotSpeed;
// DOTween.To动态更新弹体位置每帧计算目标位置
bulletComp.Tweener = DOTween.To(
() => bulletObj == null ? transform.position : bulletObj.position, // 当前位置Getter
(Vector3 pos) =>
() =>
{
return bulletObj == null ? transform.position : bulletObj.position; // 当前位置Getter
}, (Vector3 pos) =>
{
if (bulletObj != null)
{
bulletObj.position = Vector3.MoveTowards(bulletObj.position, bulletComp.ShotTargetPosition, Time.deltaTime * shotSpeed);
} // 更新位置Setter
},
tmpTargetPos,
bulletComp.ShotTargetPosition,//目标位置
shotSpeed
)
.SetSpeedBased()
.SetEase(Ease.Linear)
//.OnPlay(() =>
//{
// Debug.Log("Play");
//})
//.SetLoops(0) // 不循环
.OnUpdate(() =>
{
@ -429,7 +453,7 @@ public class Shot : MonoBehaviour
{
if (bulletComp.LockTarget == null)
{
bulletComp.LockTarget = GetNearestEnemyFromBullet(bullet);
bulletComp.LockTarget = GetNearestEnemyFromTransform(bulletObj, beforeHitTargetTransform);
//bulletComp.IsLockedTarget = true;
}
}
@ -438,70 +462,82 @@ public class Shot : MonoBehaviour
if (bulletComp.LockTarget != null && bulletObj != null)
{
//var targetDir = (bulletComp.LockTarget.transform.position - bulletObj.transform.position).normalized;
bulletObj.LookAt(bulletComp.LockTarget.transform.position);
bulletComp.ShotTargetPosition = bulletComp.LockTarget.transform.position;
bulletObj.LookAt(bulletComp.ShotTargetPosition);
//bulletObj.forward = Vector3.Lerp(
// bulletObj.forward,
// targetDir,
// Time.deltaTime * lerpSpeed // 转向灵敏度
//);
//bulletComp.ShotTargetPosition = bulletComp.LockTarget.transform.position;
}
//if (isNextLineShot)
//{
//非自动锁定状态,在轨迹更新过程中也判断是否击中
if (!isAutoLock)
if (CalcBulletBoom(bulletComp))
{
CalcBulletBoom(bulletComp, bulletComp.LockTarget);
bulletObj.DOComplete(true);
bulletObj.DOKill();
}
//暂存击中的目标位置
lockTargetPos = CheckBulletBoom(bulletComp, true);
})
.OnPlay(() =>
{
//}
})
.OnComplete(() =>
{
//if (currentShotCount > 0)
//{
//Debug.Log(currentShotCount);
// Debug.Log(currentShotCount);
//}
bulletComp.LockTarget = CalcBulletBoom(bulletComp, bulletComp.LockTarget);
bool isBulletHitted = CalcBulletBoom(bulletComp);
if (bulletComp.LockTarget != null && hitAudioClip != null)
if (bulletComp.HitTarget != null && hitAudioClip != null)
{
AudioTool.AudioSource.PlayOneShot(hitAudioClip);
}
if (bulletComp.HitTarget != null)
{
currentShotCount++;
if (currentShotCount <= continueShotCount)
{
//bulletComp.currentShotCount = currentShotCount;
PoolTool.RecycleMuzzleToPool(muzzleObj, this.muzzlePool, this.activeImpactPool);
var nextLockTarget = GetNearestEnemyFromTarget(bulletComp.currentHitPosition, bulletComp.LockTarget);
var nextLockTarget = GetNearestEnemyFromTransform(bulletObj, bulletComp.HitTarget == null ? bulletObj : bulletComp.HitTarget.transform);
if (nextLockTarget != null)
{
//SingleShot(nextLockTarget, bulletComp.transform.position, bulletComp.transform);//弹射
lockTargetPos = CheckBulletBoom(bulletComp, false);
//InitBulletPos = lockTargetPos,从击中的目标位置开始弹射
nextShotInfos.Enqueue(new NextShotInfo { CurrentShotCount = currentShotCount, Enemy = nextLockTarget, InitBulletPos = lockTargetPos });
Vector3 initBulletPos = bulletObj.position;
Transform hitTransform = null;
if (bulletComp.HitTarget != null)
{
hitTransform = bulletComp.HitTarget.transform;
initBulletPos = hitTransform.position;
}
PoolTool.RecycleBulletToPool(bulletObj, this.bulletPool, this.activeBulletPool);
//SingleShot(nextLockTarget, true, currentShotCount, bulletObj.position, null);//连线射击
CheckBulletBoom(isBulletHitted, bulletComp, false);
bulletComp.ResetEnemyTargets();
nextShotInfos.Enqueue(new NextShotInfo { CurrentShotCount = currentShotCount, Enemy = nextLockTarget, InitBulletPos = initBulletPos, bulletObj = bulletObj });
//SingleShot(nextLockTarget, true, currentShotCount, initBulletPos, bulletObj);//连线射击
//PoolTool.RecycleBulletToPool(bulletObj, this.bulletPool, this.activeBulletPool);
}
else
{
CheckBulletBoom(bulletComp, false);
PoolTool.RecycleBulletToPool(bulletObj, this.bulletPool, this.activeBulletPool);
CheckBulletBoom(isBulletHitted, bulletComp);
}
}
else
{
CheckBulletBoom(bulletComp, false);
PoolTool.RecycleTarget(bulletObj, muzzleObj, this.bulletPool, this.activeBulletPool, this.muzzlePool, this.activeImpactPool);
CheckBulletBoom(isBulletHitted, bulletComp);
}
}
else
{
CheckBulletBoom(isBulletHitted, bulletComp);
}
});
//// 8. 子弹飞行(使用线性缓动,强制世界坐标)
//yield return bulletObj.DOMove(targetPos, shotSpeed)
// .SetEase(Ease.Linear)
@ -550,26 +586,37 @@ public class Shot : MonoBehaviour
}
}
private Vector3? CheckBulletBoom(Bullet bulletComp, bool withCallback)
private void CheckBulletBoom(bool isBulletHitted, Bullet bulletComp, bool recycleToPool = true)
{
if (isBulletHitted)
{
CheckBulletBoom(bulletComp);
}
if (recycleToPool)
{
PoolTool.RecycleBulletToPool(bulletComp.transform, this.bulletPool, this.activeBulletPool);
}
}
private Vector3? CheckBulletBoom(Bullet bulletComp)
{
Vector3? hitPosition = null;
Enemy hittedEnemy = bulletComp.hittedEnemy;
if (hittedEnemy != null)
if (bulletComp.HitTarget != null)// && bulletComp.HitTarget != bulletComp.BeforeHitTarget)
{
//Calc is Boom
hitPosition = hittedEnemy.transform.position;
bool isDestroyed = hittedEnemy.TakeDamage(bulletComp.power);//对敌方造成伤害
hitPosition = bulletComp.HitTarget.transform.position;
bool isDestroyed = bulletComp.HitTarget.TakeDamage(bulletComp.power);//对敌方造成伤害
Vector3 targetDir = (bulletComp.transform.position - hitPosition.Value).normalized;
var impact = PoolTool.GetFromPool(this.impactPool, this.activeBulletPool, this.activeImpactPool); //Instantiate(impactPrefab, point, rot);
bulletComp.InitImpact(hitPosition.Value, targetDir, impact);//爆炸效果
//if (bulletComp.Tweener != null)
//{
// bulletComp.Tweener.Complete(withCallback);
//}
//bulletComp.transform.DOKill();
if (isDestroyed)
{
if (bulletComp.Tweener != null)
{
bulletComp.Tweener.Complete(withCallback);
}
bulletComp.transform.DOKill();
lockEnemy = null;
}
}
@ -577,45 +624,43 @@ public class Shot : MonoBehaviour
}
private Enemy CalcBulletBoom(Bullet bulletComp, Enemy lockTarget)
private bool CalcBulletBoom(Bullet bulletComp)
{
if (bulletComp.hittedEnemy != null)
{
lockTarget = bulletComp.hittedEnemy;
}
bool isBulletHitted = false;
// 命中检测(距离达标则触发效果)
if (bulletComp.gameObject != null)
{
bool isNeedDestroy = !VisibilityTool.IsObjectInFrustum(bulletComp.gameObject, _cam);
if (lockTarget == null)
if (bulletComp.HitTarget != null)
{
if (isNeedDestroy)
{
if (bulletComp.Tweener != null)
{
bulletComp.Tweener.Complete(true);
}
bulletComp.transform.DOKill();
}
return true;
}
else
{
if (!isNeedDestroy)
{
float currentDistance = Vector3.Distance(bulletComp.transform.position, lockTarget.transform.position);
isNeedDestroy = currentDistance < hitDistance;
//在摄像机看到的屏幕范围之外,销毁子弹
isBulletHitted = !VisibilityTool.IsObjectInFrustum(bulletComp.gameObject, _cam);
}
if (!isBulletHitted && bulletComp.LockTarget != null && bulletComp.HitTarget != bulletComp.BeforeHitTarget)
{
float currentDistance = Vector3.Distance(bulletComp.transform.position, bulletComp.LockTarget.transform.position);
isBulletHitted = currentDistance < hitDistance;
if (isBulletHitted)
{
bulletComp.currentHitPosition = bulletComp.LockTarget.transform.position;
bulletComp.HitTarget = bulletComp.LockTarget;
bulletComp.BeforeHitTarget = bulletComp.HitTarget;
bulletComp.IsShoting = false;
}
bulletComp.currentHitPosition = lockTarget.transform.position;
}
//if (isDestroyed)
//{
// bulletComp.Tweener.Kill(true);
// //bulletObj.DOKill(true); // 停止Tween
//}
////HitTarget(bulletObj, muzzleObj);
// HitTarget(bulletObj, muzzleObj);
//}
}
return lockTarget;
return isBulletHitted;
}
// 计算弹体到目标的距离
@ -660,11 +705,12 @@ public class Shot : MonoBehaviour
// Debug.Log("cc:" + Global.LockedEnemies.Count);
//}
isStartAttack = false;
lockEnemy = GetNearestEnemyFromTarget(transform.position);
lockEnemy = GetNearestEnemyFromTransform(transform);
}
}
private Enemy GetNearestEnemyFromTarget(Vector3 targetPosition, Enemy currentHitTarget = null)
private Enemy GetNearestEnemyFromTransform(Transform bullet, Transform currentHitTarget = null)
{
Enemy result = null;
float minDistance = float.MaxValue;
@ -673,45 +719,12 @@ public class Shot : MonoBehaviour
var enemy = Global.Enemies[i];
if (enemy != null)
{
if (enemy == currentHitTarget)
{
continue;
}
float distance = Vector3.Distance(enemy.transform.position, targetPosition);
if (distance < minDistance && distance <= shotDistance)// && (ringManager == null || distance > ringManager.radius * 1.2f))// && !Global.LockedEnemies.ContainsKey(enemy.GetHashCode()))
{
if (VisibilityTool.IsObjectInFrustum(enemy.gameObject, _cam))
{
minDistance = distance;
result = enemy;
}
}
}
}
//if (result == null)
//{
// result = Global.Enemies.FirstOrDefault(m => !m.IsDestroyed());
//}
return result;
}
private Enemy GetNearestEnemyFromBullet(Transform bullet, Enemy currentHitTarget = null)
{
Enemy result = null;
float minDistance = float.MaxValue;
for (int i = 0; i < Global.Enemies.Count; i++)
{
var enemy = Global.Enemies[i];
if (enemy != null)
{
if (enemy == currentHitTarget)
if (enemy.transform == currentHitTarget)
{
continue;
}
float distance = GetDistanceToTarget(bullet, enemy.transform);
if (distance < minDistance && distance <= shotDistance)// && (ringManager == null || distance > ringManager.radius * 1.2f))// && !Global.LockedEnemies.ContainsKey(enemy.GetHashCode()))
{
if (_cam.orthographic)
if (distance < minDistance && distance < shotDistance)// && (ringManager == null || distance > ringManager.radius * 1.2f))// && !Global.LockedEnemies.ContainsKey(enemy.GetHashCode()))
{
if (VisibilityTool.IsObjectInFrustum(enemy.gameObject, _cam))
{
@ -719,12 +732,6 @@ public class Shot : MonoBehaviour
result = enemy;
}
}
else
{
minDistance = distance;
result = enemy;
}
}
}
}
//if (result == null)

View File

@ -59,7 +59,7 @@ public class PoolTool
trans.DOKill(false); // 强制杀死所有Tween
trans.SetParent(null); // 解除父对象
trans.localPosition = Vector3.zero;
//trans.localPosition = Vector3.zero;
//trans.localRotation = Quaternion.identity;
//trans.localScale = Vector3.one;

View File

@ -29,7 +29,7 @@ MonoBehaviour:
HideAfterCallMain: 1
preloadFiles:
Orientation: 0
bgImageSrc: Assets/Game1/Images/SplashScreen/SplashScreen2.jpg
bgImageSrc: Assets/TowerDefence/Images/SplashScreen/SplashScreen.jpg
dataFileSubPrefix:
maxStorage: 200
defaultReleaseSize: 31457280

View File

@ -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