ai fix along wit new music

This commit is contained in:
Glence 2023-03-26 13:27:42 +08:00
parent 44bbdf5f82
commit 2da73f12d0
10 changed files with 361 additions and 337 deletions

Binary file not shown.

View File

@ -9354,7 +9354,7 @@
- Is Trigger: true
Collision Tag: 5
Type: Box
Half Extents: {x: 0.600000024, y: 1.79999995, z: 1.5}
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
Friction: 0.400000006
Bounciness: 0
Density: 1

View File

@ -17145,7 +17145,7 @@
- Is Trigger: true
Collision Tag: 5
Type: Box
Half Extents: {x: 0.600000024, y: 1.79999995, z: 1.5}
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
Friction: 0.400000006
Bounciness: 0
Density: 1

View File

@ -6,7 +6,7 @@
Components:
Transform Component:
Translate: {x: -4.64838362, y: 2.94342947, z: 0.209690213}
Rotate: {x: 0.5, y: 0.5, z: 6.5}
Rotate: {x: -1.48352981, y: 0.5, z: 6.5}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Light Component:
@ -8951,7 +8951,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.806008875, y: 0, z: 1.30613756}
Translate: {x: 4.1322155, y: 0, z: 1.85982013}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -8962,7 +8962,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.513795853, y: 0, z: 5.17213631}
Translate: {x: 3.66769528, y: 0, z: 5.17213631}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -8973,7 +8973,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.497500449, y: 0, z: 7.26010561}
Translate: {x: 5.12931681, y: 0, z: 7.53852272}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -8984,7 +8984,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.380023897, y: 0, z: 9.58513737}
Translate: {x: 5.37614918, y: 0, z: 9.58513737}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -8995,7 +8995,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 4.76827145, y: 0, z: 9.12785816}
Translate: {x: -0.473824114, y: 0, z: 9.12785816}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -9006,7 +9006,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 5.0583787, y: 0, z: 4.71819115}
Translate: {x: -0.366229892, y: 0, z: 4.99889755}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -9017,7 +9017,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.53010821, y: 0, z: 4.63929033}
Translate: {x: 0.666945934, y: 0, z: 4.45493603}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -9028,7 +9028,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.64600039, y: 0, z: 2.86434269}
Translate: {x: 0.605797768, y: 0, z: 2.86434269}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -9039,7 +9039,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.50184393, y: 0, z: 0.390250444}
Translate: {x: 0.566371024, y: 0, z: 1.71020806}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -15112,7 +15112,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.667429447, y: 0, z: 1.10868871}
Translate: {x: 3.96016145, y: 0, z: 1.54417288}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -15217,7 +15217,7 @@
- Is Trigger: true
Collision Tag: 5
Type: Box
Half Extents: {x: 0.800000012, y: 1.79999995, z: 1.5}
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
Friction: 0.400000006
Bounciness: 0
Density: 1

View File

