Nextrek
Diff Revisions
131
vs
134
for /3DSpace/Assets/Custum/Scripts/AllyShip.cs
|
@@ -14,7 +14,6 @@ |
14 |
14 |
|
public CameraFollow followCamera; |
15 |
15 |
|
public float life = 100; |
16 |
16 |
|
private bool isAlive = true; |
17 |
|
- |
public int ID; |
18 |
17 |
|
|
19 |
18 |
|
private Rigidbody _cacheRigidbody; |
20 |
19 |
|
private float shootFreq = 1f; |
|
@@ -23,9 +22,22 @@ |
23 |
22 |
|
|
24 |
23 |
|
private GameObject currentEnemyTarget; |
25 |
24 |
|
|
|
25 |
+ |
private static float HERO_MIN_RANGE = 1000.0f; |
|
26 |
+ |
private static float HERO_MAX_RANGE = 2000.0f; |
|
27 |
+ |
|
|
28 |
+ |
float genCoord(float min_distance, float max_distance) { |
|
29 |
+ |
return (Random.value - Random.value) * (min_distance + Random.value * (max_distance-min_distance)); |
|
30 |
+ |
} |
26 |
31 |
|
|
27 |
32 |
|
void Start() |
28 |
33 |
|
{ |
|
34 |
+ |
this.transform.position = new Vector3( |
|
35 |
+ |
genCoord(HERO_MIN_RANGE, HERO_MAX_RANGE), |
|
36 |
+ |
genCoord(HERO_MIN_RANGE, HERO_MAX_RANGE), |
|
37 |
+ |
genCoord(HERO_MIN_RANGE, HERO_MAX_RANGE) |
|
38 |
+ |
); |
|
39 |
+ |
|
|
40 |
+ |
this.transform.rotation = Random.rotation; |
29 |
41 |
|
|
30 |
42 |
|
foreach (SU_Thruster _thruster in thrusters) |
31 |
43 |
|
{ |
|
@@ -85,7 +97,9 @@ |
85 |
97 |
|
|
86 |
98 |
|
transform.LookAt(enemyShip); |
87 |
99 |
|
|
88 |
|
- |
if(Vector3.Distance(transform.position,enemyShip.position)<300) |
|
100 |
+ |
Vector3 relative = enemyShip.position - transform.position; |
|
101 |
+ |
float distance = relative.magnitude; |
|
102 |
+ |
if(distance<300) |
89 |
103 |
|
{ |
90 |
104 |
|
StopThruster(); |
91 |
105 |
|
} |
|
@@ -93,7 +107,8 @@ |
93 |
107 |
|
{ |
94 |
108 |
|
StartThruster(); |
95 |
109 |
|
} |
96 |
|
- |
if(lastShootTime>shootFreq) |
|
110 |
+ |
|
|
111 |
+ |
if ((distance<2000) && (Vector3.Dot (relative, transform.forward)>0.5) && (lastShootTime>shootFreq)) |
97 |
112 |
|
{ |
98 |
113 |
|
lastShootTime=0; |
99 |
114 |
|
foreach (Vector3 _wmp in weaponMountPoints) |