/
BulletManage.cs
48 lines (44 loc) · 1.21 KB
/
BulletManage.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletManage : MonoBehaviour {
public static BulletManage _bulletmage;
LinkedList<BulletMove> lifepool = new LinkedList<BulletMove>();
LinkedList<BulletMove> diepool = new LinkedList<BulletMove>();
// Use this for initialization
void Awake()
{
_bulletmage = this;
}
// Update is called once per frame
void Update () {
}
//添加子弹
public void addbullet(BulletMove bullet)
{
lifepool.AddLast(bullet);
}
//在死亡池中查找
public BulletMove takebullet(BulletType Type)
{
var temp = diepool.First;
for (int i = 0; i < diepool.Count;++i )
{
if(temp.Value.type==Type)
{
lifepool.AddLast(temp.Value);
diepool.Remove(temp.Value);
return temp.Value;
}
temp = temp.Next;
}
return null;
}
//回收子弹
public void collection(BulletMove bullet)
{
lifepool.Remove(bullet);
diepool.AddLast(bullet);
bullet.gameObject.SetActive(false);
}
}