1
using System
.Collections
;
2 using System
.Collections
.Generic
;
5 public class CanRotatorFire
: MonoBehaviour
{
7 public GameObject bullet
;
8 public GameObject grenade
;
10 public Transform shotSpawn
;
12 public float rotationSpeed
;
13 private float nextFire
;
14 public float nextFireDelay
;
15 private float nextGrenade
;
16 public float nextGrenadeDelay
;
17 public float grenadeLaunchPower
;
19 public bool noAimSequence
;
20 public bool grenadeSequence
;
21 private bool rotateUp
;
22 public bool isRightCan
;
25 // Use this for initialization
27 noAimSequence
= false;
28 grenadeSequence
= false;
35 nextGrenadeDelay
= 5f
;
36 grenadeLaunchPower
= 4f
;
39 // Update is called once per frame
42 if (noAimSequence
== true) {
46 if (grenadeSequence
== true) {
54 Instantiate (bullet
, shotSpawn
.position
, shotSpawn
.rotation
);
59 clone
= Instantiate (grenade
, shotSpawn
.position
, shotSpawn
.rotation
);
61 clone
.GetComponent
<Rigidbody2D
>().velocity
= transform
.TransformDirection (new Vector2(1,1) * grenadeLaunchPower
);
63 clone
.GetComponent
<Rigidbody2D
>().velocity
= transform
.TransformDirection (new Vector2(-1,1) * grenadeLaunchPower
);
65 clone
.GetComponent
<Rigidbody2D
>().velocity
= transform
.TransformDirection (new Vector2(-1,1) * grenadeLaunchPower
);
69 if (Time
.time
> nextFire
) {
71 nextFire
= Time
.time
+ nextFireDelay
;
73 if (transform
.rotation
.z
<= -0.3230917f
) {
76 if (transform
.rotation
.z
>= 0.2873605f
) {
80 transform
.Rotate (0, 0, -Time
.deltaTime
* rotationSpeed
);
82 transform
.Rotate (0, 0, Time
.deltaTime
* rotationSpeed
);
86 void GrenadeSequence(){
87 if (Time
.time
> nextGrenade
) {
89 nextGrenade
= Time
.time
+ nextGrenadeDelay
;