-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAutoaim.cs
62 lines (55 loc) · 1.6 KB
/
Autoaim.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace TowerDefenseGame
{
public class Autoaim
{
const float PHYSICS_CONST = .02f;
public Vector3 targetPosition1_ = new Vector3(0f, 0f, 0f);
public Vector3 targetPosition2_ = new Vector3(2f, 0f, 0f);
public Vector3 turretPosition_;
public float bulletVelocity_;
public float bulletForce_;
public bool initialized_;
public Autoaim()
{
initialized_ = true;
bulletVelocity_ = 0;
bulletForce_ = 0;
turretPosition_ = new Vector3(0, 0, 0);
}
public void SetPositions(Vector3 position1, Vector3 position2)
{
targetPosition1_ = position1;
targetPosition2_ = position2;
}
public void SetTurretPosition(Vector3 position)
{
turretPosition_ = position;
}
public void SetBulletForce(float force)
{
bulletForce_ = force;
}
public Vector3 CalculateTargetVelocity()
{
Vector3 Velocity;
Velocity = targetPosition2_ - targetPosition1_;
return Velocity;
}
public void CalculateBulletVelocity()
{
bulletVelocity_ = bulletForce_ * PHYSICS_CONST;
}
public float CalculateDistance()
{
float distance = 0f;
distance = Vector3.Distance(targetPosition1_, turretPosition_);
return distance;
}
}
}