-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntercept.cs
45 lines (39 loc) · 1.31 KB
/
Intercept.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Intercept : Follow
{
public Intercept(Entity381 ent, Entity381 target): base(ent, target, Vector3.zero)
{
//Follow does all the work
}
public override void Init()
{
//Debug.Log("Intercept:\t ing: " + targetEntity.gameObject.name);
line = LineMgr.inst.CreateInterceptLine(entity.position, targetEntity.position, targetEntity.position);
line.gameObject.SetActive(false);
}
public override void Tick()
{
//movePosition = targetEntity.transform.position;
float dh = ComputePredictiveDH(Vector3.zero);
entity.desiredHeading = dh;
entity.desiredSpeed = entity.maxSpeed;
}
public override bool IsDone()
{
return diff.sqrMagnitude < doneDistanceSq;
}
public override void Stop()
{
base.Stop();
entity.desiredSpeed = 0;
targetEntity.desiredSpeed = 0;
targetEntity.GetComponentInParent<UnitAI>().StopAndRemoveAllCommands();
Vector3 deadRot = targetEntity.transform.localEulerAngles;
deadRot.x = 90;
targetEntity.transform.localEulerAngles = deadRot;
LineMgr.inst.DestroyLR(line);
}
}