blob: 3d39423efe078faa3d33008a330dfec74fc27826 (
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
|
using System.Collections;
using UnityEngine;
public class GeneralShooter : MonoBehaviour
{
private Gun gun;
[HideInInspector]
public float charge;
public Transform[] shooters;
private void Start()
{
gun = GetComponent<Gun>();
}
public void Attack()
{
if (base.enabled)
{
StartCoroutine(DoAttack());
}
}
private IEnumerator DoAttack()
{
int shotsToMake = Mathf.Clamp(Mathf.RoundToInt(0.5f / gun.attackSpeed), 1, 5);
for (int i = 0; i < shotsToMake; i++)
{
for (int j = 0; j < shooters.Length; j++)
{
gun.transform.position = shooters[j].position;
gun.transform.rotation = shooters[j].rotation;
gun.Attack(gun.currentCharge, forceAttack: true);
}
if (shotsToMake > i)
{
yield return new WaitForSeconds(0.1f);
}
}
}
}
|