blob: 8aea87b79dad30c90f50bc1b3910e9f7b3ef22a1 (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
using UnityEngine;
public class PlayerAIMinion : MonoBehaviour
{
public AnimationCurve m_AimCompensastionCurve;
public float range = 5f;
private PlayerAPI api;
private Vector2 moveDirection;
private void Start()
{
api = GetComponentInParent<PlayerAPI>();
moveDirection = api.data.master.data.aimDirection;
if (moveDirection.x > 0.5f)
{
moveDirection.x = 1f;
}
else if (moveDirection.x < -0.5f)
{
moveDirection.x = -1f;
}
else
{
moveDirection.x = 0f;
}
moveDirection.y = 0f;
base.transform.root.gameObject.AddComponent<RemoveAfterSeconds>().seconds = 4f;
}
private void Update()
{
Player otherPlayer = PlayerManager.instance.GetOtherPlayer(api.data.master);
api.Move(moveDirection);
if (api.data.isWallGrab)
{
api.Jump();
}
if (!api.data.isGrounded)
{
api.Jump();
}
if ((bool)otherPlayer)
{
api.SetAimDirection(GetAimDirForHitting(otherPlayer.transform.position));
if (PlayerManager.instance.CanSeePlayer(base.transform.position, otherPlayer).canSee && Vector2.Distance(base.transform.position, otherPlayer.transform.position) < range)
{
api.Attack();
}
}
}
private Vector2 GetAimDirForHitting(Vector3 point)
{
Vector3 vector = point - base.transform.position;
api.SetAimDirection(vector);
api.GetMyBullet();
float time = Mathf.Abs(point.x - base.transform.position.x);
return point + Vector3.up * m_AimCompensastionCurve.Evaluate(time) - base.transform.position;
}
}
|