diff --git a/Assets/Scenes/Level2.shade b/Assets/Scenes/Level2.shade index 7a131e4b..8246c9aa 100644 --- a/Assets/Scenes/Level2.shade +++ b/Assets/Scenes/Level2.shade @@ -6091,6 +6091,7 @@ - Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAI Enabled: true idleDuration: 1 + caughtDuration: 2 timeoutDuration: 2 patrolPointParent: 166 patrolSpeed: 1 @@ -17471,4 +17472,5 @@ Scripts: - Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAttackHitbox Enabled: true - aiGO: 158 \ No newline at end of file + aiGO: 158 + raccoonFound: false \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs index c86342a0..095ef1a3 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs @@ -10,6 +10,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework public class HomeOwnerAI : Script { public float idleDuration = 1.0f; + public float caughtDuration = 2.0f; public float timeoutDuration = 2.0f; public GameObject patrolPointParent; @@ -41,6 +42,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework private Transform transform; + [NonSerialized] + public HomeOwnerAttackHitbox hitboxScript; + public void Reset() { StateMachine machine = GetScript(); @@ -65,6 +69,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework dictionary.Add(typeof(ChaseState), new ChaseState(machine)); dictionary.Add(typeof(AlertState), new AlertState(machine)); dictionary.Add(typeof(AttackState), new AttackState(machine)); + dictionary.Add(typeof(CaughtRaccoonState), new CaughtRaccoonState(machine)); machine.InitStateMachine(dictionary); } @@ -84,6 +89,11 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework //attackHitbox.SetActive(false); if (pppList != null) startPos = pppList[0].LocalPosition; + + if (attackHitbox) + hitboxScript = attackHitbox.GetScript(); + + } diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAttackHitbox.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAttackHitbox.cs index 30d99e57..6f392962 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAttackHitbox.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAttackHitbox.cs @@ -13,11 +13,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework { public GameObject aiGO; - private bool raccoonFound = false; + public bool raccoonFound = false; Transform transform; Transform aiTransform; - private PlayerController pc; + [NonSerialized] + public PlayerController pc; private HomeOwnerAI ai; protected override void start() @@ -39,20 +40,18 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework if (raccoonFound && pc && ai) { - pc.currentState = RaccoonStates.CAUGHT; - if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState))) - pc.stateMachine.SetState(typeof(PlayerCaughtState)); + if (!ai.atk) + raccoonFound = false; - pc.GotCaught(); - ai.Reset(); - raccoonFound = false; } + } protected override void onTriggerStay(CollisionInfo info) { - pc = info.GameObject.GetScript(); + if(info.GameObject.GetScript()) + pc = info.GameObject.GetScript(); if (ai && ai.atk && pc) { raccoonFound = true; diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/RotateToVelocity.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/RotateToVelocity.cs index 7791aa77..03ee9ba2 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/RotateToVelocity.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/RotateToVelocity.cs @@ -37,23 +37,23 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework { lookOffset = 0.0f; } - else - { - if(left ) - { - if (lookOffset > -lookAroundAngle) - lookOffset -= rotationPerSecond * Time.DeltaTimeF; - else - left = false; - } - if (!left) - { - if (lookOffset < lookAroundAngle) - lookOffset += rotationPerSecond * Time.DeltaTimeF; - else - left = false; - } - } + //else + //{ + // if(left ) + // { + // if (lookOffset > -lookAroundAngle) + // lookOffset -= rotationPerSecond * Time.DeltaTimeF; + // else + // left = false; + // } + // if (!left) + // { + // if (lookOffset < lookAroundAngle) + // lookOffset += rotationPerSecond * Time.DeltaTimeF; + // else + // left = false; + // } + //} @@ -75,7 +75,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework if(vel.GetMagnitude() > 0.01f) { Quaternion currentRotation = transform.LocalRotation; - Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(vel.x, vel.z) + lookOffset, 0.0f); + Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(vel.x, vel.z) + lookOffset, 0.0f); transform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationPerSecond * (float)Time.DeltaTimeF); } } diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/AttackState.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/AttackState.cs index b444c2fb..b57ad2a6 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/AttackState.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/AttackState.cs @@ -26,7 +26,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States public AttackState(StateMachine machine) : base(machine) { - + stateName = "Attack"; } @@ -68,7 +68,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States public override void OnExit() { - animator.Stop(); + RotateToVelocity rotate = ai.GetScript(); if (rotate) { @@ -84,6 +84,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States public override void update() { + if (ai.hitboxScript.raccoonFound) + { + machine.SetState(typeof(CaughtRaccoonState)); + } + + timer -= Time.DeltaTimeF; if (windUp) { @@ -141,9 +147,13 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States machine.SetState(typeof(TimeoutState)); } } + + } + + } public override void fixedUpdate() diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs new file mode 100644 index 00000000..0381b0bd --- /dev/null +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SHADE; +using static PlayerController; + +namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States +{ + public class CaughtRaccoonState: AIBaseState + { + + private float timer = 0.0f; + private PlayerController pc; + + public CaughtRaccoonState(StateMachine machine):base(machine) + { + stateName = "Caught Raccoon"; + } + + public override void OnEnter() + { + if(ai.hitboxScript) + pc = ai.hitboxScript.pc; + + timer = ai.caughtDuration; + } + + + public override void OnExit() + { + animator.Stop(); + } + + public override void update() + { + timer -= Time.DeltaTimeF; + if(timer <= 0.0f) + { + if (pc) + { + pc.currentState = RaccoonStates.CAUGHT; + if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState))) + pc.stateMachine.SetState(typeof(PlayerCaughtState)); + + pc.GotCaught(); + } + ai.Reset(); + } + + + } + + public override void fixedUpdate() + { + + } + + + } +} diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs.shmeta b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs.shmeta new file mode 100644 index 00000000..619e1c4b --- /dev/null +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/CaughtRaccoonState.cs.shmeta @@ -0,0 +1,3 @@ +Name: CaughtRaccoonState +ID: 153010954 +Type: 9 diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/ChaseState.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/ChaseState.cs index fdd3fdc1..c2a32c81 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/ChaseState.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/ChaseState.cs @@ -14,7 +14,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States float giveUpDuration = 10.0f; float giveUpTimer = 0.0f; - float atkDistance = 2.0f; + float atkDistance = 1.0f; bool run = true; diff --git a/Assets/Shaders/UI_Slider_FS.glsl b/Assets/Shaders/UI_Slider_FS.glsl index b39f18dd..f08f974f 100644 --- a/Assets/Shaders/UI_Slider_FS.glsl +++ b/Assets/Shaders/UI_Slider_FS.glsl @@ -8,6 +8,7 @@ struct MatPropData int textureIndex; float alpha; float sliderThreshold; + float borderThickness; vec4 sliderStartColor; vec4 sliderEndColor; vec4 sliderBarColor; @@ -43,6 +44,8 @@ void main() { //fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold) fragColor = MatProp.data[In2.materialIndex].sliderBarColor; else diff --git a/Assets/Shaders/UI_Slider_FS.shshaderb b/Assets/Shaders/UI_Slider_FS.shshaderb index 0dcfb62d..09feea58 100644 Binary files a/Assets/Shaders/UI_Slider_FS.shshaderb and b/Assets/Shaders/UI_Slider_FS.shshaderb differ