Skip to content

Commit 2b59e3b

Browse files
authored
Merge pull request #4 from yath-rth/dev
feat: create final unity package
2 parents 80c95e9 + 5c4d38b commit 2b59e3b

File tree

203 files changed

+71867
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+71867
-27
lines changed

.gitignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
/[Pp]ackages/
13+
14+
# MemoryCaptures can get excessive in size.
15+
# They also could contain extremely sensitive data
16+
/[Mm]emoryCaptures/
17+
18+
# Recordings can get excessive in size
19+
/[Rr]ecordings/
20+
21+
# Uncomment this line if you wish to ignore the asset store tools plugin
22+
# /[Aa]ssets/AssetStoreTools*
23+
24+
# Autogenerated Jetbrains Rider plugin
25+
/[Aa]ssets/Plugins/Editor/JetBrains*
26+
27+
# Visual Studio cache directory
28+
.vs/
29+
30+
# Gradle cache directory
31+
.gradle/
32+
33+
# Autogenerated VS/MD/Consulo solution and project files
34+
ExportedObj/
35+
.consulo/
36+
*.csproj
37+
*.unityproj
38+
*.sln
39+
*.suo
40+
*.tmp
41+
*.user
42+
*.userprefs
43+
*.pidb
44+
*.booproj
45+
*.svd
46+
*.pdb
47+
*.mdb
48+
*.opendb
49+
*.VC.db
50+
51+
# Unity3D generated meta files
52+
*.pidb.meta
53+
*.pdb.meta
54+
*.mdb.meta
55+
56+
# Unity3D generated file on crash reports
57+
sysinfo.txt
58+
59+
# Builds
60+
*.apk
61+
*.aab
62+
*.unitypackage
63+
*.unitypackage.meta
64+
*.app
65+
66+
# Crashlytics generated file
67+
crashlytics-build.properties
68+
69+
# Packed Addressables
70+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
71+
72+
# Temporary auto-generated Android Assets
73+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
74+
/[Aa]ssets/[Ss]treamingAssets/aa/*

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"visualstudiotoolsforunity.vstuc"
4+
]
5+
}

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Unity",
6+
"type": "vstuc",
7+
"request": "attach"
8+
}
9+
]
10+
}

.vscode/settings.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"**/.git": true,
5+
"**/.vs": true,
6+
"**/.gitmodules": true,
7+
"**/.vsconfig": true,
8+
"**/*.booproj": true,
9+
"**/*.pidb": true,
10+
"**/*.suo": true,
11+
"**/*.user": true,
12+
"**/*.userprefs": true,
13+
"**/*.unityproj": true,
14+
"**/*.dll": true,
15+
"**/*.exe": true,
16+
"**/*.pdf": true,
17+
"**/*.mid": true,
18+
"**/*.midi": true,
19+
"**/*.wav": true,
20+
"**/*.gif": true,
21+
"**/*.ico": true,
22+
"**/*.jpg": true,
23+
"**/*.jpeg": true,
24+
"**/*.png": true,
25+
"**/*.psd": true,
26+
"**/*.tga": true,
27+
"**/*.tif": true,
28+
"**/*.tiff": true,
29+
"**/*.3ds": true,
30+
"**/*.3DS": true,
31+
"**/*.fbx": true,
32+
"**/*.FBX": true,
33+
"**/*.lxo": true,
34+
"**/*.LXO": true,
35+
"**/*.ma": true,
36+
"**/*.MA": true,
37+
"**/*.obj": true,
38+
"**/*.OBJ": true,
39+
"**/*.asset": true,
40+
"**/*.cubemap": true,
41+
"**/*.flare": true,
42+
"**/*.mat": true,
43+
"**/*.meta": true,
44+
"**/*.prefab": true,
45+
"**/*.unity": true,
46+
"build/": true,
47+
"Build/": true,
48+
"Library/": true,
49+
"library/": true,
50+
"obj/": true,
51+
"Obj/": true,
52+
"Logs/": true,
53+
"logs/": true,
54+
"ProjectSettings/": true,
55+
"UserSettings/": true,
56+
"temp/": true,
57+
"Temp/": true
58+
},
59+
"files.associations": {
60+
"*.asset": "yaml",
61+
"*.meta": "yaml",
62+
"*.prefab": "yaml",
63+
"*.unity": "yaml",
64+
},
65+
"explorer.fileNesting.enabled": true,
66+
"explorer.fileNesting.patterns": {
67+
"*.sln": "*.csproj",
68+
},
69+
"dotnet.defaultSolution": "Modular Systems.sln"
70+
}

Assets/Basic Projectile Gun System.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using UnityEngine;
6+
7+
[CreateAssetMenu(menuName = "Gun Object", order = 0)]
8+
public class GunIScriptableObject : Stats
9+
{
10+
public GameObject gun;
11+
12+
[Header("Properties")]
13+
public float bulletSpeed;
14+
public float range;
15+
public int ammo;
16+
public float reloadTime;
17+
18+
[Header("Objects")]
19+
public AudioClip audioClip;
20+
21+
[Header("Activity")]
22+
public bool active;
23+
public bool infiniteAmmo = false;
24+
25+
26+
}

