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

66 lines
1.3 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-30 15:26:15 +08:00
public bool raccoonFound = false;
2023-03-26 13:27:42 +08:00
Transform transform;
Transform aiTransform;
2023-03-25 18:18:29 +08:00
2023-03-30 15:26:15 +08:00
[NonSerialized]
public PlayerController pc;
2023-03-26 13:27:42 +08:00
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-30 15:26:15 +08:00
if (!ai.atk)
raccoonFound = false;
2023-03-25 14:51:28 +08:00
2023-03-26 13:27:42 +08:00
}
2023-03-30 15:26:15 +08:00
2023-03-26 13:27:42 +08:00
}
protected override void onTriggerStay(CollisionInfo info)
{
2023-04-02 13:32:21 +08:00
if (info.GameObject.GetScript<PlayerController>())
{
2023-03-30 15:26:15 +08:00
pc = info.GameObject.GetScript<PlayerController>();
2023-04-02 13:32:21 +08:00
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
}