diff --git a/Dashing Game/Assets/Animations/Bosses/Blue Boss/Blue Boss.controller b/Dashing Game/Assets/Animations/Bosses/Blue Boss/Blue Boss.controller index 5f43404..c2a4c8c 100644 --- a/Dashing Game/Assets/Animations/Bosses/Blue Boss/Blue Boss.controller +++ b/Dashing Game/Assets/Animations/Bosses/Blue Boss/Blue Boss.controller @@ -20,7 +20,7 @@ AnimatorStateMachine: m_Position: {x: 230, y: 40, z: 0} - serializedVersion: 1 m_State: {fileID: 1251312478059000220} - m_Position: {x: 660, y: 90, z: 0} + m_Position: {x: 650, y: 120, z: 0} - serializedVersion: 1 m_State: {fileID: -2928596363445292714} m_Position: {x: 330, y: 200, z: 0} @@ -95,6 +95,7 @@ AnimatorState: - {fileID: 8303012563343611412} - {fileID: -2488752863267885873} - {fileID: -3508950133702914361} + - {fileID: 333677228979568451} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -160,6 +161,31 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &-1853959785950605784 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Attacking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1251312478059000220} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.16666669 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1102 &-8152611591141699 AnimatorState: serializedVersion: 5 @@ -172,6 +198,7 @@ AnimatorState: m_CycleOffset: 0 m_Transitions: - {fileID: -6294498665775269145} + - {fileID: 5938847018950598198} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -208,6 +235,12 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} + - m_Name: Attacking + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -246,6 +279,31 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &333677228979568451 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Attacking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1251312478059000220} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1102 &1251312478059000220 AnimatorState: serializedVersion: 5 @@ -256,7 +314,8 @@ AnimatorState: m_Name: Attack m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 3596594635372602630} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -272,6 +331,53 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1101 &3596594635372602630 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 7498111437746153888} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.00041224062 + m_TransitionOffset: 0 + m_ExitTime: 1 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &3823466464427555917 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Attacking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1251312478059000220} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.7499837 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &5352517473065479359 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -319,6 +425,31 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &5938847018950598198 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Attacking + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1251312478059000220} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.16666669 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1102 &7498111437746153888 AnimatorState: serializedVersion: 5 @@ -333,6 +464,7 @@ AnimatorState: - {fileID: 293618008045705192} - {fileID: 5527169875789893316} - {fileID: -2534424938766695017} + - {fileID: 3823466464427555917} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -360,6 +492,7 @@ AnimatorState: m_CycleOffset: 0 m_Transitions: - {fileID: 5352517473065479359} + - {fileID: -1853959785950605784} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 diff --git a/Dashing Game/Assets/Boss Levels/Blue Boss.unity b/Dashing Game/Assets/Boss Levels/Blue Boss.unity index 6802462..8b62efb 100644 --- a/Dashing Game/Assets/Boss Levels/Blue Boss.unity +++ b/Dashing Game/Assets/Boss Levels/Blue Boss.unity @@ -566,7 +566,7 @@ ParticleSystemRenderer: m_ApplyActiveColorSpace: 1 m_AllowRoll: 1 m_VertexStreams: 00010304 - m_Mesh: {fileID: 0} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} m_Mesh1: {fileID: 0} m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} @@ -587,7 +587,7 @@ ParticleSystem: ringBufferLoopRange: {x: 0, y: 1} looping: 1 prewarm: 0 - playOnAwake: 1 + playOnAwake: 0 useUnscaledTime: 0 autoRandomSeed: 1 useRigidbodyForVelocity: 1 @@ -654,7 +654,7 @@ ParticleSystem: startLifetime: serializedVersion: 2 minMaxState: 0 - scalar: 5 + scalar: 2 minScalar: 5 maxCurve: serializedVersion: 2 @@ -707,7 +707,7 @@ ParticleSystem: startSpeed: serializedVersion: 2 minMaxState: 0 - scalar: 5 + scalar: 0.01 minScalar: 5 maxCurve: serializedVersion: 2 @@ -759,9 +759,9 @@ ParticleSystem: m_RotationOrder: 4 startColor: serializedVersion: 2 - minMaxState: 0 - minColor: {r: 1, g: 1, b: 1, a: 1} - maxColor: {r: 1, g: 1, b: 1, a: 1} + minMaxState: 2 + minColor: {r: 0, g: 0.06844139, b: 1, a: 1} + maxColor: {r: 0.5235849, g: 0.86361456, b: 1, a: 1} maxGradient: serializedVersion: 2 key0: {r: 1, g: 1, b: 1, a: 1} @@ -823,7 +823,7 @@ ParticleSystem: startSize: serializedVersion: 2 minMaxState: 0 - scalar: 1 + scalar: 0.43 minScalar: 1 maxCurve: serializedVersion: 2 @@ -981,7 +981,7 @@ ParticleSystem: m_RotationOrder: 4 startRotationX: serializedVersion: 2 - minMaxState: 0 + minMaxState: 3 scalar: 0 minScalar: 0 maxCurve: @@ -1034,7 +1034,7 @@ ParticleSystem: m_RotationOrder: 4 startRotationY: serializedVersion: 2 - minMaxState: 0 + minMaxState: 3 scalar: 0 minScalar: 0 maxCurve: @@ -1087,8 +1087,8 @@ ParticleSystem: m_RotationOrder: 4 startRotation: serializedVersion: 2 - minMaxState: 0 - scalar: 0 + minMaxState: 3 + scalar: 3.1415925 minScalar: 0 maxCurve: serializedVersion: 2 @@ -1198,12 +1198,12 @@ ParticleSystem: ShapeModule: serializedVersion: 6 enabled: 1 - type: 4 - angle: 25 + type: 17 + angle: 8.991145 length: 5 boxThickness: {x: 0, y: 0, z: 0} radiusThickness: 1 - donutRadius: 0.2 + donutRadius: 0.6153736 m_Position: {x: 0, y: 0, z: 0} m_Rotation: {x: 0, y: 0, z: 0} m_Scale: {x: 1, y: 1, z: 1} @@ -1285,7 +1285,7 @@ ParticleSystem: sphericalDirectionAmount: 0 randomPositionAmount: 0 radius: - value: 1 + value: 2.7374377 mode: 0 spread: 0 speed: @@ -1404,7 +1404,7 @@ ParticleSystem: rateOverTime: serializedVersion: 2 minMaxState: 0 - scalar: 10 + scalar: 70 minScalar: 10 maxCurve: serializedVersion: 2 @@ -1834,7 +1834,7 @@ ParticleSystem: m_RotationOrder: 4 separateAxes: 0 ColorModule: - enabled: 0 + enabled: 1 gradient: serializedVersion: 2 minMaxState: 1 @@ -1842,7 +1842,7 @@ ParticleSystem: maxColor: {r: 1, g: 1, b: 1, a: 1} maxGradient: serializedVersion: 2 - key0: {r: 1, g: 1, b: 1, a: 1} + key0: {r: 1, g: 1, b: 1, a: 0} key1: {r: 1, g: 1, b: 1, a: 1} key2: {r: 0, g: 0, b: 0, a: 0} key3: {r: 0, g: 0, b: 0, a: 0} @@ -1859,8 +1859,8 @@ ParticleSystem: ctime6: 0 ctime7: 0 atime0: 0 - atime1: 65535 - atime2: 0 + atime1: 32768 + atime2: 65535 atime3: 0 atime4: 0 atime5: 0 @@ -1868,7 +1868,7 @@ ParticleSystem: atime7: 0 m_Mode: 0 m_NumColorKeys: 2 - m_NumAlphaKeys: 2 + m_NumAlphaKeys: 3 minGradient: serializedVersion: 2 key0: {r: 1, g: 1, b: 1, a: 1} @@ -3161,11 +3161,11 @@ ParticleSystem: m_PostInfinity: 2 m_RotationOrder: 4 NoiseModule: - enabled: 0 + enabled: 1 strength: serializedVersion: 2 minMaxState: 0 - scalar: 1 + scalar: 0.1 minScalar: 1 maxCurve: serializedVersion: 2 @@ -3327,7 +3327,7 @@ ParticleSystem: octaves: 1 octaveMultiplier: 0.5 octaveScale: 2 - quality: 2 + quality: 1 scrollSpeed: serializedVersion: 2 minMaxState: 0 @@ -5694,10 +5694,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 30cf97ed3421b064ab3280c3e20eb6c4, type: 3} m_Name: m_EditorClassIdentifier: - AttackRange: 7 - ConsiderRange: 0 - MoveSpeed: 15 - AttackStrength: 10 + AttackRange: 10 + ConsiderRange: 20 + MoveSpeed: 10 + AttackTime: 6 + AttackStrength: 20 + DamageRange: 7 + AttackMoveSpeed: 40 minBlinkTime: 2 maxBlinkTime: 3 bounciness: 100 @@ -11865,5 +11868,15 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2302392148938058634, guid: 396043d1b8e2c874ba4c185bc4b2ae54, + type: 3} + propertyPath: m_Color.b + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2302392148938058634, guid: 396043d1b8e2c874ba4c185bc4b2ae54, + type: 3} + propertyPath: m_Color.g + value: 0.7461276 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 396043d1b8e2c874ba4c185bc4b2ae54, type: 3} diff --git a/Dashing Game/Assets/Scripts/Bosses/BlueBossController.cs b/Dashing Game/Assets/Scripts/Bosses/BlueBossController.cs index 7c22804..22086b2 100644 --- a/Dashing Game/Assets/Scripts/Bosses/BlueBossController.cs +++ b/Dashing Game/Assets/Scripts/Bosses/BlueBossController.cs @@ -5,12 +5,19 @@ public class BlueBossController : MonoBehaviour { [Header("Functional")] + [Tooltip("How close the player can get before the countdown begins to an attack")] [SerializeField] private float AttackRange; [SerializeField] private float ConsiderRange; [SerializeField] private float MoveSpeed; + [SerializeField] private float AttackTime; [Tooltip("How much damage the boss can deal to the player")] [SerializeField] private float AttackStrength; + [Tooltip("How close the player can get to the boss without being damaged while attacking")] + [SerializeField] private float DamageRange; + + [Tooltip("How fast the boss moves while attacking")] + [SerializeField] private float AttackMoveSpeed; [Header("Cosmetic")] [SerializeField] private float minBlinkTime; @@ -20,26 +27,45 @@ public class BlueBossController : MonoBehaviour private Animator anims; private Player player; private Rigidbody2D rb; + private ParticleSystem attackParticles; private float timeSinceLastBlink; private float nextBlinkTime; + private Vector2 smoothStopVel; //for smoothly stopping the boss from moving + + //variables used to control whether or not the boss attacks private bool isAttacking; private float attackBuildup; private float maxAttackBuildup; + private float attackTimeElapsed; + + //variables used while attacking + private Vector2 attackVector; + private float attackVel; + private float curAttackSpeed; + void Awake() { anims = GetComponent(); player = FindObjectOfType(); rb = GetComponent(); + attackParticles = GetComponentInChildren(); + attackParticles.Stop(); + timeSinceLastBlink = 0; nextBlinkTime = Random.Range(minBlinkTime, maxBlinkTime); + smoothStopVel = Vector2.zero; + isAttacking = false; attackBuildup = 0; - maxAttackBuildup = 0.7f; + maxAttackBuildup = 2f; + + attackTimeElapsed = 0; + attackVel = 0; } void Update() @@ -55,17 +81,67 @@ void Update() } //handle attacks - if() + if(distanceToPlayer() < AttackRange + 1f) + attackBuildup += Time.deltaTime; + else + attackBuildup = 0; + + if (attackBuildup > maxAttackBuildup && !isAttacking) + { + //start attack + isAttacking = true; + attackTimeElapsed = 0f; + + curAttackSpeed = 0; + attackVel = 0; + + attackVector = (player.transform.position - transform.position); + + attackParticles.Play(); + attackParticles.gameObject.transform.rotation.eulerAngles.Set(0, 0, 0); //reset particle rotation + } + + if(isAttacking) + { + //spin the particles to make a ring effect + attackParticles.gameObject.transform.Rotate(Vector3.forward * 5f); + + if (distanceToPlayer() < DamageRange) + { + player.Health -= AttackStrength * Time.deltaTime; + } + + attackTimeElapsed += Time.deltaTime; + if(attackTimeElapsed >= AttackTime) + { + //stop attack + isAttacking = false; + attackBuildup = 0; + + attackParticles.Stop(); + } + } + + anims.SetBool("Attacking", isAttacking); } void FixedUpdate() { //handle movements - if (!isAttacking && Vector2.Distance(player.gameObject.transform.position, transform.position) > AttackRange) + if (!isAttacking && distanceToPlayer() > AttackRange) { - Vector2 movement = (player.transform.position - transform.position).normalized * MoveSpeed; + Vector2 movement = (player.transform.position - transform.position).normalized * (distanceToPlayer() > ConsiderRange ? MoveSpeed/2f : MoveSpeed); rb.velocity = movement; } + else if(isAttacking) + { + curAttackSpeed = Mathf.SmoothDamp(curAttackSpeed, AttackMoveSpeed, ref attackVel, 2f); + rb.velocity = attackVector * curAttackSpeed; + } + else + { + rb.velocity = Vector2.SmoothDamp(rb.velocity, Vector2.zero, ref smoothStopVel, 0.8f); + } } private void OnCollisionEnter2D(Collision2D other) @@ -86,7 +162,19 @@ private void OnCollisionEnter2D(Collision2D other) else { //damage player + player.Health -= AttackStrength*1.5f; //do a little more damage to punish the player for thinking they can just touch the boss } } + else if(other.collider.CompareTag("Ground") && isAttacking) + { + //bounce off of wall + Vector2 direction = Vector2.Reflect(attackVector, other.contacts[0].normal); + attackVector = direction.normalized; + } + } + + private float distanceToPlayer() + { + return Vector2.Distance(player.gameObject.transform.position, transform.position); } }