//捡到弹药包后 private void PickupBullet() { if (gunType != GunEnum.normal) { //先清空当前武器的子弹数量 bullet_number[gunType.GetHashCode()] = 0; } int weaponType = Random.Range(1, 5); gunType = bulletPool_Ins.RandomChange(weaponType); bullet_number[weaponType] = 10; //显示UI gunnameText.text = bulletPool_Ins.InitGunName(gunType) + " " + bullet_number[gunType.GetHashCode()]; }
//减少子弹数量 void DecreasBullet(GunEnum gunType) { bullet_number[gunType.GetHashCode()] -= 1; Debug.Log(bullet_number[gunType.GetHashCode()]); //如果当前武器子弹用完了 if (bullet_number[gunType.GetHashCode()] == 0) { Debug.Log("子弹没了,进来"); this.gunType = GunEnum.normal; gunnameText.text = bulletPool_Ins.InitGunName(this.gunType); } else { gunnameText.text = bulletPool_Ins.InitGunName(gunType) + " " + bullet_number[gunType.GetHashCode()]; } }