Skip to content

Commit

Permalink
Ammo
Browse files Browse the repository at this point in the history
  • Loading branch information
socialsalih committed Jun 7, 2023
1 parent 1a03063 commit 16d85c7
Show file tree
Hide file tree
Showing 11 changed files with 645 additions and 340 deletions.
843 changes: 559 additions & 284 deletions Assets/Scenes/Operation 1/1-1/1-1/1-1.unity

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Assets/Scripts/Controller/Ammo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ammo : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
PlayerAmmo playerAmmo = other.GetComponent<PlayerAmmo>();

if (playerAmmo != null)
{
playerAmmo.AmmoCollected();
gameObject.SetActive(false);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Assets/Scripts/Controller/AmmoItemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class AmmoItemController : MonoBehaviour
public string playerTag = "Player";
public string ammoTag = "Ammo";
public int ammoIncreaseAmount = 10;
public GameObject ammoUI;

private int ammoCount = 0;

Expand All @@ -20,14 +19,9 @@ private void OnTriggerEnter(Collider other)
{
Destroy(gameObject);
ammoCount += ammoIncreaseAmount;
UpdateAmmoUI();
}
}
}
}

private void UpdateAmmoUI()
{
ammoUI.GetComponentInChildren<Text>().text = "Ammo: " + ammoCount.ToString();
}
}
}
23 changes: 23 additions & 0 deletions Assets/Scripts/Controller/AmmoUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;


public class AmmoUI : MonoBehaviour
{
private TextMeshProUGUI ammoText;

// Start is called before the first frame update
void Start()
{
ammoText = GetComponent<TextMeshProUGUI>();
}

public void UpdateKeyText(PlayerAmmo playerAmmo)
{
ammoText.text = playerAmmo.NumberOfAmmos.ToString();
}


}
11 changes: 11 additions & 0 deletions Assets/Scripts/Controller/AmmoUI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scripts/Controller/KeyUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class KeyUI : MonoBehaviour
{
private TextMeshProUGUI keyText;
public TextMeshProUGUI keyText;

// Start is called before the first frame update
void Start()
Expand Down
19 changes: 19 additions & 0 deletions Assets/Scripts/Controller/PlayerAmmo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class PlayerAmmo : MonoBehaviour
{
public int NumberOfAmmos { get; private set; }

public UnityEvent<PlayerAmmo> OnAmmoCollected;


public void AmmoCollected()
{
NumberOfAmmos++;
OnAmmoCollected.Invoke(this);
}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/Controller/PlayerAmmo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 0 additions & 47 deletions Assets/Scripts/Weapons/WeaponController.cs

This file was deleted.

2 changes: 2 additions & 0 deletions ProjectSettings/TagManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ TagManager:
- enemy
- target
- Goal
- CinemachineTarget
- bullet
layers:
- Default
- TransparentFX
Expand Down

0 comments on commit 16d85c7

Please sign in to comment.