Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ben-Jammin curious-username

🎯
Focusing
View GitHub Profile
View planning.cs
/*
**Laser charging then fire**
Charge for 3, laser lasts 5 seconds after charge is done.
***CHARGING***[need gameobject and script]
Particle Effect > Emission > Rate over Time.
After powerup collection
-Activate charge effect gameobject
-Start at 800 Rate over Time, Distance 0
-Subtract particles for powerup, charge time 3 seconds, Subtract 800 to 0 over 3 seconds
View shieldlife.cs
private int _shieldLife = 3;
[SerializeField]
private GameObject _shield;
private bool _isShieldActive
void Start()
{
_shieldDamage = _shield.GetComponent<SpriteRenderer>();
}
View spawnme.cs
[SerializeField]
private GameObject[] _powerups;
IEnumerator SpawnPowerupRoutine()
{
//every 3 - 7 seconds, spawn in a powerup
while (_stopSpawning == false) {
Vector3 spawn = new Vector3(Random.Range(-8f, 8f), 7, 0);
View playerhealth.cs
private GameObject _rightEngine, _leftEngine;
private int _lives = 3;
public void AddHealth()
{
_powerupSound.Play();
if (_lives < 3)
{
_lives++;
_uiManager.UpdateLives(_lives);
View powerup.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PowerUp : MonoBehaviour
{
[SerializeField]
private float _speed = 3.0f;
[SerializeField]
private int _powerupID;
View thruster.cs
[SerializeField]
private GameObject _thruster;
private float _speed = 5.5f;
void Update()
{
Thrusters();
}
void Thrusters()
View coutdown.cs
private float _countDown = 3;
IEnumerator CountDown()
{
while(_countDown > 0)
{
yield return new WaitForSeconds(1.0f);
_countDown--;
}
_rateOverTimeValue = 0;
@curious-username
curious-username / spawnmanager.cs
Created Oct 14, 2021
updating the spawn manager
View spawnmanager.cs
IEnumerator SpawnPowerupRoutine()
{
//every 3 - 7 seconds, spawn in a powerup
while (_stopSpawning == false) {
Vector3 spawn = new Vector3(Random.Range(-8f, 8f), 7, 0);
int randomPowerUp = Random.Range(0, 4);
Instantiate(_powerups[randomPowerUp], spawn, Quaternion.identity);
yield return new WaitForSeconds(Random.Range(3, 8));
View powerup.cs
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
Player player = other.GetComponent<Player>();
if (player != null)
{
//if powerUp ID is 0
@curious-username
curious-username / uimanager.cs
Last active Oct 14, 2021
text system for space shooter
View uimanager.cs
[SerializeField]
private Text _ammoCount;
void Start()
{
_ammoCount.text = "Ammo: " + 15;
}
public void UpdateAmmoCount(int ammo)
{
_ammoCount.text = "Ammo: " + ammo.ToString();