GATLING GUN
This commit is contained in:
parent
f2a3904b21
commit
e81f7808d7
6 changed files with 52 additions and 4 deletions
|
@ -16,6 +16,10 @@ public class Bullet : MonoBehaviour {
|
|||
|
||||
}
|
||||
|
||||
public void SetSpeed(float spd) {
|
||||
speed = spd;
|
||||
}
|
||||
|
||||
public void SetDamage(int dmg) {
|
||||
damage = dmg;
|
||||
}
|
||||
|
|
13
Assets/Scripts/Entities/Attack/GatlingGun.cs
Normal file
13
Assets/Scripts/Entities/Attack/GatlingGun.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace Assets.Scripts.Entities.Attack {
|
||||
class GatlingGun : SingleShot {
|
||||
public GatlingGun(GameObject owner) : base(owner) {
|
||||
damage = 5;
|
||||
cooldown = 0.1f;
|
||||
speed = 20;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Entities/Attack/GatlingGun.cs.meta
Normal file
11
Assets/Scripts/Entities/Attack/GatlingGun.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 947693703e16a8e4d9542d72d014e351
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -8,7 +8,7 @@ namespace Assets.Scripts.Entities.Attack {
|
|||
|
||||
int damage = 10;
|
||||
float cooldown = 1;
|
||||
float range = 2f;
|
||||
float range = 1f;
|
||||
GameObject owner;
|
||||
|
||||
public MeleeAttack(GameObject owner) {
|
||||
|
|
|
@ -5,9 +5,10 @@ using UnityEngine;
|
|||
namespace Assets.Scripts.Entities.Attack {
|
||||
class SingleShot : IAttack {
|
||||
|
||||
int damage = 12;
|
||||
float cooldown = 1;
|
||||
int range = 4;
|
||||
protected int damage = 12;
|
||||
protected float cooldown = 1;
|
||||
protected int range = 4;
|
||||
protected float speed = 10;
|
||||
GameObject owner;
|
||||
GameObject bulletPrefab;
|
||||
Transform spawn;
|
||||
|
@ -32,6 +33,7 @@ namespace Assets.Scripts.Entities.Attack {
|
|||
b.transform.position = spawn.position;
|
||||
Bullet bu = b.GetComponent<Bullet>();
|
||||
bu.SetDamage(damage);
|
||||
bu.SetSpeed(speed);
|
||||
bu.SetOwner(owner);
|
||||
GameController.instance.GetAudioControl().SfxPlay(0);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ public class Player : Mob {
|
|||
[SerializeField]
|
||||
private int carDamage = 5;
|
||||
|
||||
private SingleShot singleShot;
|
||||
private GatlingGun ggun;
|
||||
|
||||
private float nextAttackTime;
|
||||
|
||||
public Player() : base(100) { }
|
||||
|
@ -18,10 +21,25 @@ public class Player : Mob {
|
|||
SingleShot s = new SingleShot(this.gameObject);
|
||||
s.SetPrefab(bulletPrefab);
|
||||
s.SetSpawn(bulletSpawn);
|
||||
singleShot = s;
|
||||
GatlingGun g = new GatlingGun(this.gameObject);
|
||||
g.SetPrefab(bulletPrefab);
|
||||
g.SetSpawn(bulletSpawn);
|
||||
ggun = g;
|
||||
SetAttack(s);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if(Input.GetKeyDown(KeyCode.G)) {
|
||||
if(attack != ggun) {
|
||||
attack = ggun;
|
||||
Debug.Log("Switched to GatlingGun");
|
||||
} else {
|
||||
attack = singleShot;
|
||||
Debug.Log("Switched to SingleShot");
|
||||
}
|
||||
|
||||
}
|
||||
if ( Time.timeSinceLevelLoad >= nextAttackTime && attack != null) {
|
||||
if ( Input.GetAxis("Fire") > 0 ) {
|
||||
Debug.Log("Attack pressed!");
|
||||
|
|
Loading…
Add table
Reference in a new issue