Skip to content

Instantly share code, notes, and snippets.

View curious-username's full-sized avatar

Ben-Jammin curious-username

View GitHub Profile
@curious-username
curious-username / post_null.cs
Created September 16, 2021 05:01
post null
if(_gameOverText != null) {
_gameOverText.gameObject.SetActive(true);
_scoreText.gameObject.SetActive(false);
_gameOverText.text = "Game Over!";
}
@curious-username
curious-username / Enemy.cs
Created September 17, 2021 03:09
enemy script for toaster
public class Enemy : MonoBehaviour
{
private float _speed = 4.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
@curious-username
curious-username / SpawnManager.cs
Created September 17, 2021 03:13
spawn manager for kitty loaf shooter
public class SpawnManager : MonoBehaviour
{
[SerializeField]
private GameObject _enemyPreFab;
private bool _stopSpawning = false;
// Start is called before the first frame update
void Start()
{
StartCoroutine(SpawnEnemy());
}
@curious-username
curious-username / collision.cs
Created September 18, 2021 03:49
rando collision code
if(collision.tag == "Player")
{
if(_player != null)
{
_player.Damage();
}
Destroy(gameObject);
}
@curious-username
curious-username / playerweapon.cs
Created September 18, 2021 04:02
laser death
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Enemy")
{
Destroy(this.gameObject);
}
}
[SerializeField]
private GameObject _shield;
[SerializeField]
private bool _isShieldActive = false;
@curious-username
curious-username / damage_shield.cs
Created September 23, 2021 01:18
logic for handling shield in damage method
if(_isShieldActive == true)
{
if (_shield != null) {
_isShieldActive = false;
_shield.SetActive(false);
}
}
@curious-username
curious-username / shieldactivemethod.cs
Created September 23, 2021 01:29
method to activate the shield on the player
public void ShieldsActive()
{
if(_shield != null) {
_isShieldActive = true;
//enable shield visualize
_shield.SetActive(true);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Shield")
{
Destroy(gameObject);
}
}
@curious-username
curious-username / spawnmanager.cs
Last active September 23, 2021 01:49
spawnmanager power up handling
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnManager : MonoBehaviour
{
[SerializeField]
private GameObject _enemyPrefab;
[SerializeField]
private GameObject _enemyContainer;