├── .gitattributes ├── 3rd Person Tutorial ├── MeleeWeapon.cs ├── MeleeWeapon.cs.meta ├── ThirdPersonAnimation.cs ├── ThirdPersonAnimation.cs.meta ├── ThirdPersonController.cs ├── ThirdPersonController.cs.meta ├── Zombie.cs └── Zombie.cs.meta ├── Coroutines ├── ChangeValueCoroutine.cs ├── ChangeValueCoroutine.cs.meta ├── ChangingValueUpdate.cs ├── ChangingValueUpdate.cs.meta ├── CoroutineTurnOff.cs ├── CoroutineTurnOff.cs.meta ├── GameBoardGenerator.cs ├── GameBoardGenerator.cs.meta ├── ImageFill.cs ├── ImageFill.cs.meta ├── MoveSlider.cs ├── MoveSlider.cs.meta ├── MovingWithCoroutine.cs ├── MovingWithCoroutine.cs.meta ├── MovingWithUpdate.cs ├── MovingWithUpdate.cs.meta ├── ObjectFloatDown.cs ├── ObjectFloatDown.cs.meta ├── ReferenceTest.cs ├── ReferenceTest.cs.meta ├── YieldExamples.cs └── YieldExamples.cs.meta ├── Event Handlers ├── AddObject.cs ├── AddObject.cs.meta ├── DoubleClickToSpin.cs ├── DoubleClickToSpin.cs.meta ├── InventorySlot.cs ├── InventorySlot.cs.meta ├── InventoryTile.cs ├── InventoryTile.cs.meta ├── MoveObject.cs ├── MoveObject.cs.meta ├── SFXManager.cs ├── SFXManager.cs.meta ├── Simple_Drag_and_Drop.unitypackage ├── StarWiggle.cs ├── StarWiggle.cs.meta ├── UIDrag.cs ├── UIDrag.cs.meta ├── UIPopup.cs ├── UIPopup.cs.meta ├── UIPopupOnHover.cs └── UIPopupOnHover.cs.meta ├── ExtensionMethods ├── ExtensionExamples.cs └── ExtensionExamples.cs.meta ├── Generics ├── MeleeWeapon.cs ├── MeleeWeapon.cs.meta ├── ThirdPersonActionsAsset.cs ├── ThirdPersonActionsAsset.cs.meta ├── ThirdPersonActionsAsset.inputactions ├── ThirdPersonActionsAsset.inputactions.meta ├── ThirdPersonAnimation.cs ├── ThirdPersonAnimation.cs.meta ├── ThirdPersonController.cs ├── ThirdPersonController.cs.meta ├── Zombie.cs └── Zombie.cs.meta ├── Key Rebind ├── InputManager.cs ├── InputManager.cs.meta ├── JumpController.cs ├── JumpController.cs.meta ├── ReBindUI.cs ├── ReBindUI.cs.meta ├── Rebind Prefab.prefab ├── Rebind Prefab.prefab.meta ├── RebindJumping.cs ├── RebindJumping.cs.meta ├── RebindJumping.inputactions └── RebindJumping.inputactions.meta ├── License ├── Object Pool 2 ├── DisableObjects.cs ├── ObjectPool.cs ├── PoolObject.cs └── Spawner.cs ├── README.md ├── RayCasting ├── CharacterJumping.cs ├── CharacterJumping.cs.meta ├── FirstPersonTargetShooting.cs ├── FirstPersonTargetShooting.cs.meta ├── FlashPoof.cs ├── FlashPoof.cs.meta ├── FlyingCube.cs ├── FlyingCube.cs.meta ├── New Input │ ├── CharacterJumpingNewInput.cs │ ├── CharacterJumpingNewInput.cs.meta │ ├── FirstPersonTargetShootingNewInput.cs │ ├── FirstPersonTargetShootingNewInput.cs.meta │ ├── Input Actions.meta │ ├── Input Actions │ │ ├── SelectingActions.cs │ │ ├── SelectingActions.cs.meta │ │ ├── SelectingActions.inputactions │ │ ├── SelectingActions.inputactions.meta │ │ ├── ShootingActions.cs │ │ ├── ShootingActions.cs.meta │ │ ├── ShootingActions.inputactions │ │ └── ShootingActions.inputactions.meta │ ├── SelectingAndMovingObjectNewInput.cs │ ├── SelectingAndMovingObjectNewInput.cs.meta │ ├── SelectingObjectsNewInput.cs │ └── SelectingObjectsNewInput.cs.meta ├── RaycastOverload.cs ├── RaycastOverload.cs.meta ├── SelectingAndMovingObject.cs ├── SelectingAndMovingObject.cs.meta ├── SelectingObjects.cs ├── SelectingObjects.cs.meta ├── Target.cs └── Target.cs.meta ├── Split Screen ├── CinemachineInputHandler.cs ├── InputHandler.cs ├── PlayerManager.cs ├── ThirdPersonController.cs ├── ToggleOnPlayerJoin.cs ├── ZombiePod.cs └── ZombieSpawner.cs ├── Stats and Upgrades ├── ExtraBits.cs ├── ExtraBits.cs.meta ├── Stats.cs ├── Stats.cs.meta ├── StatsManager.cs ├── StatsManager.cs.meta ├── StatsUpgrade.cs ├── StatsUpgrade.cs.meta ├── Upgrade.cs └── Upgrade.cs.meta └── Strategy Camera ├── CameraMovement.cs └── Input Settings ├── CameraControls.cs └── CameraControls.inputactions /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /3rd Person Tutorial/MeleeWeapon.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(AudioSource))] 6 | public class MeleeWeapon : MonoBehaviour 7 | { 8 | //not the best way to do audio but it works 9 | //events and a SFX manager might be better. 10 | [SerializeField] 11 | private AudioClip clip; 12 | private AudioSource audioSource; 13 | 14 | private void Start() 15 | { 16 | audioSource = this.GetComponent(); 17 | } 18 | private void OnTriggerEnter(Collider other) 19 | { 20 | Zombie zombie = other.GetComponent(); 21 | 22 | if (zombie != null && zombie.enabled) 23 | { 24 | zombie.Die(); 25 | if(!audioSource.isPlaying) 26 | audioSource.PlayOneShot(clip); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /3rd Person Tutorial/MeleeWeapon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9367a170669d37e43921fb044be990c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /3rd Person Tutorial/ThirdPersonAnimation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ThirdPersonAnimation : MonoBehaviour 6 | { 7 | private Animator animator; 8 | private Rigidbody rb; 9 | private float maxSpeed = 5f; 10 | 11 | // Start is called before the first frame update 12 | void Start() 13 | { 14 | animator = this.GetComponent(); 15 | rb = this.GetComponent(); 16 | } 17 | 18 | // Update is called once per frame 19 | void Update() 20 | { 21 | animator.SetFloat("speed", rb.velocity.magnitude / maxSpeed); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /3rd Person Tutorial/ThirdPersonAnimation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 979be96d5de73664fa83b71d13a073f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /3rd Person Tutorial/ThirdPersonController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.InputSystem; 6 | 7 | public class ThirdPersonController : MonoBehaviour 8 | { 9 | //input fields 10 | private ThirdPersonActionsAsset playerActionsAsset; 11 | private InputAction move; 12 | 13 | //movement fields 14 | private Rigidbody rb; 15 | [SerializeField] 16 | private float movementForce = 1f; 17 | [SerializeField] 18 | private float jumpForce = 5f; 19 | [SerializeField] 20 | private float maxSpeed = 5f; 21 | private Vector3 forceDirection = Vector3.zero; 22 | 23 | [SerializeField] 24 | private Camera playerCamera; 25 | private Animator animator; 26 | 27 | private void Awake() 28 | { 29 | rb = this.GetComponent(); 30 | playerActionsAsset = new ThirdPersonActionsAsset(); 31 | animator = this.GetComponent(); 32 | } 33 | 34 | private void OnEnable() 35 | { 36 | playerActionsAsset.Player.Jump.started += DoJump; 37 | playerActionsAsset.Player.Attack.started += DoAttack; 38 | move = playerActionsAsset.Player.Move; 39 | playerActionsAsset.Player.Enable(); 40 | } 41 | 42 | private void OnDisable() 43 | { 44 | playerActionsAsset.Player.Jump.started -= DoJump; 45 | playerActionsAsset.Player.Attack.started -= DoAttack; 46 | playerActionsAsset.Player.Disable(); 47 | } 48 | 49 | private void FixedUpdate() 50 | { 51 | forceDirection += move.ReadValue().x * GetCameraRight(playerCamera) * movementForce; 52 | forceDirection += move.ReadValue().y * GetCameraForward(playerCamera) * movementForce; 53 | 54 | rb.AddForce(forceDirection, ForceMode.Impulse); 55 | forceDirection = Vector3.zero; 56 | 57 | if (rb.velocity.y < 0f) 58 | rb.velocity -= Vector3.down * Physics.gravity.y * Time.fixedDeltaTime; 59 | 60 | Vector3 horizontalVelocity = rb.velocity; 61 | horizontalVelocity.y = 0; 62 | if (horizontalVelocity.sqrMagnitude > maxSpeed * maxSpeed) 63 | rb.velocity = horizontalVelocity.normalized * maxSpeed + Vector3.up * rb.velocity.y; 64 | 65 | LookAt(); 66 | } 67 | 68 | private void LookAt() 69 | { 70 | Vector3 direction = rb.velocity; 71 | direction.y = 0f; 72 | 73 | if (move.ReadValue().sqrMagnitude > 0.1f && direction.sqrMagnitude > 0.1f) 74 | this.rb.rotation = Quaternion.LookRotation(direction, Vector3.up); 75 | else 76 | rb.angularVelocity = Vector3.zero; 77 | } 78 | 79 | private Vector3 GetCameraForward(Camera playerCamera) 80 | { 81 | Vector3 forward = playerCamera.transform.forward; 82 | forward.y = 0; 83 | return forward.normalized; 84 | } 85 | 86 | private Vector3 GetCameraRight(Camera playerCamera) 87 | { 88 | Vector3 right = playerCamera.transform.right; 89 | right.y = 0; 90 | return right.normalized; 91 | } 92 | 93 | private void DoJump(InputAction.CallbackContext obj) 94 | { 95 | if(IsGrounded()) 96 | { 97 | forceDirection += Vector3.up * jumpForce; 98 | } 99 | } 100 | 101 | private bool IsGrounded() 102 | { 103 | Ray ray = new Ray(this.transform.position + Vector3.up * 0.25f, Vector3.down); 104 | if (Physics.Raycast(ray, out RaycastHit hit, 0.3f)) 105 | return true; 106 | else 107 | return false; 108 | } 109 | 110 | private void DoAttack(InputAction.CallbackContext obj) 111 | { 112 | animator.SetTrigger("attack"); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /3rd Person Tutorial/ThirdPersonController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aec35f41ca5498742ae9dc44c5b0a2a7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /3rd Person Tutorial/Zombie.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.AI; 5 | 6 | [RequireComponent(typeof(NavMeshAgent))] 7 | [RequireComponent(typeof(AudioSource))] 8 | public class Zombie : MonoBehaviour 9 | { 10 | private Transform player; 11 | private NavMeshAgent navAgent; 12 | private Animator animator; 13 | private Vector3 lastPosition; 14 | private float speed; 15 | 16 | public List zombieSFX; 17 | private AudioSource audioSource; 18 | 19 | // Start is called before the first frame update 20 | void Start() 21 | { 22 | if (player == null) 23 | player = GameObject.FindObjectOfType().transform; 24 | 25 | navAgent = this.GetComponent(); 26 | animator = this.GetComponent(); 27 | audioSource = this.GetComponent(); 28 | 29 | lastPosition = this.transform.position; 30 | navAgent.speed = Random.Range(0.5f, 1.25f); 31 | navAgent.SetDestination(player.position); 32 | 33 | StartCoroutine(PlaySFX()); 34 | } 35 | 36 | // Update is called once per frame 37 | void Update() 38 | { 39 | if (navAgent.remainingDistance < 2f || (this.transform.position - lastPosition).sqrMagnitude > 10f) 40 | navAgent.SetDestination(player.position); 41 | 42 | speed = (this.transform.position - lastPosition).magnitude / Time.deltaTime; 43 | lastPosition = this.transform.position; 44 | 45 | animator.SetFloat("speed", speed); 46 | } 47 | 48 | IEnumerator PlaySFX() 49 | { 50 | if (!audioSource.isPlaying) 51 | { 52 | yield return new WaitForSeconds(Random.Range(1, 3)); 53 | AudioClip clip = zombieSFX[Random.Range(0, zombieSFX.Count)]; 54 | audioSource.PlayOneShot(clip); 55 | StartCoroutine(PlaySFX()); 56 | } 57 | else 58 | { 59 | yield return null; 60 | StartCoroutine(PlaySFX()); 61 | } 62 | } 63 | 64 | public void Die() 65 | { 66 | animator.SetTrigger("dead"); 67 | StopAllCoroutines(); 68 | audioSource.PlayOneShot(zombieSFX[Random.Range(0, zombieSFX.Count)]); 69 | navAgent.isStopped = true; 70 | this.enabled = false; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /3rd Person Tutorial/Zombie.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 947833284687e7d44929daf51e65013d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Coroutines/ChangeValueCoroutine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | [RequireComponent(typeof(Text))] 6 | public class ChangeValueCoroutine : MonoBehaviour 7 | { 8 | [SerializeField] 9 | private Text countText; 10 | 11 | // Start is called before the first frame update 12 | void Start() 13 | { 14 | 15 | 16 | StartCoroutine(DoTimer()); 17 | 18 | } 19 | 20 | private void OnDisable() 21 | { 22 | StopCoroutine(DoTimer()); 23 | } 24 | 25 | IEnumerator DoTimer(float countTime = 1f) 26 | { 27 | int count = 0; 28 | while(true) 29 | { 30 | yield return new WaitForSeconds(countTime); 31 | count++; 32 | countText.text = count.ToString(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Coroutines/ChangeValueCoroutine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b99d35d4fb320245ade5114fd80215f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Coroutines/ChangingValueUpdate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | [RequireComponent(typeof(Text))] 7 | public class ChangingValueUpdate : MonoBehaviour 8 | { 9 | [SerializeField] 10 | private Text countText; 11 | private int count; 12 | private float time; 13 | 14 | // Update is called once per frame 15 | void Update() 16 | { 17 | DoTimer(); 18 | } 19 | 20 | private void DoTimer(float countTime = 1f) 21 | { 22 | time += Time.deltaTime; 23 | if (time >= countTime) 24 | { 25 | count++; 26 | countText.text = count.ToString(); 27 | time = 0; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Coroutines/ChangingValueUpdate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25d9d5f23c386d343bd092a830fd289c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Coroutines/CoroutineTurnOff.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class CoroutineTurnOff : MonoBehaviour 6 | { 7 | 8 | private Coroutine someCoroutine; 9 | 10 | private void OnDisable() 11 | { 12 | //ensure the coroutine stops 13 | //when the component turns off 14 | StopCoroutine(AnnoyingCorountine()); 15 | //or 16 | StopAllCoroutines(); 17 | } 18 | 19 | void Start() 20 | { 21 | 22 | } 23 | 24 | 25 | 26 | IEnumerator AnnoyingCorountine() 27 | { 28 | while(true) 29 | { 30 | Debug.Log("I'm still on!"); 31 | yield return null; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Coroutines/CoroutineTurnOff.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d6a3c930119fd040bc1022d5307009f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Coroutines/GameBoardGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Sirenix.OdinInspector; 5 | 6 | public class GameBoardGenerator : MonoBehaviour 7 | { 8 | [SerializeField] 9 | private GameObject squarePrefab1; 10 | [SerializeField] 11 | private GameObject squarePrefab2; 12 | [SerializeField] 13 | [Range(2,20)] 14 | private int size = 8; 15 | private List boardPieces = new List(); 16 | 17 | // Start is called before the first frame update 18 | void Start() 19 | { 20 | //StartCoroutine(BuildBoard(size)); 21 | } 22 | 23 | [Button] 24 | private void GenerateBoard() 25 | { 26 | ClearBoard(); 27 | StartCoroutine(BuildBoard(size)); 28 | } 29 | 30 | [Button] 31 | private void ClearBoard() 32 | { 33 | foreach (GameObject gameObject in boardPieces) 34 | { 35 | Destroy(gameObject); 36 | } 37 | } 38 | 39 | IEnumerator BuildBoard(int size) 40 | { 41 | for (int i = 0; i < size; i++) 42 | { 43 | for (int j = 0; j < size; j++) 44 | { 45 | if ((i + j) % 2 == 0) 46 | { 47 | GameObject go = Instantiate(squarePrefab1, 48 | new Vector3(i, 0, j), 49 | Quaternion.identity); 50 | boardPieces.Add(go); 51 | go.transform.SetParent(this.transform); 52 | } 53 | else 54 | { 55 | GameObject go = Instantiate(squarePrefab2, 56 | new Vector3(i, 0, j), 57 | Quaternion.identity); 58 | boardPieces.Add(go); 59 | go.transform.SetParent(this.transform); 60 | } 61 | 62 | yield return new WaitForSeconds(0.1f); 63 | } 64 | } 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Coroutines/GameBoardGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 008227449dbb9fa4cbc0d66ddd6e3210 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Coroutines/ImageFill.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using UnityEngine.EventSystems; 6 | 7 | [RequireComponent(typeof(Button))] 8 | public class ImageFill : MonoBehaviour, IPointerDownHandler, IPointerUpHandler 9 | { 10 | private Button button; 11 | [SerializeField] 12 | private Image image; 13 | private bool isOn = true; 14 | private Coroutine currentCoroutine; 15 | 16 | private void OnEnable() 17 | { 18 | button = this.GetComponent