| @@ -1,4 +1,4 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| namespace Gameplay | ||
| @@ -32,4 +32,4 @@ void OnTriggerExit(Collider other) | ||
| zEvents.ZoneExited(actor.Type, actor.gameObject); | ||
| } | ||
| } | ||
| } | ||
| @@ -0,0 +1,30 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| namespace Combat | ||
| { | ||
| public enum Powers | ||
| { | ||
| Aggro, | ||
| BattleCry, | ||
| BoobyTrap, | ||
| Bow, | ||
| DelayedGrenadeLauncher, | ||
| DodgeRoll, | ||
| EagleEyes, | ||
| Flamethrower, | ||
| ForgethePath, | ||
| GhillieSuit, | ||
| GiveOrders, | ||
| Inspire, | ||
| Katana, | ||
| LayMines, | ||
| Ninjitsu, | ||
| RCDrone, | ||
| RocketLauncher, | ||
| SleepDart, | ||
| SniperShot, | ||
| TakeCover, | ||
| ThrowGrenade | ||
| } | ||
| } |
| @@ -0,0 +1,11 @@ | ||
| namespace Combat | ||
| { | ||
| public enum DamageTypes | ||
| { | ||
| Normal, | ||
| SoftTargetOnly, | ||
| HardTargetOnly, | ||
| AntiPersonel, | ||
| AntiArmor | ||
| } | ||
| } |
| @@ -0,0 +1,93 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| namespace Combat | ||
| { | ||
| public class Projectile : MonoBehaviour | ||
| { | ||
| private Vector3 ProjOrigin; | ||
| public DamageTypes DamType; | ||
| [Range(0,100)] public float Speed; | ||
| public float ProjectileRange; | ||
| public int Damage; | ||
|
|
||
| private float CreationTime { get; set; } | ||
| private float TimeSinceCreation { get { return Time.time - CreationTime; } set { } } | ||
|
|
||
| void Awake() | ||
| { | ||
| CreationTime = Time.time; | ||
| } | ||
|
|
||
| void Start() | ||
| { | ||
| ProjOrigin = gameObject.transform.position; | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
| UpdatePosition(); | ||
| } | ||
|
|
||
| void LateUpdate() | ||
| { | ||
| if (MaxDistanceReached()) MarkForDeletion(this); | ||
| } | ||
|
|
||
| internal static Projectile InitProj(Projectile p, Transform locAndDir, ProjectileTypes projType, float speed, int damage, float projRange) | ||
| { | ||
| if ((locAndDir == null) || (projType == null) || speed <= 0) return null; | ||
| p.ProjOrigin = p.transform.position; p.DamType = GetDamageType(projType); | ||
| p.Speed = speed; p.Damage = damage; p.ProjectileRange = projRange; | ||
| return p; | ||
| } | ||
|
|
||
| internal static void MarkForDeletion(Projectile proj) | ||
| { | ||
| Destroy(proj.gameObject); | ||
| } | ||
|
|
||
| internal static GameObject InstantiateProjectile(ProjectileTypes type, Transform locAndDir) | ||
| { | ||
| GameObject p = Instantiate(Resources.Load<GameObject>("Prefabs/Bullet")); | ||
| p.transform.position = locAndDir.position; | ||
| p.transform.forward = locAndDir.forward; | ||
| return p; | ||
| } | ||
|
|
||
| private bool MaxDistanceReached() | ||
| { | ||
| return Vector3.Distance(this.gameObject.transform.position, ProjOrigin) > ProjectileRange; | ||
| } | ||
|
|
||
| private static DamageTypes GetDamageType(ProjectileTypes projType) | ||
| { | ||
| switch (projType) | ||
| { | ||
| case ProjectileTypes.Bullet: | ||
| return DamageTypes.Normal; | ||
| case ProjectileTypes.BulletArmPierce: | ||
| return DamageTypes.AntiArmor; | ||
| case ProjectileTypes.BulletHollowPoint: | ||
| return DamageTypes.AntiPersonel; | ||
| case ProjectileTypes.Shuriken: | ||
| return DamageTypes.SoftTargetOnly; | ||
| case ProjectileTypes.Fireball: | ||
| return DamageTypes.SoftTargetOnly; | ||
| case ProjectileTypes.Rocket: | ||
| return DamageTypes.AntiArmor; | ||
| case ProjectileTypes.Grenade: | ||
| return DamageTypes.AntiArmor; | ||
| case ProjectileTypes.Arrow: | ||
| return DamageTypes.SoftTargetOnly; | ||
| default: | ||
| return DamageTypes.Normal; | ||
| } | ||
| } | ||
|
|
||
| private void UpdatePosition() | ||
| { | ||
| this.transform.position = ProjOrigin + transform.forward * Speed * TimeSinceCreation; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,14 @@ | ||
| namespace Combat | ||
| { | ||
| public enum ProjectileTypes | ||
| { | ||
| Bullet, | ||
| BulletArmPierce, | ||
| BulletHollowPoint, | ||
| Shuriken, | ||
| Fireball, | ||
| Rocket, | ||
| Grenade, | ||
| Arrow | ||
| } | ||
| } |
| @@ -0,0 +1,13 @@ | ||
| namespace Combat | ||
| { | ||
| public enum Weapons | ||
| { | ||
| ChainGun, | ||
| Crossbow, | ||
| M16, | ||
| Pistol, | ||
| Shotgun, | ||
| Shuriken, | ||
| SMG | ||
| } | ||
| } |
| @@ -0,0 +1,35 @@ | ||
| using UnityEngine; | ||
| using Stats; | ||
| using System.Collections; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public abstract class AutoWeapon : StandardWeapon | ||
| { | ||
| protected bool Firing { get; set; } | ||
| public override void Start() | ||
| { | ||
| base.Start(); | ||
| } | ||
|
|
||
| internal override bool FireOn() | ||
| { | ||
| if (!Firing) return StartAutoFire(); | ||
| else return true; | ||
| } | ||
|
|
||
| internal override bool FireOff() | ||
| { | ||
| return StopAutoFire(); | ||
| } | ||
|
|
||
| protected bool StandardFire() | ||
| { | ||
| return base.FireOn(); | ||
| } | ||
|
|
||
| protected abstract bool StartAutoFire(); | ||
| protected abstract bool StopAutoFire(); | ||
|
|
||
| } | ||
| } |
| @@ -0,0 +1,35 @@ | ||
| using UnityEngine; | ||
| using Stats; | ||
| using System.Collections; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public abstract class BurstWeapon : StandardWeapon | ||
| { | ||
| protected int BurstNumProjectiles { get; set; } | ||
| protected bool Firing { get; set; } | ||
| public override void Start() | ||
| { | ||
| base.Start(); | ||
| } | ||
|
|
||
| internal override bool FireOn() | ||
| { | ||
| Firing = true; | ||
| ReadyToFire = false; | ||
| return BurstFire(); | ||
| } | ||
| internal override bool FireOff() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| protected bool StandardFire() | ||
| { | ||
| return base.FireOn(); | ||
| } | ||
|
|
||
| protected abstract bool BurstFire(); | ||
|
|
||
| } | ||
| } |
| @@ -0,0 +1,42 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using Stats; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public class ChainGun : AutoWeapon | ||
| { | ||
| public float SpinUpTime; | ||
| public override void Start() | ||
| { | ||
| base.Start(); | ||
| } | ||
|
|
||
| protected override bool StartAutoFire() | ||
| { | ||
| StartCoroutine(AutoFire()); | ||
| return true; | ||
| } | ||
|
|
||
| protected override bool StopAutoFire() | ||
| { | ||
| Firing = false; | ||
| return true; | ||
| } | ||
|
|
||
| private IEnumerator AutoFire() | ||
| { | ||
| //Play Spin up sound | ||
| Firing = true; | ||
| yield return new WaitForSeconds(SpinUpTime); | ||
| while(Firing) | ||
| { | ||
| StandardFire(); | ||
| yield return new WaitForSeconds(Stats.FireRate); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,36 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public class M16 : BurstWeapon | ||
| { | ||
| public int NumProj = 3; | ||
| public override void Start() | ||
| { | ||
| BurstNumProjectiles = NumProj; | ||
| base.Start(); | ||
| } | ||
| protected override bool BurstFire() | ||
| { | ||
| StartCoroutine(StartBurst(BurstNumProjectiles)); | ||
| return true; | ||
| } | ||
|
|
||
| protected IEnumerator StartBurst(int numRounds) | ||
| { | ||
| int i = 0; | ||
| while(Firing) | ||
| { | ||
| StandardFire(); | ||
| i++; | ||
| if (i >= numRounds) | ||
| { | ||
| ReadyToFire = true; | ||
| Firing = false; | ||
| } | ||
| else yield return new WaitForSeconds(Stats.FireRate); | ||
| } | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,33 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using Stats; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public class Pistol : StandardWeapon | ||
| { | ||
| public override void Start() | ||
| { | ||
| base.Start(); | ||
| } | ||
|
|
||
| internal override bool FireOn() | ||
| { | ||
| bool b = base.FireOn(); | ||
| ReadyToFire = false; | ||
| StartCoroutine(EnforceMinCooldown()); | ||
| return b; | ||
| } | ||
|
|
||
| internal override bool FireOff() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| private IEnumerator EnforceMinCooldown() | ||
| { | ||
| yield return new WaitForSeconds(Stats.FireRate); | ||
| ReadyToFire = true; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,35 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using Stats; | ||
| using System.Threading; | ||
|
|
||
| namespace Combat.WeaponVariants | ||
| { | ||
| public abstract class StandardWeapon : MonoBehaviour | ||
| { | ||
|
|
||
| internal Transform BarrelTransform { get; set; } | ||
| internal WeaponStats Stats { get; set; } | ||
| internal bool ReadyToFire { get; set; } | ||
|
|
||
| public virtual void Start() | ||
| { | ||
| BarrelTransform = gameObject.transform; | ||
| ReadyToFire = true; | ||
| } | ||
|
|
||
| internal virtual bool FireOn() | ||
| { | ||
| GameObject g = Projectile.InstantiateProjectile(Stats.ProjectileType, BarrelTransform); | ||
| Projectile p = g.AddComponent<Projectile>(); | ||
| if (p == null) return false; | ||
| Projectile.InitProj(p, BarrelTransform, Stats.ProjectileType, Stats.ProjectileSpeed, Stats.ProjectileDamage, Stats.Range); | ||
| //Produce Sound | ||
| //Create relevant alert to enemies | ||
| return true; | ||
| } | ||
|
|
||
| internal abstract bool FireOff(); | ||
|
|
||
| } | ||
| } |
| @@ -1,21 +1,23 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using Combat; | ||
|
|
||
| namespace Stats | ||
| { | ||
| public struct PowerStats | ||
| { | ||
| public string PowerName; | ||
| public Powers PowerType; | ||
| public int Cooldown; | ||
| public int Range; | ||
| public int Damage; | ||
| public int NoiseLevel; | ||
| public int BaseNumUses; | ||
|
|
||
| public PowerStats(string name, Powers type, int cooldown, int range, int dam, int noise, int baseNum) | ||
| { | ||
| PowerName = name; Cooldown = cooldown; Range = range; Damage = dam; NoiseLevel = noise; BaseNumUses = baseNum; PowerType = type; | ||
| if (PowerName == null) PowerName = PowerType.ToString(); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,25 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using Combat; | ||
|
|
||
| namespace Stats | ||
| { | ||
| public struct WeaponStats | ||
| { | ||
| public string WeaponName; | ||
| public Weapons WeaponType; | ||
| public float FireRate; | ||
| public float Range; | ||
| public ProjectileTypes ProjectileType; | ||
| public int ProjectileDamage; | ||
| public float ProjectileSpeed; | ||
| public int NoiseLevel; | ||
|
|
||
| public WeaponStats(string name, Weapons type, float fireRate, int range, ProjectileTypes projType, int damage, float projSpeed, int noise) | ||
| { | ||
| WeaponName = name; FireRate = fireRate; Range = range; ProjectileType = projType; ProjectileDamage = damage; NoiseLevel = noise; | ||
| WeaponType = type; ProjectileSpeed = projSpeed; | ||
| if (WeaponName == null) WeaponName = WeaponType.ToString(); | ||
| } | ||
| } | ||
| } |
| @@ -28,10 +28,17 @@ void Awake() | ||
| InitializeGame(); | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
|
|
||
| } | ||
|
|
||
| protected virtual void InitializeGame() | ||
| { | ||
| GameManager = new GameplayManager(); | ||
| this.LevelManager = new LevelManager(); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } | ||