目录
1.Weapon基类
using UnityEngine;
using System.Collections;
public class Weapon : MonoBehaviour {
public int atk;//攻击力
public float shootRate;//射击频率
public float timer;//计时器
public bool canShoot;//表示当前是否可以射击
public int bulletCount;//子弹数量
public int bulletMaxCount;//表示子弹的最大数量
void Update()
{
if (!canShoot)
{
timer += Time.deltaTime;
if (timer > 1 / shootRate)
{
canShoot = true;
timer = 0;
}
}
}
public void Fire()
{
if (canShoot)
{
Shoot();
canShoot = false;
}
}
public virtual void Shoot ()
{
print("weapon shoot");
}
}