From 479a0fcfc2162aa3df59103c2dfed9e899a2490b Mon Sep 17 00:00:00 2001 From: Trimutex Date: Thu, 14 Mar 2024 11:56:10 -0500 Subject: [PATCH] Quickly added Enemy_4 --- Assets/Scenes/_Scene_0.unity | 3 +- Assets/_Prefabs/Enemy_2.prefab | 2 +- Assets/_Prefabs/Enemy_3.prefab | 2 +- Assets/_Prefabs/Enemy_4.prefab | 90 +++++++++++++++++++++++---- Assets/__Scripts/Enemy_4.cs | 61 ++++++++++++++++-- Assets/__Scripts/Weapon.cs | 34 ++++++++++ Assets/__Scripts/Weapon.cs.meta | 11 ++++ ProjectSettings/QualitySettings.asset | 27 +++++--- 8 files changed, 202 insertions(+), 28 deletions(-) create mode 100644 Assets/__Scripts/Weapon.cs create mode 100644 Assets/__Scripts/Weapon.cs.meta diff --git a/Assets/Scenes/_Scene_0.unity b/Assets/Scenes/_Scene_0.unity index 99b5c58..67408a2 100644 --- a/Assets/Scenes/_Scene_0.unity +++ b/Assets/Scenes/_Scene_0.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} + m_IndirectSpecularColor: {r: 0.18028328, g: 0.22571328, b: 0.3069218, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -475,6 +475,7 @@ MonoBehaviour: - {fileID: 1716873588767813483, guid: ba65718b1eee9fde8b64fc1c56f7fcd7, type: 3} - {fileID: 1454311047477341964, guid: c033931eb931661a285a471741bae343, type: 3} - {fileID: 1454311047477341964, guid: c033931eb931661a285a471741bae343, type: 3} + - {fileID: 5688048094632641677, guid: 68c912c6fd38ee6258ae1295410e82ea, type: 3} enemySpawnPerSecond: 0.5 enemyDefaultPadding: 1.5 --- !u!1 &998017458 diff --git a/Assets/_Prefabs/Enemy_2.prefab b/Assets/_Prefabs/Enemy_2.prefab index 53b7456..990cc7c 100644 --- a/Assets/_Prefabs/Enemy_2.prefab +++ b/Assets/_Prefabs/Enemy_2.prefab @@ -183,7 +183,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a2b7c79b712fe5c9ca22495cdf2f32b7, type: 3} m_Name: m_EditorClassIdentifier: - radius: -2.5 + radius: 3 keepOnScreen: 0 isOnScreen: 1 camWidth: 0 diff --git a/Assets/_Prefabs/Enemy_3.prefab b/Assets/_Prefabs/Enemy_3.prefab index 0a96493..412ed15 100644 --- a/Assets/_Prefabs/Enemy_3.prefab +++ b/Assets/_Prefabs/Enemy_3.prefab @@ -375,7 +375,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a2b7c79b712fe5c9ca22495cdf2f32b7, type: 3} m_Name: m_EditorClassIdentifier: - radius: -2.5 + radius: 2.5 keepOnScreen: 0 isOnScreen: 1 camWidth: 0 diff --git a/Assets/_Prefabs/Enemy_4.prefab b/Assets/_Prefabs/Enemy_4.prefab index 0efe218..678038b 100644 --- a/Assets/_Prefabs/Enemy_4.prefab +++ b/Assets/_Prefabs/Enemy_4.prefab @@ -10,6 +10,8 @@ GameObject: m_Component: - component: {fileID: 5688048094632641678} - component: {fileID: 5688048094632641679} + - component: {fileID: 6012299646585092094} + - component: {fileID: 6289777641844929688} m_Layer: 9 m_Name: Enemy_4 m_TagString: Enemy @@ -52,6 +54,67 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 120 m_CollisionDetection: 0 +--- !u!114 &6012299646585092094 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5688048094632641677} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a2b7c79b712fe5c9ca22495cdf2f32b7, type: 3} + m_Name: + m_EditorClassIdentifier: + radius: 3.5 + keepOnScreen: 0 + isOnScreen: 1 + camWidth: 0 + camHeight: 0 + offRight: 0 + offLeft: 0 + offUp: 0 + offDown: 0 +--- !u!114 &6289777641844929688 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5688048094632641677} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 890512b9c88f600408f25130d273807b, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 10 + fireRate: 0.3 + health: 10 + score: 100 + parts: + - name: Cockpit + health: 10 + protectedBy: + - Fuselage + go: {fileID: 0} + mat: {fileID: 0} + - name: Fuselage + health: 10 + protectedBy: + - WingL + - WingR + go: {fileID: 0} + mat: {fileID: 0} + - name: WingL + health: 10 + protectedBy: [] + go: {fileID: 0} + mat: {fileID: 0} + - name: WingR + health: 10 + protectedBy: [] + go: {fileID: 0} + mat: {fileID: 0} --- !u!1 &5688048095306501618 GameObject: m_ObjectHideFlags: 0 @@ -63,7 +126,7 @@ GameObject: - component: {fileID: 5688048095306501619} - component: {fileID: 5688048095306501622} - component: {fileID: 5688048095306501621} - - component: {fileID: 5688048095306501620} + - component: {fileID: 1336262608} m_Layer: 9 m_Name: WingR m_TagString: Untagged @@ -136,8 +199,8 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!135 &5688048095306501620 -SphereCollider: +--- !u!136 &1336262608 +CapsuleCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -146,8 +209,9 @@ SphereCollider: m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 m_Radius: 0.5 + m_Height: 1 + m_Direction: 0 m_Center: {x: 0, y: 0, z: 0} --- !u!1 &5688048095477329001 GameObject: @@ -160,7 +224,7 @@ GameObject: - component: {fileID: 5688048095477329002} - component: {fileID: 5688048095477329005} - component: {fileID: 5688048095477329004} - - component: {fileID: 5688048095477329003} + - component: {fileID: 1336262606} m_Layer: 9 m_Name: WingL m_TagString: Untagged @@ -233,8 +297,8 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!135 &5688048095477329003 -SphereCollider: +--- !u!136 &1336262606 +CapsuleCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -243,8 +307,9 @@ SphereCollider: m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 m_Radius: 0.5 + m_Height: 1 + m_Direction: 0 m_Center: {x: 0, y: 0, z: 0} --- !u!1 &5688048095502189620 GameObject: @@ -257,7 +322,7 @@ GameObject: - component: {fileID: 5688048095502189621} - component: {fileID: 5688048095502189624} - component: {fileID: 5688048095502189623} - - component: {fileID: 5688048095502189622} + - component: {fileID: 1336262604} m_Layer: 9 m_Name: Fuselage m_TagString: Untagged @@ -330,8 +395,8 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!135 &5688048095502189622 -SphereCollider: +--- !u!136 &1336262604 +CapsuleCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -340,8 +405,9 @@ SphereCollider: m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 m_Radius: 0.5 + m_Height: 1 + m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} --- !u!1 &5688048095870530698 GameObject: diff --git a/Assets/__Scripts/Enemy_4.cs b/Assets/__Scripts/Enemy_4.cs index 502e046..5c1506b 100644 --- a/Assets/__Scripts/Enemy_4.cs +++ b/Assets/__Scripts/Enemy_4.cs @@ -2,17 +2,66 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +/// +/// Enemy_4 will start offscreen and then pick a random point on screen to +/// move to. Once it has arrived, it will pick another random point and +/// continue until the player has shot it down. +/// + +[System.Serializable] +public class Part { + // These three fields need to be defined in the Inspector pane + public string name; + public float health; + public string[] protectedBy; + [HideInInspector] + public GameObject go; + [HideInInspector] + public Material mat; +} + public class Enemy_4 : Enemy { - // Start is called before the first frame update + [Header("Set in Inspector: Enemy_4")] + public Part[] parts; + private Vector3 p0, p1; // The two points to interpolate + private float timeStart; // Birth time for this Enemy_4 + private float duration = 4; // Duration of movement + void Start() { - + // There is already an initial position chosen by Main.SpawnEnemy() + // so add it to points as the initial p0 & p1 + p0 = p1 = pos; + InitMovement(); + Transform t; + foreach(Part prt in parts) { + t = transform.Find(prt.name); + if (t != null) { + prt.go = t.gameObject; + prt.mat = prt.go.GetComponent().material; + } + } } - // Update is called once per frame - void Update() - { - + void InitMovement() { + p0 = p1; // Set p0 to the old p1 + // Assign a new on-screen location to p1 + float widMinRad = bndCheck.camWidth - bndCheck.radius; + float hgtMinRad = bndCheck.camHeight - bndCheck.radius; + p1.x = Random.Range(-widMinRad, widMinRad); + p1.y = Random.Range(-hgtMinRad, hgtMinRad); + // Reset the time + timeStart = Time.time; + } + public override void Move() { + // This completely overrides Enemy.Move() with a linear interpolation + float u = (Time.time - timeStart) / duration; + if (u >= 1) { + InitMovement(); + u = 0; + } + u = 1 - Mathf.Pow(1 - u, 2); // Apply East Out easing to u + pos = (1 - u) * p0 + u*p1; // Simple linear interpolation } } diff --git a/Assets/__Scripts/Weapon.cs b/Assets/__Scripts/Weapon.cs new file mode 100644 index 0000000..ab100ae --- /dev/null +++ b/Assets/__Scripts/Weapon.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// This is an enum of the various possible weapon types. +/// It also includes a "shield" type to allow a shield power-up. +/// Items marked [NI] below are Not Implemented in the IGDPD book. +/// + +public enum WeaponType { + none, // The default / no weapon + blaster, // A simple blaster + spread, // Two shots simultaneously + phaser, // [NI] Shots that move in waves + missile, // [NI] Homing missiles + laser, // [NI]Damage over time + shield // Raise shieldLevel +} + +public class Weapon : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/__Scripts/Weapon.cs.meta b/Assets/__Scripts/Weapon.cs.meta new file mode 100644 index 0000000..5a1b8d5 --- /dev/null +++ b/Assets/__Scripts/Weapon.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a45dacce959bdd1c943cd342de8d377 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 36c0dad..a8367c1 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -18,7 +18,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 1 + skinWeights: 1 textureQuality: 1 anisotropicTextures: 0 antiAliasing: 0 @@ -27,6 +27,7 @@ QualitySettings: realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 vSyncCount: 0 + realtimeGICPUUsage: 25 lodBias: 0.3 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -40,6 +41,7 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] - serializedVersion: 2 name: Low @@ -53,7 +55,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 2 + skinWeights: 2 textureQuality: 0 anisotropicTextures: 0 antiAliasing: 0 @@ -62,6 +64,7 @@ QualitySettings: realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 vSyncCount: 0 + realtimeGICPUUsage: 25 lodBias: 0.4 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -75,6 +78,7 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] - serializedVersion: 2 name: Medium @@ -88,7 +92,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 0 - blendWeights: 2 + skinWeights: 2 textureQuality: 0 anisotropicTextures: 1 antiAliasing: 0 @@ -97,6 +101,7 @@ QualitySettings: realtimeReflectionProbes: 0 billboardsFaceCameraPosition: 0 vSyncCount: 1 + realtimeGICPUUsage: 25 lodBias: 0.7 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -110,6 +115,7 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] - serializedVersion: 2 name: High @@ -123,7 +129,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 2 + skinWeights: 2 textureQuality: 0 anisotropicTextures: 1 antiAliasing: 0 @@ -132,6 +138,7 @@ QualitySettings: realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 vSyncCount: 1 + realtimeGICPUUsage: 50 lodBias: 1 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -145,6 +152,7 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] - serializedVersion: 2 name: Very High @@ -158,7 +166,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 4 + skinWeights: 4 textureQuality: 0 anisotropicTextures: 2 antiAliasing: 2 @@ -167,6 +175,7 @@ QualitySettings: realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 vSyncCount: 1 + realtimeGICPUUsage: 50 lodBias: 1.5 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -180,6 +189,7 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] - serializedVersion: 2 name: Ultra @@ -193,7 +203,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 4 + skinWeights: 4 textureQuality: 0 anisotropicTextures: 2 antiAliasing: 2 @@ -202,6 +212,7 @@ QualitySettings: realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 vSyncCount: 1 + realtimeGICPUUsage: 100 lodBias: 2 maximumLODLevel: 0 streamingMipmapsActive: 0 @@ -215,16 +226,18 @@ QualitySettings: asyncUploadBufferSize: 16 asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 + customRenderPipeline: {fileID: 0} excludedTargetPlatforms: [] m_PerPlatformDefaultQuality: Android: 2 - Lumin: 5 GameCoreScarlett: 5 GameCoreXboxOne: 5 + Lumin: 5 Nintendo 3DS: 5 Nintendo Switch: 5 PS4: 5 PS5: 5 + Server: 0 Stadia: 5 Standalone: 5 WebGL: 3