@ -6,7 +6,7 @@ using SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{
public class HomeOwnerAI:Script
public class HomeOwnerAI : Script
{
public float idleDuration = 1.0f;
public float timeoutDuration = 2.0f;
@ -31,6 +31,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
public AnimationClipAsset atkSeqAnim;
private Vector3 startPos;
public bool atk { get; set; }
[NonSerialized]
public IEnumerable<Transform> patrolPointPool;
@ -51,7 +52,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
protected override void awake()
{
StateMachine machine = GetScript<StateMachine>();
if(machine)
if (machine)
{
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(IdleState), new IdleState(machine));
@ -73,17 +74,19 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
startPos = transform.GlobalPosition;
}
atk = false;
}
protected override void start()
{
attackHitbox.SetActive(false);
//attackHitbox.SetActive(false);
}
protected override void update()
{
if(alertCooldown > 0.0f)
if (alertCooldown > 0.0f)
{
alertCooldown -= Time.DeltaTimeF;
}
@ -128,14 +131,14 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{
StateMachine machine = GetScript<StateMachine>();
AILineOfSight los = GetScript<AILineOfSight>();
if(machine && los)
if (machine && los)
{
if (Input.GetKeyDown(Input.KeyCode.K))
{
los.range = 5.0f;
machine.SetState(typeof(AlertState));
}
if(Input.GetKeyDown(Input.KeyCode.L))
if (Input.GetKeyDown(Input.KeyCode.L))
{
los.range = 0.0f;
machine.SetState(typeof(IdleState));

View File

@ -13,14 +13,18 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{
public GameObject aiGO;
private bool raccoonFound = false;
Transform transform;
Transform aiTransform;
private PlayerController pc;
private HomeOwnerAI ai;
protected override void start()
{
transform = GetComponent<Transform>();
aiTransform = aiGO.GetComponent<Transform>();
ai = aiGO.GetScript<HomeOwnerAI>();
}
protected override void update()
@ -32,27 +36,26 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
transform.GlobalEulerAngles = aiTransform.GlobalEulerAngles;
}
}
protected override void onTriggerStay(CollisionInfo info)
{
PlayerController pc = info.GameObject.GetScript<PlayerController>();
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
if (pc)
if (raccoonFound && pc && ai)
{
pc.currentState = RaccoonStates.CAUGHT;
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
pc.stateMachine.SetState(typeof(PlayerCaughtState));
pc.GotCaught();
if (ai)
{
ai.Reset();
GameObject.SetActive(false);
raccoonFound = false;
}
}
protected override void onTriggerStay(CollisionInfo info)
{
pc = info.GameObject.GetScript<PlayerController>();
if (ai && ai.atk && pc)
{
raccoonFound = true;
}
}

View File

@ -4,29 +4,32 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE_Scripting.Audio;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
public class AlertState: AIBaseState
public class AlertState : AIBaseState
{
const float alertDuration = 16.0f/30.0f + 1.0f;
const float alertDuration = 16.0f / 30.0f + 1.0f;
float alertTimer = alertDuration;
public AlertState(StateMachine machine): base(machine)
public AlertState(StateMachine machine) : base(machine)
{
stateName = "Alert";
AudioHandler.audioClipHandlers["raccoondetected"] = SHADE.Audio.CreateAudioClip("event:/Raccoon/raccoon_detected");
}
public override void OnEnter()
{
alertTimer = alertDuration;
if(animator)
if (animator)
{
animator.PlayOneShot(ai.alertAnim);
}
SHADE.Audio.SetParameterWithLabel("PlayerDetection", "Detected");
AudioHandler.audioClipHandlers["raccoondetected"].Play();
}
public override void OnExit()
{

View File

@ -7,14 +7,14 @@ using System.Threading.Tasks;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
public class AttackState: AIBaseState
public class AttackState : AIBaseState
{
float timer = 0.0f;
float windupTime = 8.0f / 30.0f;
float holdTime = 0.3f;
float seqTime = 8.0f / 30.0f ;
float seqTime = 8.0f / 30.0f;
float endTime = 0.5f;
@ -23,7 +23,8 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
bool seq = false;
bool end = false;
public AttackState(StateMachine machine): base(machine)
public AttackState(StateMachine machine) : base(machine)
{
}
@ -44,7 +45,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
rotate.active = false;
RigidBody rigid = machine.GetComponent<RigidBody>();
if(rigid)
if (rigid)
{
rigid.LinearVelocity = Vector3.Zero;
}
@ -61,7 +62,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
}
ai.attackHitbox.SetActive(false);
//ai.attackHitbox.SetActive(false);
}
@ -76,27 +77,29 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
}
ai.attackHitbox.SetActive(false);
//ai.attackHitbox.SetActive(false);
machine.GetScript<HomeOwnerAI>().atk = false;
}
public override void update()
{
timer -= Time.DeltaTimeF;
if(windUp)
if (windUp)
{
if(timer <= 0.0f)
if (timer <= 0.0f)
{
windUp = false;
hold = true;
animator.Play(ai.atkHoldAnim);
timer = holdTime;
ai.attackHitbox.SetActive(true);
//ai.attackHitbox.SetActive(true);
//machine.GetScript<HomeOwnerAI>().atk = true;
}
}
else if(hold)
else if (hold)
{
if(timer <= 0.0f)
if (timer <= 0.0f)
{
hold = false;
seq = true;
@ -104,15 +107,16 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
timer = seqTime;
}
}
else if(seq)
else if (seq)
{
if(timer <= 1.0f / 30.0f)
if (timer <= 1.0f / 30.0f)
{
ai.attackHitbox.SetActive(true);
//ai.attackHitbox.SetActive(true);
machine.GetScript<HomeOwnerAI>().atk = true;
}
if(timer <= 0.0f)
if (timer <= 0.0f)
{
seq = false;
end = true;
@ -122,9 +126,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
}
}
else if(end)
else if (end)
{
if(timer <= 0.0f)
if (timer <= 0.0f)
{
end = false;
AILineOfSight los = ai.GetScript<AILineOfSight>();

View File

@ -1,5 +1,6 @@
using SHADE;
using SHADE_Scripting.Audio;
using SHADE_Scripting.Gameplay.AIBehaviour.AIRework;
using System;
public class Item : Script
{
@ -155,7 +156,7 @@ public class Item : Script
emitter.Emit();
}
if (info.GameObject.GetScript<Homeowner1>() && homeownerOnce)
if (info.GameObject.GetScript<HomeOwnerAI>() && homeownerOnce)
{
homeownerOnce = false;
returnBack = true;

View File

@ -51,6 +51,8 @@ public class GameManager : Script
private bool goingToWin;
private bool goingToLose;
private bool playSpeedUp = false;
protected override void awake()
{
if (Instance != null && Instance != this)
@ -91,6 +93,7 @@ public class GameManager : Script
AudioHandler.audioClipHandlers["SFXItemScore"] = Audio.CreateAudioClip("event:/Music/stingers/item_scored");
AudioHandler.audioClipHandlers["RaccoonScored"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_scored");
Audio.SetParameterWithLabel("PlaybackSpeed", "Normal");
}
protected override void start()
@ -123,6 +126,13 @@ public class GameManager : Script
if (currGameState == GameState.START)
{
timer -= Time.DeltaTimeF;
if (timer < 30.0f && !playSpeedUp)
{
Audio.SetParameterWithLabel("PlaybackSpeed", "ToTransition");
playSpeedUp = true;
}
if(scoreText)
scoreText.GetComponent<TextRenderable>().Text = $"{Score}";
if(timeText)