Skip to content

Instantly share code, notes, and snippets.

View GT3000's full-sized avatar

Anthony Delgado GT3000

View GitHub Profile
@GT3000
GT3000 / Enemy.cs
Created April 18, 2021 06:24
Enemy script where the enemy updates ScoreManager when hit by the player
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
[SerializeField] private int pointsValue = 10; //How many points the enemy is worth
private ScoreManager scoreManager; //A local ScoreManager variable so you can access it later
@GT3000
GT3000 / SpawnManager.cs
Last active April 20, 2021 04:43
Simple enemy spawning coroutine
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnManager : MonoBehaviour
{
[SerializeField] private GameObject enemyPrefab; //Holds our enemy to be spawned
[SerializeField] private int totalEnemiesToSpawn; //How many we'll spawn
private int currentAmountSpawned; //How many have spawned
@GT3000
GT3000 / Coroutine.cs
Last active April 20, 2021 05:14
Structure of a Coroutine
private void Start()
{
//This starts the coroutine and lets Unity know this is a coroutine
StartCoroutine(SpawnEnemies());
}
//IEnumerator is used to denote this a coroutine
private IEnumerator SpawnEnemies()
{
//This will spawn the enemy
@GT3000
GT3000 / SpawnManager.cs
Created April 20, 2021 08:02
Simple script illustrating hierarchy cleanup in a spawn manager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnManager : MonoBehaviour
{
[SerializeField] private GameObject enemyPrefab;
[SerializeField] private int totalEnemiesToSpawn;
private int currentAmountSpawned;
private GameObject enemyContaner; //Holds your shiny new enemy objects
@GT3000
GT3000 / Parallax.cs
Last active April 21, 2021 06:37
A simple scrolling background script
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Ludiq.PeekCore;
using UnityEngine;
using UnityEngine.UI;
using Vector3 = UnityEngine.Vector3;
public class Parallax : MonoBehaviour
{
@GT3000
GT3000 / powerup.cs
Created May 2, 2021 10:30
Basic Power-up System
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum PowerUpType { SpeedBoost, Firepower, Invisibility }
public class PowerUp : MonoBehaviour
{
[SerializeField] private PowerUpType powerUpType;
@GT3000
GT3000 / ScoreManager.cs
Last active May 4, 2021 06:33
Simple Score Manager that tracks current score and updates a text object
public class ScoreManager : MonoBehaviour
{
[SerializeField] private Text scoreText; //Holds the Text object responsible for our score
[SerializeField] private int score; //Tracks how many points we've accumulated so far
// Start is called before the first frame update
void Start()
{
//Sets the score to zero
scoreText.text = "Score: " + score;
@GT3000
GT3000 / UIManager.cs
Created May 6, 2021 01:19
Simple Game Over UI Manager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
[SerializeField] private GameObject gameOverPanel;
[SerializeField] private Text restartText;
@GT3000
GT3000 / LevelManager.cs
Last active May 7, 2021 06:47
Simple Level Manager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour
{
public static LevelManager Instance;
void Awake()
@GT3000
GT3000 / EnemyExplosion.cs
Created May 10, 2021 03:00
Simple enemy explosion script
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class EnemyExplosion : MonoBehaviour
{
[SerializeField] private GameObject explosionPrefab; //Explosion animation prefab
// Start is called before the first frame update