Assets/Basic Projectile Gun System/GunIScriptableObject.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using System.Linq;
5+
using UnityEngine.InputSystem;
6+
7+
public class GunManager : MonoBehaviour
8+
{
9+
ObjectPooler pool;
10+
InputSystem_Actions input;
11+
12+
public List<GunIScriptableObject> gunTypes;
13+
GunIScriptableObject activeGun;
14+
15+
bool isReloading = false;
16+
int currAmmo = 0;
17+
18+
float canFire, fireInput = 0;
19+
20+
[SerializeField] Vector3 reloadRotation;
21+
[SerializeField] Transform gunParent;
22+
AudioSource audioSource;
23+
24+
[Header("Objects")]
25+
Transform shellSpawn;
26+
List<ParticleSystem> muzzleFlash = new List<ParticleSystem>();
27+
List<GameObject> flashLight = new List<GameObject>();
28+
public List<Transform> muzzle = new List<Transform>();
29+
30+
private void Start()
31+
{
32+
pool = ObjectPooler.instance;
33+
input = new InputSystem_Actions();
34+
audioSource = GetComponent<AudioSource>();
35+
36+
//gunTypes[Random.Range(0, gunTypes.Count)].active = true; //To get a random gun type
37+
38+
foreach (GunIScriptableObject item in gunTypes)
39+
{
40+
if (item.active)
41+
{
42+
activeGun = item;
43+
//item.active = false; //To save the last active gun
44+
break;
45+
}
46+
}
47+
48+
if (activeGun == null) activeGun = gunTypes[Random.Range(0, gunTypes.Count)];
49+
50+
Transform gunInstance = Instantiate(activeGun.gun, gunParent).transform;
51+
Debug.Log(gunInstance.name);
52+
53+
for (int i = 0; i < gunInstance.childCount; i++)
54+
{
55+
Transform item = gunInstance.transform.GetChild(i);
56+
57+
if (item.CompareTag("muzzle") && item != null)
58+
{
59+
muzzle.Add(item);
60+
flashLight.Add(item.Find("Flash").gameObject);
61+
muzzleFlash.Add(item.Find("Muzzle Flash").GetComponent<ParticleSystem>());
62+
}
63+
64+
if (item.gameObject.name == "Mag") shellSpawn = item;
65+
}
66+
67+
currAmmo = activeGun.ammo;
68+
}
69+
70+
private void OnEnable()
71+
{
72+
input.Enable();
73+
input.Player.Attack.performed += ctx => Attack();
74+
}
75+
76+
void Attack()
77+
{
78+
if (isReloading) return;
79+
80+
if (currAmmo <= 0)
81+
{
82+
StartCoroutine(reloading());
83+
return;
84+
}
85+
86+
if (canFire <= Time.time)
87+
{
88+
if (activeGun.getStat(StatTypes.attackCooldown) > 0) canFire = Time.time + (1 / (activeGun.getStat(StatTypes.attackCooldown) / 60f));
89+
else canFire = Time.time;
90+
91+
StartCoroutine(Shoot());
92+
}
93+
}
94+
95+
IEnumerator Shoot()
96+
{
97+
if (pool != null)
98+
{
99+
if (!activeGun.infiniteAmmo) currAmmo--;
100+
101+
for (int i = 0; i < muzzle.Count; i++)
102+
{
103+
if (muzzle[i].gameObject.activeInHierarchy)
104+
{
105+
GameObject bullet = pool.GetObject(1);
106+
bullet.transform.SetPositionAndRotation(muzzle[i].position, muzzle[i].rotation);
107+
bullet.GetComponent<Rigidbody>().AddForce(muzzle[i].forward * activeGun.bulletSpeed, ForceMode.Impulse);
108+
muzzleFlash[i].Play();
109+
flashLight[i].SetActive(true);
110+
StartCoroutine(bullet.GetComponent<bullet>().Initialise(activeGun.range));
111+
}
112+
}
113+
114+
GameObject shell = pool.GetObject(3);
115+
shell.transform.SetPositionAndRotation(shellSpawn.position, shellSpawn.rotation);
116+
117+
audioSource.PlayOneShot(activeGun.audioClip);
118+
119+
yield return new WaitForSeconds(.2f);
120+
121+
foreach (GameObject item in flashLight) item.SetActive(false);
122+
}
123+
}
124+
125+
IEnumerator reloading()
126+
{
127+
Debug.Log("Reloading");
128+
isReloading = true;
129+
130+
yield return new WaitForSeconds(activeGun.reloadTime);
131+
isReloading = false;
132+
133+
currAmmo = activeGun.ammo;
134+
}
135+
}

Assets/Basic Projectile Gun System/GunManager.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
[RequireComponent(typeof(Rigidbody))]
6+
public class bullet : MonoBehaviour
7+
{
8+
public IEnumerator Initialise(float range)
9+
{
10+
yield return new WaitForSeconds(range);
11+
gameObject.GetComponent<Rigidbody>().linearVelocity = Vector3.zero;
12+
if (ObjectPooler.instance != null) ObjectPooler.instance.ReturnObject(gameObject, 1);
13+
}
14+
}

0 commit comments

Comments
 (0)