Repository: DaniDevy/LudumDare45 Branch: master Commit: 82a07eafdd16 Files: 36 Total size: 55.6 KB Directory structure: gitextract_g4xbrcvp/ ├── LD45/ │ ├── Audio/ │ │ ├── AudioManager.cs │ │ └── Sound.cs │ ├── Board/ │ │ ├── GenerateDungeon.cs │ │ ├── SpawnEnemy.cs │ │ ├── SpawnProps.cs │ │ └── StartRoom.cs │ ├── Camera/ │ │ ├── CameraMovement.cs │ │ └── CameraShake.cs │ ├── Game/ │ │ └── Game.cs │ ├── Other/ │ │ ├── Crate.cs │ │ ├── Enlighten.cs │ │ ├── Floor.cs │ │ ├── Goal.cs │ │ ├── Laser.cs │ │ ├── Minimap.cs │ │ └── Remove.cs │ ├── Player/ │ │ ├── Actor.cs │ │ ├── Enemy/ │ │ │ ├── Enemy.cs │ │ │ └── MeleeEnemy.cs │ │ ├── Enemy.meta │ │ └── PlayerMovement.cs │ ├── UI/ │ │ ├── PlayerStats.cs │ │ ├── Settings.cs │ │ └── Timer.cs │ ├── Upgrades/ │ │ ├── Heart.cs │ │ ├── Helmet.cs │ │ ├── IUpgrade.cs │ │ ├── Sneakers.cs │ │ └── Soda.cs │ └── Weapons/ │ ├── Bullet.cs │ ├── Chest.cs │ ├── Gun.cs │ ├── GunContainer.cs │ ├── Inventory.cs │ └── Weapon.cs └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: LD45/Audio/AudioManager.cs ================================================ using UnityEngine; using Random = UnityEngine.Random; namespace Audio { public class AudioManager : MonoBehaviour { public Sound[] sounds; public bool muted; public bool muteMusic; public static AudioManager Instance { get; set; } void Awake () { Instance = this; foreach (Sound s in sounds) { s.source = gameObject.AddComponent(); s.source.clip = s.clip; s.source.loop = s.loop; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.bypassListenerEffects = s.bypass; } Play("Song"); SetVolume(0.7f); } public void MuteSounds() { muted = !muted; } public void MuteMusic() { muteMusic = !muteMusic; float v; if (muteMusic) v = 0f; else v = 1f; foreach (Sound s in sounds) { if (s.name == "Song") { s.source.volume = v; return; } } } public void SetVolume(float v) { foreach (Sound s in sounds) { if (s.name == "Song") { s.source.volume = v; return; } } } public void UnmuteMusic() { foreach (Sound s in sounds) { if (s.name == "Song") { s.source.volume = 1.15f; return; } } } public void Play(string n) { if (muted && n != "Song") return; foreach (Sound s in sounds) { if (s.name == n) { s.source.Play(); return; } } } public void Stop(string n) { foreach (Sound s in sounds) { if (s.name == n) { s.source.Stop(); return; } } } } } ================================================ FILE: LD45/Audio/Sound.cs ================================================ using UnityEngine; namespace Audio { [System.Serializable] public class Sound { public string name; public AudioClip clip; [Range(0, 2f)] public float volume; [Range(0, 2)] public float pitch; public bool loop; public bool bypass; [HideInInspector] public AudioSource source; } } ================================================ FILE: LD45/Board/GenerateDungeon.cs ================================================ using System; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; public class GenerateDungeon : MonoBehaviour { public GameObject normalChest, upgradeChest, eliteChest; private int nRooms = 10; private int n = 50; private float scale = 30f; public GameObject room, enemyRoom, corridor, empty, mark, floorNr, emptyRoom; private Vector2 spawnPos; public int[,] rooms; public List> roomPositions; private List> availableRooms; private List directionsList; private List currentDirections; public List objects; public static GenerateDungeon Instance { get; set; } private void Awake() { Instance = this; objects = new List(); } public void DeleteDungeon() { print("c: " + objects.Count); foreach (var g in objects) { Destroy(g); } } public void GenerateNewDungeon() { roomPositions = new List>(); rooms = new int[n,n]; directionsList = new List(); directionsList.Add(new Vector2(0, 1)); directionsList.Add(new Vector2(0, -1)); directionsList.Add(new Vector2(1, 0)); directionsList.Add(new Vector2(-1, 0)); Vector2 pos = new Vector2(25,25); Vector2 size = new Vector2(Random.Range(1, 2), Random.Range(1, 2)); Tuple firstRoom = new Tuple(pos, size); roomPositions.Add(firstRoom); Instantiate(floorNr, pos * scale, Quaternion.identity); markRoom(firstRoom, 3); for (int i = 0; i < nRooms; i++) { int c = 0; //Dont do this at home kids LOL while (!GenerateNewRoom()) { c++; if (c > 100) break; } } availableRooms = new List>(roomPositions); Vector2 finalRoom = availableRooms[availableRooms.Count - 1].Item1; rooms[(int) finalRoom.x, (int) finalRoom.y] = 3; FindSpawns(); FindChests(); ShowRooms(); } private void FindChests() { int total = Random.Range(3, 5); print("total: " + total); int normalChests = Random.Range(1, 4); total -= normalChests; int upgradeChests = total; int eliteChests = 0; if (Random.Range(0f, 1f) < 0.25f) eliteChests = 1; for (int i = 0; i < normalChests; i++) { int r = Random.Range(0, availableRooms.Count); Vector2 pos = availableRooms[r].Item1; objects.Add(Instantiate(normalChest, pos * scale, Quaternion.identity)); availableRooms.RemoveAt(r); rooms[(int) pos.x, (int) pos.y] = 3; } for (int i = 0; i < upgradeChests; i++) { int r = Random.Range(0, availableRooms.Count); Vector2 pos = availableRooms[r].Item1; objects.Add(Instantiate(upgradeChest, pos * scale, Quaternion.identity)); availableRooms.RemoveAt(r); rooms[(int) pos.x, (int) pos.y] = 3; } for (int i = 0; i < eliteChests; i++) { int r = Random.Range(0, availableRooms.Count); Vector2 pos = availableRooms[r].Item1; objects.Add(Instantiate(eliteChest, pos * scale, Quaternion.identity)); availableRooms.RemoveAt(r); rooms[(int) pos.x, (int) pos.y] = 3; } } private void ShowAvailable() { for (int i = 0; i < availableRooms.Count; i++) { print(availableRooms[i].Item1.x + ", " + availableRooms[i].Item1.y ); } } private void FindSpawns() { Vector2 playerSpawn = roomPositions[0].Item1; spawnPos = playerSpawn; Vector2 bossSpawn = roomPositions[nRooms].Item1; availableRooms.RemoveAt(nRooms); availableRooms.RemoveAt(0); //Instantiate(mark, playerSpawn * scale, Quaternion.identity); objects.Add(Instantiate(mark, bossSpawn * scale, Quaternion.identity)); } private void FindRandomLeaf() { } private bool GenerateNewRoom() { int roomNumber = Random.Range(0, roomPositions.Count); Vector2 npos = roomPositions[roomNumber].Item1; Vector2 nsize = roomPositions[roomNumber].Item2; int x = Random.Range(0, (int) nsize.x); int y = Random.Range(0, (int) nsize.y); //Find direction to create new room currentDirections = new List(); currentDirections.Add(new Vector2(0, 1)); currentDirections.Add(new Vector2(0, -1)); currentDirections.Add(new Vector2(1, 0)); currentDirections.Add(new Vector2(-1, 0)); for (int u = 0; u < 4; u++) { int nr = Random.Range(0, currentDirections.Count); Vector2 dir = currentDirections[nr] * 2; currentDirections.RemoveAt(nr); if (!hasNeighbours(npos + dir)) { if (nNeighbours(npos+dir) > 2) continue; Vector2 p = npos + dir; Vector2 s = nsize; Tuple nRoom = new Tuple(p, s); roomPositions.Add(nRoom); markRoom(nRoom, 1); rooms[(int) (npos.x + (dir.x / 2)), (int) (npos.y + (dir.y / 2))] = 2; return true; } } return false; } private bool hasNeighbours(Vector2 pos) { for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { Vector2 p = new Vector2(x, y) + pos; if (p.x < 0 || p.x > n || p.y < 0 || p.y > n) continue; if (rooms[(int) p.x, (int) p.y] != 0) return true; } } return false; } private int nNeighbours(Vector2 pos) { int count = 0; if (rooms[(int) pos.x + 2, (int) pos.y] != 0) count++; if (rooms[(int) pos.x - 2, (int) pos.y] != 0) count++; if (rooms[(int) pos.x, (int) pos.y + 2] != 0) count++; if (rooms[(int) pos.x, (int) pos.y - 2] != 0) count++; return count; } private void markRoom(Tuple newRoom, int mark) { Vector2 pos = newRoom.Item1; Vector2 size = newRoom.Item2; for (int x = 0; x < size.x; x++) { rooms[(int) pos.x + x, (int) pos.y] = mark; } for (int y = 1; y < size.y; y++) { rooms[(int) pos.x, (int) pos.y + y] = mark; } if (size.x == 2 && size.y == 2) rooms[(int) pos.x + 1, (int) pos.y + 1] = mark; } private void ShowRooms() { for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (rooms[x, y] == 0) { //nothing GameObject r = Instantiate(empty, new Vector2(x * scale, y * scale), Quaternion.identity); r.transform.localScale = Vector2.one * scale; objects.Add(r); } if (rooms[x, y] == 1) { //room GameObject r = Instantiate(enemyRoom, new Vector2(x * scale, y * scale), Quaternion.identity); r.transform.localScale = Vector2.one * scale; objects.Add(r); } else if (rooms[x, y] == 2) { //corridor float a = 0; if (rooms[x + 1, y] == 1 || rooms[x - 1, y] == 1) a = 90; if (rooms[x + 1, y] == 3 || rooms[x - 1, y] == 3) a = 90; Vector2 s = corridor.transform.localScale * scale; GameObject r = Instantiate(corridor, new Vector2(x * scale, y * scale), Quaternion.Euler(new Vector3(0,0,a))); r.transform.localScale = s; objects.Add(r); } else if (rooms[x, y] == 3) { GameObject r = Instantiate(emptyRoom, new Vector2(x * scale, y * scale), Quaternion.identity); r.transform.localScale = Vector2.one * scale; objects.Add(r); } } } } public Vector2 GetSpawnPos() { return spawnPos * scale; } } ================================================ FILE: LD45/Board/SpawnEnemy.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; public class SpawnEnemy : MonoBehaviour { public GameObject enemy, p, spawnPopFx; public ParticleSystem ps; private void Start() { Invoke(nameof(Spawn), Random.Range(1f, 2f)); ParticleSystem.MainModule m = ps.main; m.startColor = enemy.GetComponent().color; } private void Spawn() { enemy.SetActive(true); Destroy(p); ParticleSystem ps2 = Instantiate(spawnPopFx, transform.position, Quaternion.identity).GetComponent(); ParticleSystem.MainModule m2 = ps2.main; m2.startColor = enemy.GetComponent().color; } } ================================================ FILE: LD45/Board/SpawnProps.cs ================================================ using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpawnProps : MonoBehaviour { public GameObject barrel; public GameObject crate; public GameObject wall; public GameObject lava; public bool walls; void Start() { int crates = Random.Range(0, 3); for (int i = 0; i < crates; i++) { Vector3 pos = new Vector3(Random.Range(-10, 10), Random.Range(-10, 10)); GenerateDungeon.Instance.objects.Add(Instantiate(crate, transform.position + pos, Quaternion.identity)); } if (walls) { int walls = Random.Range(0, 4); for (int i = 0; i < walls; i++) { Vector3 pos = new Vector3(Random.Range(-7, 7), Random.Range(-7, 7)); Vector3 r = new Vector3(0, 0, Random.Range(1, 3) * 90); GenerateDungeon.Instance.objects.Add(Instantiate(wall, transform.position + pos, Quaternion.Euler(r))); } } } } ================================================ FILE: LD45/Board/StartRoom.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using UnityEngine; using Random = UnityEngine.Random; public class StartRoom : MonoBehaviour { public SpriteRenderer doorSprite; public GameObject colliders, roomfade, enemy; private bool started; private int waves, currentWave; private float roomSize; private List enemies; private bool readyToCheck = true; private void Awake() { enemies = new List(); roomSize = 28f; } private void OnTriggerEnter2D(Collider2D other) { if (started) return; if (other.gameObject.CompareTag("Player")) { CameraMovement.Instance.SetRoom(transform); CameraShake.ShakeOnce(0.5f, 2f); AudioManager.Instance.Play("DoorOpen"); doorSprite.sortingOrder = 1; colliders.SetActive(true); roomfade.SetActive(true); started = true; waves = Game.Instance.GetWaveAmount(); currentWave = 1; } } private void FixedUpdate() { if (!started || !readyToCheck) return; CheckEnemyList(); if (enemies.Count == 0) { if (currentWave > waves) { FinishRoom(); return; } SpawnEnemies(); currentWave++; readyToCheck = false; } } private void CheckEnemyList() { for (int i = 0; i < enemies.Count; i++) { if (enemies[i] == null) enemies.RemoveAt(i); } } private void SpawnEnemies() { print("spawning bois"); int n = Game.Instance.GetEnemyAmount(); for (int i = 0; i < n; i++) { Invoke(nameof(SpawnOneEnemy), Random.Range(0, 7)); } Invoke(nameof(GetCheckReady), 7f); } private void GetCheckReady() { readyToCheck = true; } private void SpawnOneEnemy() { GameObject e = SelectEnemy(); Vector3 p = (transform.position + new Vector3(Random.Range(-roomSize / 2, roomSize / 2),Random.Range(-roomSize / 2, roomSize / 2), 0)); enemies.Add(Instantiate(e, p, Quaternion.identity).transform.GetChild(0).gameObject); } private GameObject SelectEnemy() { return Game.Instance.GetEnemy(); } public void FinishRoom() { doorSprite.sortingOrder = -1; colliders.SetActive(false); roomfade.SetActive(false); CameraMovement.Instance.SetRoom(null); AudioManager.Instance.Play("DoorClose"); Destroy(this); } } ================================================ FILE: LD45/Camera/CameraMovement.cs ================================================ using System; using UnityEngine; public class CameraMovement : MonoBehaviour { public Transform player; private float speed = 0.7f; private Vector2 velSpeed; private float defaultZoom = 8f; private float zoomSpeed = 1f; private float velZoom; private Vector2 startPos; private Transform roomT; public Camera c; public static CameraMovement Instance { get; set; } private void Awake() { Instance = this; startPos = transform.position; } void FixedUpdate () { if (player == null) return; //Movement float playerSpeed = PlayerMovement.Instance.GetRb().velocity.magnitude; Vector2 posOffset = PlayerMovement.Instance.GetRb().velocity / 1.75f; Vector2 myPos = new Vector2(player.transform.position.x, player.transform.position.y) + posOffset; //Stay within room bounds if (roomT != null) { Vector2 roomPos = roomT.position; float offset = 10f; if (myPos.x > roomPos.x + offset) myPos = new Vector2(roomPos.x + offset, myPos.y); else if (myPos.x < roomPos.x - offset) myPos = new Vector2(roomPos.x - offset, myPos.y); if (myPos.y > roomPos.y + offset) myPos = new Vector2(myPos.x, roomPos.y + offset); else if (myPos.y < roomPos.y - offset) myPos = new Vector2(myPos.x, roomPos.y - offset); } transform.position = Vector2.SmoothDamp(transform.position, myPos, ref velSpeed, speed); if (playerSpeed > 11) playerSpeed = 11; //Zoom float desiredZoom = defaultZoom + (playerSpeed / 4); //+ height; Camera.main.orthographicSize = Mathf.SmoothDamp(Camera.main.orthographicSize, desiredZoom, ref velZoom, zoomSpeed); transform.position = new Vector3(transform.position.x, transform.position.y, -10); } public void SetPlayer(Transform t) { player = t; } public void StartRound() { c.orthographicSize = 0.1f; transform.position = player.transform.position; } public void SetRoom(Transform pos) { roomT = pos; } } ================================================ FILE: LD45/Camera/CameraShake.cs ================================================ using UnityEngine; using Random = UnityEngine.Random; public class CameraShake : MonoBehaviour { public Transform camTransform; private static float shakeDuration = 0f; private static float shakeAmount = 0.7f; private float vel; private Vector3 vel2 = Vector3.zero; Vector3 originalPos; void Awake() { if (camTransform == null) { camTransform = transform; } originalPos = camTransform.localPosition; } public static void ShakeOnce(float lenght, float strength) { shakeDuration = lenght; shakeAmount = strength; } void Update() { if (shakeDuration > 0) { Vector3 newPos = originalPos + Random.insideUnitSphere * shakeAmount; camTransform.localPosition = Vector3.SmoothDamp(camTransform.localPosition, newPos, ref vel2, 0.05f); shakeDuration -= Time.deltaTime; shakeAmount = Mathf.SmoothDamp(shakeAmount, 0, ref vel, 0.7f); } else { camTransform.localPosition = originalPos; } } } ================================================ FILE: LD45/Game/Game.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using Random = UnityEngine.Random; public class Game : MonoBehaviour { public GameObject player; public GameObject menuUI, gameUI, deadUI; public GameObject[] enemies; public int floor = 1; public bool playing; public static Game Instance { get; set; } public TextMeshProUGUI doneText; private void Awake() { Instance = this; } public void NextFloor() { GenerateDungeon.Instance.DeleteDungeon(); GenerateDungeon.Instance.GenerateNewDungeon(); PlayerMovement.Instance.gameObject.transform.position = GenerateDungeon.Instance.GetSpawnPos(); CameraMovement.Instance.StartRound(); floor++; Minimap.Instance.LoadMap(); } public void StartGame() { GenerateDungeon.Instance.GenerateNewDungeon(); Vector2 spawnPos = GenerateDungeon.Instance.GetSpawnPos(); GameObject p = Instantiate(player, spawnPos, Quaternion.identity); CameraMovement.Instance.SetPlayer(p.transform); CameraMovement.Instance.StartRound(); Timer.Instance.StartTimer(); playing = true; floor = 1; PlayerMovement.Instance.ResetPlayer(); Minimap.Instance.LoadMap(); } public float GetFirerateMultiplier() { float f = Timer.Instance.GetMinutes() / 3; if (f == 0) f = 1; if (f == 5) f = 5; return 5 / f; } public float GetSpeedMultiplier() { float f = Timer.Instance.GetMinutes() / 30; if (f > 0.5f) f = 0.5f; return 0.5f + f; } public int GetEnemyAmount() { int min = Timer.Instance.GetMinutes(); int mi = 1 + (int) Mathf.Floor(min / 2); int ma = (int) Mathf.Floor(min / 1.5f); if (ma < 3) ma = 3; if (ma > 10) ma = 10; if (mi < 2) mi = 2; print("min: " + mi + ", m: " + ma); return Random.Range(mi, ma); } public int GetWaveAmount() { int min = Timer.Instance.GetMinutes(); int ma = (int) Mathf.Floor(min / 4); if (ma > 4) ma = 4; if (ma < 2) ma = 2; return Random.Range(1, ma); } public GameObject GetEnemy() { int min = Timer.Instance.GetMinutes() / 4; int m = 2 + min; if (m > enemies.Length) m = enemies.Length; print("max: " + m); int max = Random.Range(0, m); print("r: " + max); return enemies[max]; } public void PlayerDied() { deadUI.SetActive(true); gameUI.SetActive(false); GenerateDungeon.Instance.DeleteDungeon(); doneText.text = "You made it to floor " + floor; PlayerStats.Instance.gun1.sprite = null; PlayerStats.Instance.gun2.sprite = null; } public int GetEnemyHealth() { int min = Timer.Instance.GetMinutes() / 3; return min; } public void ExitGame() { Application.Quit(1); } } ================================================ FILE: LD45/Other/Crate.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using UnityEngine; using Random = UnityEngine.Random; public class Crate : MonoBehaviour { public GameObject breakFx; public GameObject[] items; private Collider2D[] playerColliders; private Collider2D myCollider; public bool e; private bool coin; private void Start() { GenerateDungeon.Instance.objects.Add(gameObject); } public void Break() { Instantiate(breakFx, transform.position, Quaternion.identity); playerColliders = PlayerMovement.Instance.GetColliders(); print(playerColliders); GameObject weapon = SelectWeapon(e); GameObject w = Instantiate(weapon, transform.position, transform.rotation); Vector2 dir = (transform.position - PlayerMovement.Instance.transform.position).normalized; w.GetComponent().AddForce((dir * 300) + new Vector2(Random.Range(-400, 400), Random.Range(-400, 400))); w.GetComponent().AddTorque(Random.Range(-2000,2000)); CameraShake.ShakeOnce(0.2f, 1.5f); AudioManager.Instance.Play("Hit2"); myCollider = w.GetComponent(); RemoveCollision(); gameObject.SetActive(false); GenerateDungeon.Instance.objects.Add(w); } private void RemoveCollision() { for (int i = 0; i < playerColliders.Length; i++) { Physics2D.IgnoreCollision(playerColliders[i], myCollider, true); } Invoke(nameof(ResumeCollision), 0.8f); } private void ResumeCollision() { print("start colliding again"); for (int i = 0; i < playerColliders.Length; i++) { Physics2D.IgnoreCollision(playerColliders[i], myCollider, false); } } private GameObject SelectWeapon(bool e) { if (Random.Range(0f, 1f) > 0.2f) { coin = true; return items[0]; } int u = Mathf.FloorToInt(0 + (items.Length - 1) * Mathf.Pow(Random.Range(0f, 1f), 2)); u += 1; return items[u]; } } ================================================ FILE: LD45/Other/Enlighten.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Enlighten : MonoBehaviour { private void OnTriggerEnter2D(Collider2D other) { other.gameObject.GetComponent().color = Color.white; print("lighting"); } } ================================================ FILE: LD45/Other/Floor.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class Floor : MonoBehaviour { public TextMeshProUGUI text; public GameObject descriptionText; private void Start() { int floor = Game.Instance.floor; text.text = "Floor " + floor; if (floor > 1) descriptionText.SetActive(false); else descriptionText.SetActive(true); GenerateDungeon.Instance.objects.Add(gameObject); } } ================================================ FILE: LD45/Other/Goal.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Goal : MonoBehaviour { private bool done; private void OnTriggerEnter2D(Collider2D other) { if (done) return; if (other.gameObject.CompareTag("Player")) { done = true; Game.Instance.NextFloor(); } } } ================================================ FILE: LD45/Other/Laser.cs ================================================ using System.Collections; using System.Collections.Generic; using UnityEngine; public class Laser : MonoBehaviour { private Transform target; public LineRenderer lr; void Start() { target = PlayerMovement.Instance.transform; lr.transform.parent = null; lr.transform.position = Vector2.zero; } // Update is called once per frame void Update() { print(target); if (target == null) return; lr.SetPosition(0, transform.position); lr.SetPosition(1, target.position); } } ================================================ FILE: LD45/Other/Minimap.cs ================================================ using System; using System.Collections.Generic; using UnityEngine; public class Minimap : MonoBehaviour { private List> layout; public Material mat; private GameObject player; public GameObject room; public Transform p; private LineRenderer lr; private Transform playerT; public static Minimap Instance { get; set; } private void Awake() { Instance = this; /* lr = p.gameObject.AddComponent(); lr.startColor = Color.white; lr.startWidth = 10f; lr.transform.parent = p; lr.sortingOrder = 10; lr.sortingLayerName = "UI"; lr.material = mat; */ } public void LoadMap() { for (int i = p.childCount - 1; i >= 0; i--) { Destroy(p.GetChild(i).gameObject); } layout = GenerateDungeon.Instance.roomPositions; Vector2 pos2 = PlayerMovement.Instance.transform.position / 30f; player = Instantiate(room, pos2, Quaternion.identity); player.transform.parent = p; player.transform.localPosition = pos2; player.transform.localScale *= 0.25f; player.GetComponent().color = Color.blue; player.GetComponent().sortingOrder = 5; for (int i = 0; i < layout.Count; i++) { Vector2 pos = layout[i].Item1 - new Vector2(25, 25); pos *= 8; GameObject g = Instantiate(room, pos, Quaternion.identity); g.transform.parent = p; g.transform.localPosition = pos; g.transform.localScale *= 0.25f; } playerT = PlayerMovement.Instance.transform; } private void Update() { if (player == null || playerT == null) return; Vector3 pos = ((playerT.position / 30f) - new Vector3(25, 25)) * 8f; Vector3 pPos = new Vector3((int) pos.x, (int)pos.y); player.transform.localPosition = pPos; /* lr.positionCount++; lr.SetPosition(lr.positionCount - 1, player.transform.position); */ for (int i = 0; i < layout.Count; i++) { } } } ================================================ FILE: LD45/Other/Remove.cs ================================================ using System.Collections; using System.Collections.Generic; using UnityEngine; public class Remove : MonoBehaviour { // Start is called before the first frame update void Start() { Invoke(nameof(KillSelf), 1f); } private void KillSelf() { Destroy(gameObject); } } ================================================ FILE: LD45/Player/Actor.cs ================================================ using System; using System.Collections.Generic; using Audio; using UnityEngine; using Random = UnityEngine.Random; public class Actor : MonoBehaviour { public float speed; protected Rigidbody2D rb; public GameObject killFx, bullet, coin; protected Inventory inventory; protected int dashCooldown; protected bool dashing; protected Vector2 dashDir; protected float dashSpeed = 15f; protected int dashDuration = 35; protected int dashC; protected Gun gun = GunContainer.rustyPistol; protected bool readyToFire = true; protected SpriteRenderer sr; protected Color dColor; [SerializeField] protected int health = 5; public ParticleSystem ps; private ParticleSystem.EmissionModule em; protected virtual void Init() { } private void Awake() { ps = GetComponentInChildren(); em = ps.emission; rb = GetComponent(); Init(); sr = GetComponent(); dColor = sr.color; } protected void Aim(Vector3 target) { Vector2 dir = transform.position - target; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(new Vector3(0,0, angle + 90)); } protected void Move(Vector2 dir) { float pen = 1; if ((dir.x > 0.5f || dir.x < -0.5f) && (dir.y > 0.5f || dir.y < -0.5f)) { pen = 1.35f; } rb.velocity = dir.normalized * GetSpeed() * pen; } protected virtual float GetSpeed() { return speed; } protected void Dash(Vector2 dir) { if (dashCooldown > 0) return; AudioManager.Instance.Play("Dash"); float pen = 1; if ((dir.x > 0.5f || dir.x < -0.5f) && (dir.y > 0.5f || dir.y < -0.5f)) { pen = 0.8f; } rb.angularVelocity = 0f; em.enabled = true; dashing = true; dashDir = dir * pen; dashC = 0; dashCooldown = 200; CameraShake.ShakeOnce(0.25f, 1); } protected void StopDash() { dashDir = Vector2.zero; dashing = false; em.enabled = false; rb.angularVelocity = 0f; } protected virtual void KillActor() { GameObject fx = Instantiate(killFx, transform.position, Quaternion.identity); ParticleSystem.MainModule mm = fx.GetComponent().main; mm.startColor = dColor; AudioManager.Instance.Play("Explosion1"); int a = Random.Range(1, 7); for (int i = 0; i < a; i++) { GameObject c = Instantiate(coin, transform.position, Quaternion.identity); GenerateDungeon.Instance.objects.Add(c); c.GetComponent().AddForce(new Vector2(Random.Range(-500, 500), Random.Range(-500, 500))); } Destroy(gameObject); } public virtual void Damage(Vector2 dir, int damage) { health -= damage; if (health < 1) KillActor(); AudioManager.Instance.Play("EnemyHit1"); CancelInvoke(nameof(ResetColor)); sr.color = Color.white; Invoke(nameof(ResetColor), 0.05f); } private void ResetColor() { sr.color = dColor; } protected void Fire() { if (gun == null) return; if (!readyToFire) return; readyToFire = false; AudioManager.Instance.Play("Shoot"); for (int i = 0; i < gun.GetBullets(); i++) { GameObject b = Instantiate(bullet, transform.position + (transform.up / 1.5f), transform.rotation); if (gameObject.layer == LayerMask.NameToLayer("Player")) { b.layer = LayerMask.NameToLayer("PlayerBullet"); } else b.layer = LayerMask.NameToLayer("EnemyBullet"); Rigidbody2D brb = b.GetComponent(); b.GetComponent().color = dColor; ((Bullet) b.GetComponent(typeof(Bullet))).SetDamage(gun.GetDamage()); float s = gun.GetDamage() / 2; if (s > 0.5f) s = 0.5f; b.transform.localScale *= 1 + s; GenerateDungeon.Instance.objects.Add(b); Vector2 dir = transform.rotation * Vector2.up; Vector2 pdir = Vector2.Perpendicular(dir) * Random.Range(-gun.GetSpread(), gun.GetSpread()); brb.velocity = (dir + pdir) * gun.GetSpeed() * GetSpeedMultiplier(); } float f = gun.GetFireRate(); Invoke(nameof(FireCooldown), gun.GetFireRate() * GetFirerateMultiplier()); } protected void FireCooldown() { readyToFire = true; } private void OnCollisionEnter2D(Collision2D other) { if (dashing) { if (other.gameObject.layer == LayerMask.NameToLayer("BlockPlayer")) { if (!other.gameObject.CompareTag("Crate")) StopDash(); } } } protected float GetSpeedMultiplier() { if (gameObject.layer == LayerMask.NameToLayer("Enemy")) return Game.Instance.GetSpeedMultiplier(); return 1; } protected float GetFirerateMultiplier() { if (gameObject.layer == LayerMask.NameToLayer("Enemy")) return Random.Range(2, Game.Instance.GetFirerateMultiplier()); return GetFireRate(); } protected virtual float GetFireRate() { return 2; } } ================================================ FILE: LD45/Player/Enemy/Enemy.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; public class Enemy : Actor { private Transform target; private Vector3 bias; private int c; private float biasStrength = 8f; public LayerMask whatIsWall; public int gunNr; public int desiredDist; public int moveAwayDist; protected override void Init() { target = PlayerMovement.Instance.transform; if (gunNr == -1) gun = GunContainer.GetRandomGun(); else gun = GunContainer.GetGun(gunNr); bias = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f,1f)) * biasStrength; readyToFire = false; Invoke(nameof(FireCooldown), gun.GetFireRate() * GetFirerateMultiplier()); health += Game.Instance.GetEnemyHealth(); GenerateDungeon.Instance.objects.Add(gameObject); } private void Update() { if (target == null) return; Vector2 tp = target.position; Vector2 p = transform.position; float dist = Vector2.Distance(tp, p); if (dist > desiredDist) Move((target.position - transform.position) + bias); else if (dist < moveAwayDist) { Move((transform.position - target.position) + bias); } else { rb.velocity = Vector2.zero; } c++; if (c > 400) { bias = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f,1f)) * biasStrength; c = 0; } Aim(target.position); RaycastHit2D hit = Physics2D.Raycast(transform.position, target.position - transform.position, 20, whatIsWall); Debug.DrawLine(transform.position, target.position, Color.black, 1); if (hit.collider == null) return; if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Player")) { if (dist < 11f) Fire(); } } } ================================================ FILE: LD45/Player/Enemy/MeleeEnemy.cs ================================================ using UnityEngine; public class MeleeEnemy : Actor { private Transform target; protected override void Init() { target = PlayerMovement.Instance.transform; health += Game.Instance.GetEnemyHealth(); } private void Update() { if (target == null) return; Vector2 tp = target.position; Vector2 p = transform.position; float dist = Vector2.Distance(tp, p); Move(target.position - transform.position); Aim(target.position); GenerateDungeon.Instance.objects.Add(gameObject); } } ================================================ FILE: LD45/Player/Enemy.meta ================================================ fileFormatVersion: 2 guid: d2a3ae5f977a6ac46862e85c0f71432d folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: ================================================ FILE: LD45/Player/PlayerMovement.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using UnityEngine; public class PlayerMovement : Actor { public GameObject goldFx; public static PlayerMovement Instance { get; set; } private bool invincible; private int cooldown; private int pCooldown; public int soda, helmet, sneaker; public GameObject currentWeapon; public GameObject chest; private int dashDamage = 1; private int gold; private Vector2 pushDir; protected override void Init() { inventory = new Inventory(); Instance = this; gun = inventory.GetCurrentGun(); } private void Update() { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Aim(mousePos); if (pCooldown > 0) return; if (dashing) return; float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); Move(new Vector2(x, y)); //Shooting if (Input.GetMouseButton(0)) Fire(); if (Input.GetKeyDown(KeyCode.Space)) { Dash(((Vector3) mousePos - transform.position).normalized); } if (Input.GetKeyDown(KeyCode.Q)) { inventory.SwapActive(); } if (Input.GetKeyDown(KeyCode.E)) { if (chest != null) { Chest c = (Chest) chest.GetComponent(typeof(Chest)); if (gold >= c.price) { c.Open(); gold -= c.price; } else { CameraShake.ShakeOnce(0.15f,1.5f); AudioManager.Instance.Play("Error"); } } else if (currentWeapon != null) { inventory.PickupGun(currentWeapon); currentWeapon = null; } } } private void FixedUpdate() { if (dashCooldown > 0) dashCooldown--; if (invincible) { float a = Mathf.PingPong(Time.time * 10, 0.6f) + 0.3f; if (a > 0.7f) sr.color = dColor; else sr.color = Color.black; sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, a / 1.3f); cooldown--; pCooldown--; if (cooldown < 1) { invincible = false; } if (pCooldown > 0) { rb.velocity = pushDir; return; } if (cooldown == 0) sr.color = dColor; } if (dashing) { rb.velocity = (dashDir * dashSpeed) * (1f + (helmet / 4f)); dashC++; float r = transform.localRotation.eulerAngles.z; ParticleSystem.MainModule m = ps.main; m.startRotationZ = 0.01745f * -r; if (dashC > dashDuration) { StopDash(); } } } public Rigidbody2D GetRb() { return rb; } public override void Damage(Vector2 dir, int damage) { if (invincible || dashing) return; base.Damage(dir, 1); invincible = true; cooldown = 80; pCooldown = 25; pushDir = -dir; StopDash(); AudioManager.Instance.Play("PlayerHit"); } protected override void KillActor() { base.KillActor(); Destroy(gameObject); Game.Instance.playing = false; Game.Instance.PlayerDied(); } private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("Pickup")) { if (other.gameObject.CompareTag("Coin")) { Destroy(other.gameObject); AudioManager.Instance.Play("Coin"); Instantiate(goldFx, transform.position, Quaternion.identity); gold++; } //Weapons if (other.gameObject.CompareTag("Gun")) { currentWeapon = other.gameObject; } else if (other.gameObject.CompareTag("Chest")) chest = other.gameObject; else if (other.gameObject.CompareTag("Upgrade")) { ((IUpgrade) other.GetComponent(typeof(IUpgrade))).Upgrade(); AudioManager.Instance.Play("Pickup"); } } if (other.gameObject.layer == LayerMask.NameToLayer("Enemy")) { if (dashing) { Actor e = (Actor) other.GetComponent(typeof(Actor)); e.Damage(rb.velocity, dashDamage + helmet); CameraShake.ShakeOnce(0.2f, 2.5f); } else { Damage(rb.velocity, dashDamage); } } else if (other.gameObject.layer == LayerMask.NameToLayer("BlockPlayer")) { if (other.gameObject.CompareTag("Crate")) { if (dashing) ((Crate) other.gameObject.GetComponent(typeof(Crate))).Break(); } } } private void OnTriggerExit2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("Pickup")) { if (other.gameObject.CompareTag("Gun")) { currentWeapon = null; } else if (other.gameObject.CompareTag("Chest")) chest = null; } } public void Heal() { if (health == 5) { AudioManager.Instance.Play("Coin"); gold += 10; return; } health++; } public void SetGun(Gun g) { gun = g; } public int GetGold() { return gold; } public int GetHealth() { return health; } public void ResetPlayer() { inventory.ResetInventory(); soda = 0; sneaker = 0; helmet = 0; gun = null; health = 5; gold = 20; inventory = new Inventory(); } protected override float GetFireRate() { int s = soda + 1; float r = 1.4f / s; if (r < 0.25f) r = 0.3f; return r; } protected override float GetSpeed() { float s = speed + (sneaker / 2); if (s > 20) s = 20; return s; } public Collider2D[] GetColliders() { return GetComponentsInChildren(); } } ================================================ FILE: LD45/UI/PlayerStats.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class PlayerStats : MonoBehaviour { public TextMeshProUGUI gold; public Transform hearts; public SpriteRenderer gun1, gun2; public static PlayerStats Instance { get; set; } private void Awake() { Instance = this; } private void Update() { gold.text = "" + PlayerMovement.Instance.GetGold(); UpdateHearts(); } private void UpdateHearts() { int h = PlayerMovement.Instance.GetHealth(); for (int i = 0; i < 5; i++) { if (i < h) hearts.GetChild(i).GetChild(0).gameObject.SetActive(true); else hearts.GetChild(i).GetChild(0).gameObject.SetActive(false); } } } ================================================ FILE: LD45/UI/Settings.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using TMPro; using UnityEngine; using UnityEngine.Rendering.PostProcessing; public class Settings : MonoBehaviour { public TextMeshProUGUI graphicsText, musicText, sfxText; public PostProcessLayer ppl; private bool graphics, music, sfx; private void Start() { graphics = true; } public void ChangeGraphics() { graphics = !graphics; ppl.enabled = graphics; graphicsText.text = "Graphics - "; graphicsText.text += graphics ? "Fancy" : "Performance"; } public void ChangeMusic() { bool s = AudioManager.Instance.muteMusic; if (s) musicText.text = "Music - off"; else musicText.text = "Music - on"; } public void ChangeSounds() { bool s = AudioManager.Instance.muted; if (s) sfxText.text = "Sounds - off"; else sfxText.text = "Sounds - on"; } } ================================================ FILE: LD45/UI/Timer.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class Timer : MonoBehaviour { public TextMeshProUGUI text, status; private float timer = 0; public static Timer Instance { get; set; } private void Awake() { Instance = this; } public void StartTimer() { timer = 0; } void Update() { if (!Game.Instance.playing) return; timer += Time.deltaTime; string minutes = Mathf.Floor(timer / 60).ToString("00"); string seconds = Mathf.Floor(timer % 60).ToString("00"); text.text = string.Format("{0}:{1}", minutes, seconds); status.text = StatusText(Mathf.Floor(timer / 60)); } private string StatusText(float f) { if (f < 2) return "very easy"; if (f < 4) return "easy"; if (f < 8) return "medium"; if (f < 12) return "hard"; if (f < 16) return "very hard"; if (f < 20) return "impossible"; if (f < 25) return "oh shit"; if (f < 30) return "very oh shit"; return "f"; } public int GetMinutes() { return (int) Mathf.Floor(timer / 60); } } ================================================ FILE: LD45/Upgrades/Heart.cs ================================================ using System.Collections; using System.Collections.Generic; using UnityEngine; public class Heart : MonoBehaviour, IUpgrade { private bool upgraded; public GameObject pickup; public void Upgrade() { if (upgraded) return; upgraded = true; PlayerMovement.Instance.Heal(); Instantiate(pickup, transform.position, Quaternion.identity); Destroy(gameObject); } } ================================================ FILE: LD45/Upgrades/Helmet.cs ================================================ using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class Helmet : MonoBehaviour, IUpgrade { //please dont look at my shitty redundant code LOL private bool upgraded; public GameObject pickup; public GameObject text; public void Upgrade() { if (upgraded) return; upgraded = true; PlayerMovement.Instance.helmet++; Instantiate(pickup, transform.position, Quaternion.identity); Destroy(gameObject); Instantiate(text, transform.position, Quaternion.identity).GetComponentInChildren().text = "+dash"; } } ================================================ FILE: LD45/Upgrades/IUpgrade.cs ================================================ using System.Collections; using System.Collections.Generic; using UnityEngine; public interface IUpgrade { void Upgrade(); } ================================================ FILE: LD45/Upgrades/Sneakers.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class Sneakers : MonoBehaviour, IUpgrade { private bool upgraded; public GameObject pickup; public GameObject text; public void Upgrade() { if (upgraded) return; upgraded = true; PlayerMovement.Instance.sneaker++; Instantiate(pickup, transform.position, Quaternion.identity); Destroy(gameObject); Instantiate(text, transform.position, Quaternion.identity).GetComponentInChildren().text = "+speed"; } } ================================================ FILE: LD45/Upgrades/Soda.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class Soda : MonoBehaviour, IUpgrade { private bool upgraded; public GameObject pickup; public GameObject text; public void Upgrade() { if (upgraded) return; upgraded = true; PlayerMovement.Instance.soda++; Instantiate(pickup, transform.position, Quaternion.identity); Destroy(gameObject); Instantiate(text, transform.position, Quaternion.identity).GetComponentInChildren().text = "+fire rate"; } } ================================================ FILE: LD45/Weapons/Bullet.cs ================================================ using System; using UnityEngine; public class Bullet : MonoBehaviour { public GameObject explosion; private int damage = 1; private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("BlockPlayer")) ExplodeBullet(); else { Actor a = (Actor) other.gameObject.GetComponent(typeof(Actor)); a.Damage(-GetComponent().velocity, damage); ExplodeBullet(); } } private void ExplodeBullet() { Instantiate(explosion, transform.position, Quaternion.identity); Destroy(gameObject); } public void SetDamage(int d) { damage = d; } } ================================================ FILE: LD45/Weapons/Chest.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using UnityEngine; using Random = UnityEngine.Random; public class Chest : MonoBehaviour { public GameObject[] weapons; private Collider2D[] playerColliders; private Collider2D myCollider; public bool e; public int price; public void Open() { playerColliders = PlayerMovement.Instance.GetColliders(); print(playerColliders); GameObject weapon = SelectWeapon(e); GameObject w = Instantiate(weapon, transform.position, transform.rotation); Vector2 dir = (transform.position - PlayerMovement.Instance.transform.position).normalized; w.GetComponent().AddForce((dir * 3000) + new Vector2(Random.Range(-4000, 4000), Random.Range(-4000, 4000))); w.GetComponent().AddTorque(Random.Range(-2000,2000)); CameraShake.ShakeOnce(0.3f, 2f); AudioManager.Instance.Play("Pickup"); myCollider = w.GetComponent(); RemoveCollision(); gameObject.SetActive(false); GenerateDungeon.Instance.objects.Add(w); } private void RemoveCollision() { for (int i = 0; i < playerColliders.Length; i++) { Physics2D.IgnoreCollision(playerColliders[i], myCollider, true); } Invoke(nameof(ResumeCollision), 0.8f); } private void ResumeCollision() { print("start colliding again"); for (int i = 0; i < playerColliders.Length; i++) { Physics2D.IgnoreCollision(playerColliders[i], myCollider, false); } } private GameObject SelectWeapon(bool e) { if (e) { return weapons[Random.Range(0, weapons.Length)]; } int u = Mathf.FloorToInt(0 + (weapons.Length) * Mathf.Pow(Random.Range(0f, 1f), 2)); int sum = 0; return weapons[u]; } } ================================================ FILE: LD45/Weapons/Gun.cs ================================================ using UnityEngine; public class Gun { private float fireRate; private float bullets; private float spread; private float speed; private int damage; private string description; public Gun(float fireRate, float bullets, float spread, float speed, int damage, string desc) { this.fireRate = fireRate; this.bullets = bullets; this.spread = spread; this.speed = speed; this.description = desc; this.damage = damage; } public float GetFireRate() { return fireRate; } public float GetBullets() { return bullets; } public float GetSpread() { return spread; } public float GetSpeed() { return speed; } public string GetDescription() { return description; } public int GetDamage() { return damage; } } ================================================ FILE: LD45/Weapons/GunContainer.cs ================================================  using System; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; public class GunContainer : MonoBehaviour{ public static readonly Gun rustyPistol = new Gun(0.35f, 1, 0.15f, 9f, 1, "Rusty Pistol"); public static readonly Gun shinyPistol = new Gun(0.3f, 1, 0.08f, 12f, 1, "Shiny Pistol"); public static readonly Gun dualPistol = new Gun(0.3f, 2, 0.2f, 11f, 1, "Dual Pistol"); public static readonly Gun revolver = new Gun(0.4f, 1, 0.05f, 14f, 2, "Revolver"); public static readonly Gun smallShotgun = new Gun(0.5f, 5, 0.35f, 12f, 1, "Small Shotgun"); public static readonly Gun shotgun = new Gun(0.45f, 6, 0.25f, 14f, 1, "Shotgun"); public static readonly Gun sawedoffShotgun = new Gun(0.55f, 8, 0.5f, 14f, 1, "Sawed-off Shotgun"); public static readonly Gun rifle = new Gun(0.1f, 1, 0.15f, 15f, 1, "Rifle"); public static readonly Gun doubleRifle = new Gun(0.12f, 2, 0.45f, 15f, 1, "Double Rifle"); public static readonly Gun coolRifle = new Gun(0.15f, 1, 0.13f, 15f, 2, "Cooler Rifle"); public static readonly Gun sniper = new Gun(0.8f, 1, 0.0f, 25f, 10, "Sniper"); public static List guns; private void Start() { guns = new List(); guns.Add(rustyPistol); guns.Add(shinyPistol); guns.Add(dualPistol); guns.Add(revolver); guns.Add(smallShotgun); guns.Add(shotgun); guns.Add(sawedoffShotgun); guns.Add(rifle); guns.Add(doubleRifle); guns.Add(coolRifle); guns.Add(sniper); } public static Gun GetGun(int n) { return guns[n]; } public static Gun GetRandomGun() { return guns[Random.Range(0, guns.Count)]; } } ================================================ FILE: LD45/Weapons/Inventory.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using Audio; using UnityEngine; public class Inventory : MonoBehaviour { private Gun gun1, gun2; private int activeGun = 0; public void PickupGun(GameObject g) { if (g == null) return; Weapon w = (Weapon) g.GetComponent(typeof(Weapon)); if (w.pickedUp) return; w.pickedUp = true; AudioManager.Instance.Play("PickupGun"); g.SetActive(false); if (gun1 == null) { gun1 = ((Weapon) g.GetComponent(typeof(Weapon))).GetGun(); PlayerStats.Instance.gun1.sprite = g.GetComponent().sprite; } else if (gun2 == null) { gun2 = ((Weapon) g.GetComponent(typeof(Weapon))).GetGun(); PlayerStats.Instance.gun2.sprite = g.GetComponent().sprite; } else if (activeGun == 0) { gun1 = ((Weapon) g.GetComponent(typeof(Weapon))).GetGun(); PlayerStats.Instance.gun1.sprite = g.GetComponent().sprite; } else { gun2 = ((Weapon) g.GetComponent(typeof(Weapon))).GetGun(); PlayerStats.Instance.gun2.sprite = g.GetComponent().sprite; } PlayerMovement.Instance.SetGun(GetCurrentGun()); } public Gun GetCurrentGun() { if (activeGun == 0) { return gun1; } return gun2; } public void SwapActive() { AudioManager.Instance.Play("PickupGun"); if (activeGun == 0) { activeGun = 1; PlayerStats.Instance.gun1.transform.GetChild(0).GetComponent().color = Color.gray; PlayerStats.Instance.gun2.transform.GetChild(0).GetComponent().color = Color.white; } else { activeGun = 0; PlayerStats.Instance.gun2.transform.GetChild(0).GetComponent().color = Color.gray; PlayerStats.Instance.gun1.transform.GetChild(0).GetComponent().color = Color.white; } PlayerMovement.Instance.SetGun(GetCurrentGun()); } public void ResetInventory() { gun1 = null; gun2 = null; activeGun = 0; } } ================================================ FILE: LD45/Weapons/Weapon.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Weapon : MonoBehaviour { private Gun gun; public int gunNr; public bool pickedUp; private void Start() { gun = GunContainer.GetGun(gunNr); } public Gun GetGun() { return gun; } } ================================================ FILE: README.md ================================================ # LudumDare45