SHADE_Y3/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAttackHitbox.cs

65 lines
1.4 KiB
C#
Raw Normal View History

2023-03-25 14:51:28 +08:00
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
2023-03-25 18:18:29 +08:00
using System.Threading;
2023-03-25 14:51:28 +08:00
using System.Threading.Tasks;
2023-03-25 17:20:35 +08:00
using static PlayerController;
2023-03-25 14:51:28 +08:00
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{
2023-03-25 17:20:35 +08:00
public class HomeOwnerAttackHitbox : Script
{
public GameObject aiGO;
2023-03-25 18:18:29 +08:00
2023-03-26 13:27:42 +08:00
private bool raccoonFound = false;
Transform transform;
Transform aiTransform;
2023-03-25 18:18:29 +08:00
2023-03-26 13:27:42 +08:00
private PlayerController pc;
private HomeOwnerAI ai;
2023-03-25 18:18:29 +08:00
protected override void start()
2023-03-25 14:51:28 +08:00
{
2023-03-26 13:27:42 +08:00
transform = GetComponent<Transform>();
aiTransform = aiGO.GetComponent<Transform>();
ai = aiGO.GetScript<HomeOwnerAI>();
2023-03-25 18:18:29 +08:00
}
2023-03-25 16:52:26 +08:00
2023-03-25 18:18:29 +08:00
protected override void update()
{
if (transform && aiTransform)
2023-03-25 17:20:35 +08:00
{
2023-03-25 18:18:29 +08:00
transform.GlobalPosition = aiTransform.GlobalPosition + aiTransform.Forward * 0.7f;
2023-03-25 17:20:35 +08:00
transform.GlobalEulerAngles = aiTransform.GlobalEulerAngles;
2023-03-25 16:52:26 +08:00
2023-03-26 13:27:42 +08:00
}
2023-03-25 16:52:26 +08:00
2023-03-26 13:27:42 +08:00
if (raccoonFound && pc && ai)
2023-03-25 17:20:35 +08:00
{
2023-03-25 18:47:42 +08:00
pc.currentState = RaccoonStates.CAUGHT;
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
2023-03-26 13:27:42 +08:00
pc.stateMachine.SetState(typeof(PlayerCaughtState));
2023-03-25 14:51:28 +08:00
2023-03-25 18:47:42 +08:00
pc.GotCaught();
2023-03-26 13:27:42 +08:00
ai.Reset();
raccoonFound = false;
}
}
protected override void onTriggerStay(CollisionInfo info)
{
pc = info.GameObject.GetScript<PlayerController>();
if (ai && ai.atk && pc)
{
raccoonFound = true;
2023-03-25 17:20:35 +08:00
}
2023-03-25 14:51:28 +08:00
}
2023-03-25 17:20:35 +08:00
}
2023-03-25 14:51:28 +08:00
}