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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 枪
/// </summary>
public class Equip_Gun : EquipBase
{
public override string name => "枪";
public override string iconPath => "art/ui/equipicon/gun";
public override AutoMode autoMode => AutoMode.Interval;
public override float interval => 0.1f;
private string prefabPath = "prefabs/bullet/bullet";
private int index = 0;
TestPeaceMakerBullet CreateBullet(CrewScript crew, Vector2 dir, float speed, float lifeTime)
{
TestPeaceMakerBullet bullet = UnityEngine.Object.Instantiate<TestPeaceMakerBullet>(ResourceManager.Instance.Load< TestPeaceMakerBullet>(prefabPath));
bullet.transform.position = crew.arrow.position + new Vector3(crew.aimDirection.x, crew.aimDirection.y, 0) * -0.3f;
bullet.Set(dir, speed, lifeTime);
bullet.gameObject.SetActive(true);
return bullet;
}
public override void OnTrigger(GameObject owner)
{
CrewScript crew = owner.GetComponent<CrewScript>();
index++;
index = index % 3;
if(index == 0)
{
CreateBullet(crew, TestMathHelper.Rotate(crew.aimDirection, -10 * Mathf.Deg2Rad), 12f, 2f);
}
else if(index == 1)
{
CreateBullet(crew, crew.aimDirection, 12f, 2f);
}
else if(index == 2)
{
CreateBullet(crew, TestMathHelper.Rotate(crew.aimDirection, 10 * Mathf.Deg2Rad), 12f, 2f);
}
}
}
|