Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boss1Controller : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float waitTime = 5f;
[SerializeField] float smoothness = 1f;
[SerializeField] int border = 64;
[SerializeField] GameObject bullet;
[SerializeField] GameObject laserBullet;
[SerializeField] GameObject bulletEffect;
[SerializeField] AudioClip shoot;
[SerializeField] AudioClip shoot2;
[SerializeField] AudioClip laserSound;
int intentX = 0;
int intentY = 0;
bool meandering = false;
AudioSource audioSource;
PLIGameController game;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
game = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<PLIGameController>();
audioSource = game.GetComponent<AudioSource>();
StartCoroutine(PickSomewhere());
StartCoroutine(GoCraCy());
}
IEnumerator PickSomewhere() {
while (true) {
yield return new WaitForSeconds(waitTime);
if (meandering) {
intentX = Random.Range(-256 / 2 + border, 256 / 2 - border);
intentY = Random.Range(64, 96);
}
}
}
IEnumerator GoCraCy() {
// TODO: charge laser
yield return new WaitForSeconds(5.0f);
audioSource.PlayOneShot(laserSound);
// Get blown back
intentY = 100;
for (int i = 0; i < 40; i++) {
float xDelta = 40f;
float yDelta = -40f;
float bulletSpeed = -500f;
for (int _ = 0; _ < 2; _++) {
GameObject b1 = Instantiate(laserBullet);
b1.transform.position = new Vector2(
transform.position.x + xDelta - 6,
transform.position.y + yDelta);
b1.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, bulletSpeed);
GameObject b2 = Instantiate(laserBullet);
b2.transform.position = new Vector2(
transform.position.x + xDelta,
transform.position.y + yDelta + 2);
b2.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, bulletSpeed);
GameObject b3 = Instantiate(laserBullet);
b3.transform.position = new Vector2(
transform.position.x + xDelta + 6,
transform.position.y + yDelta);
b3.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, bulletSpeed);
xDelta *= -1f;
}
yield return new WaitForSeconds(0.06f);
}
yield return new WaitForSeconds(3.0f);
meandering = true;
while (true) {
float bulletsPerRevolution = 15f;
float bulletSpeed = 100f;
int c = 0, d = 0;
float a = 0f;
for (d = 0; d < 8; d++) {
a = -1f * Mathf.PI;
audioSource.PlayOneShot(shoot, 0.3f);
GameObject e1 = Instantiate(bulletEffect);
e1.transform.position = transform.position;
for (c = 0; c < bulletsPerRevolution; c++) {
GameObject b1 = Instantiate(bullet);
b1.transform.position = transform.position;
b1.GetComponent<Rigidbody2D>().velocity = new Vector2(bulletSpeed * Mathf.Cos(a), bulletSpeed * Mathf.Sin(a));
GameObject b2 = Instantiate(bullet);
b2.transform.position = transform.position;
b2.GetComponent<Rigidbody2D>().velocity = new Vector2(
0.5f * bulletSpeed * Mathf.Cos(a + Mathf.PI),
0.5f * bulletSpeed * Mathf.Sin(a + Mathf.PI));
a += Mathf.PI / bulletsPerRevolution;
}
yield return new WaitForSeconds(0.08f);
}
yield return new WaitForSeconds(2f);
c = 0;
a = -1f*Mathf.PI;
bulletsPerRevolution = 10f;
bulletSpeed = 60f;
while (c < 10) {
c++;
audioSource.PlayOneShot(shoot2, 0.3f);
GameObject e1 = Instantiate(bulletEffect);
e1.transform.position = transform.position;
for (int s = 1; s <= 3; s++) {
GameObject b1 = Instantiate(bullet);
b1.transform.position = transform.position;
b1.GetComponent<Rigidbody2D>().velocity = new Vector2(
s * bulletSpeed * Mathf.Cos(a),
s * bulletSpeed * Mathf.Sin(a));
GameObject b2 = Instantiate(bullet);
b2.transform.position = transform.position;
b2.GetComponent<Rigidbody2D>().velocity = new Vector2(
s * bulletSpeed * Mathf.Cos(a + Mathf.PI / 12),
s * bulletSpeed * Mathf.Sin(a + Mathf.PI / 12));
GameObject b3 = Instantiate(bullet);
b3.transform.position = transform.position;
b3.GetComponent<Rigidbody2D>().velocity = new Vector2(
s * bulletSpeed * Mathf.Cos(a - Mathf.PI / 12),
s * bulletSpeed * Mathf.Sin(a - Mathf.PI / 12));
}
a += Mathf.PI / bulletsPerRevolution;
yield return new WaitForSeconds(0.2f);
}
yield return new WaitForSeconds(1.5f);
}
}
// Update is called once per frame
void FixedUpdate() {
Vector2 vel = body.velocity;
Vector2.SmoothDamp(transform.position,
new Vector2(intentX, intentY),
ref vel,
smoothness);
body.velocity = vel;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aab8bfb042b98144387286505065f733
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,88 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boss2Controller : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float waitTime = 8f;
[SerializeField] float smoothness = 20f;
[SerializeField] float maxSpeed = 150f;
[SerializeField] int border = 64;
[SerializeField] GameObject bullet;
float intentX = 0;
float intentY = 0;
AudioSource audioSource;
PLIGameController game;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
game = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<PLIGameController>();
audioSource = game.GetComponent<AudioSource>();
StartCoroutine(PickSomewhere());
StartCoroutine(GoCraCy());
}
IEnumerator PickSomewhere() {
intentX = ((transform.position.x > 0) ? 1 : -1) * 100;
intentY = 0;
yield return new WaitForSeconds(waitTime);
intentX = ((transform.position.x > 0) ? -1 : 1) * 150;
intentY = 100;
yield return new WaitForSeconds(waitTime);
intentX = ((transform.position.x > 0) ? 1 : -1) * 80;
intentY = 50;
yield return new WaitForSeconds(waitTime);
intentX = ((transform.position.x > 0) ? -1 : 1) * 170;
intentY = 0;
yield return new WaitForSeconds(waitTime);
intentX = transform.position.x;
intentY = -300;
yield return new WaitForSeconds(waitTime);
Destroy(gameObject);
}
IEnumerator GoCraCy() {
yield return new WaitForSeconds(5.0f);
while (true) {
float bulletsPerRevolution = 10f;
float bulletSpeed = 40f;
int c = 0;
float a = 0f;
while (c < 15) {
c++;
GameObject b1 = Instantiate(bullet);
b1.transform.position = transform.position;
b1.GetComponent<Rigidbody2D>().velocity = new Vector2(
1.0f * bulletSpeed * Mathf.Cos(a),
1.0f * bulletSpeed * Mathf.Sin(a));
GameObject b2 = Instantiate(bullet);
b2.transform.position = transform.position;
b2.GetComponent<Rigidbody2D>().velocity = new Vector2(
1.5f * bulletSpeed * Mathf.Cos(a + Mathf.PI / 8),
1.5f * bulletSpeed * Mathf.Sin(a + Mathf.PI / 8));
GameObject b3 = Instantiate(bullet);
b3.transform.position = transform.position;
b3.GetComponent<Rigidbody2D>().velocity = new Vector2(
2.0f * bulletSpeed * Mathf.Cos(a - Mathf.PI / 8),
2.0f * bulletSpeed * Mathf.Sin(a - Mathf.PI / 8));
a += 2 * Mathf.PI / bulletsPerRevolution;
yield return new WaitForSeconds(0.05f);
}
yield return new WaitForSeconds(3f);
}
}
// Update is called once per frame
void FixedUpdate() {
Vector2 vel = body.velocity;
Vector2.SmoothDamp(transform.position,
new Vector2(intentX, intentY),
ref vel,
smoothness,
maxSpeed);
body.velocity = vel;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc7b40a6bc454e2448031b842ca46f1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletController : MonoBehaviour {
[SerializeField] GameObject explosion;
[SerializeField] int damage = 1;
[SerializeField] public int speed = 60; // ppf
Rigidbody2D body;
// Start is called before the first frame update
void Start()
{
}
void Die() {
Instantiate(explosion);
explosion.transform.position = transform.position;
Destroy(gameObject);
}
public void InitializeBullet(bool down, float angle = 0) {
body = GetComponent<Rigidbody2D>();
if (down) {
transform.localScale = new Vector2(1.0f, -1.0f);
body.velocity = new Vector2(
-1.0f * speed * Mathf.Sin(angle),
-1.0f * speed * Mathf.Cos(angle));
} else {
body.velocity = new Vector2(
speed * Mathf.Sin(angle),
speed * Mathf.Cos(angle));
}
GetComponent<Rigidbody2D>().SetRotation(angle*-180f/Mathf.PI);
}
private void OnTriggerEnter2D(Collider2D collision) {
if (collision.gameObject.CompareTag("PegLegIoEnemy")) {
collision.gameObject.GetComponent<PegLegIoEnemyController>().Hurt(damage);
Die();
}
}
// Update is called once per frame
void FixedUpdate()
{
if (Mathf.Abs(transform.position.x) > 480 || Mathf.Abs(transform.position.y) > 270) {
Die();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 121a53e6749b90441bf8b812a0445d80
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DyingPlayerController : MonoBehaviour {
[SerializeField] AudioClip die;
[SerializeField] AudioClip boom;
[SerializeField] float deathTime = 1.5f; // seconds
[SerializeField] Color glowColor = Color.red; // seconds
[SerializeField] float glowFrequency = 10f; // per second
[SerializeField] bool glowing = true;
[SerializeField] GameObject explosion;
AudioSource audioSource;
SpriteRenderer sprite;
// Start is called before the first frame update
void Start() {
}
private void Awake() {
audioSource = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<AudioSource>();
sprite = GetComponent<SpriteRenderer>();
audioSource.PlayOneShot(die);
if (glowing) {
StartCoroutine(Glow());
}
StartCoroutine(Die());
}
private IEnumerator Glow() {
while (true) {
sprite.color = glowColor;
yield return new WaitForSeconds(1.0f / glowFrequency);
sprite.color = Color.white;
yield return new WaitForSeconds(1.0f / glowFrequency);
}
}
private IEnumerator Die() {
yield return new WaitForSeconds(deathTime);
audioSource.PlayOneShot(boom);
GameObject e = Instantiate(explosion);
e.transform.position = transform.position;
Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7dd9877e3f09a3b4f8996f2307782070
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyBulletController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void LateUpdate() {
if (Mathf.Abs(transform.position.x) > 480 || Mathf.Abs(transform.position.y) > 270) {
Destroy(gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c2608385258b0804d91cc7ec1b726fe8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController_Bubble : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float diff = 10.0f;
[SerializeField] float jumpSpeed = 200f;
[SerializeField] float runSpeed = 100f;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
if (Random.Range(0.0f, 1.0f) > 0.5) {
body.velocity = new Vector2(
Random.Range(-1.0f, 1.0f) * runSpeed,
Random.Range(-1.0f, 1.0f) * runSpeed);
}
}
// Update is called once per frame
void FixedUpdate() {
body.velocity = new Vector2(
Mathf.Clamp(body.velocity.x, -1*jumpSpeed, jumpSpeed),
Mathf.Clamp(body.velocity.y, -1 * jumpSpeed, jumpSpeed));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5acfef45612779c49980365aeeff049f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController_Dummy : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float waitTime = 5f;
[SerializeField] float smoothness = 1f;
[SerializeField] int border = 64;
[SerializeField] GameObject bullet;
float intentX = 0;
float intentY = 0;
AudioSource audioSource;
PLIGameController game;
bool slow = false;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
game = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<PLIGameController>();
audioSource = game.GetComponent<AudioSource>();
StartCoroutine(PickSomewhere());
StartCoroutine(GoCraCy());
}
IEnumerator PickSomewhere() {
for (int i = 0; i < 5; i++) {
intentX = ((transform.position.x > 0) ? 1 : -1) * Random.Range(0f, 170f);
intentY = Random.Range(0f, 100f);
yield return new WaitForSeconds(waitTime);
}
slow = true;
intentX = transform.position.x;
intentY = -300;
yield return new WaitForSeconds(waitTime);
Destroy(gameObject);
}
IEnumerator GoCraCy() {
yield return new WaitForSeconds(3.0f);
while (true) {
float bulletsPerRevolution = 15f;
float bulletSpeed = 100f;
int c = 0;
float a = 0f;
while (c < 30) {
c++;
GameObject b1 = Instantiate(bullet);
b1.transform.position = transform.position;
b1.GetComponent<Rigidbody2D>().velocity = new Vector2(
bulletSpeed * Mathf.Cos(a),
bulletSpeed * Mathf.Sin(a));
a += 2 * Mathf.PI / bulletsPerRevolution;
yield return new WaitForSeconds(0.01f);
}
yield return new WaitForSeconds(5f);
}
}
// Update is called once per frame
void FixedUpdate() {
Vector2 vel = body.velocity;
Vector2.SmoothDamp(transform.position,
new Vector2(intentX, intentY),
ref vel,
(slow?5:smoothness));
body.velocity = vel;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03402fb3d9851cb49b7d23d1e2bc435f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController_Jumper : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float diff = 10.0f;
[SerializeField] float jumpSpeed = 200f;
[SerializeField] float runSpeed = 10f;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
StartCoroutine(PickSomewhere());
}
IEnumerator PickSomewhere() {
while (true) {
yield return new WaitForSeconds(100.0f / diff);
if (Random.Range(0.0f, 1.0f) > 0.5) {
body.velocity = new Vector2(Random.Range(-1.0f, 1.0f) * runSpeed, body.velocity.y);
}
}
}
// Update is called once per frame
void FixedUpdate() {
body.velocity = new Vector2(body.velocity.x, Mathf.Clamp(body.velocity.y, -1*jumpSpeed, jumpSpeed));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd8f8a9d753c9f34daf1805407606091
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController_Shooter : MonoBehaviour {
[SerializeField] Rigidbody2D body;
[SerializeField] float diff = 20.0f;
[SerializeField] float minSpeed = 20f;
[SerializeField] float maxSpeed = 100f;
// Start is called before the first frame update
void Start() {
body = GetComponent<Rigidbody2D>();
if (transform.position.x < 0) {
body.velocity = new Vector2(Random.Range(minSpeed, maxSpeed), 0);
} else {
body.velocity = new Vector2(-1.0f*Random.Range(minSpeed, maxSpeed), 0);
}
}
private void FixedUpdate() {
if (Mathf.Abs(transform.position.x) > 480) {
Destroy(gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fdc7188c4eaab8c40b75f54713fdd87d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController_Stupid : MonoBehaviour
{
[SerializeField] Rigidbody2D body;
[SerializeField] float diff = 10.0f;
[SerializeField] float smoothness = 2f;
[SerializeField] int border = 32;
int intentX = 0;
int intentY = 0;
// Start is called before the first frame update
void Start()
{
body = GetComponent<Rigidbody2D>();
StartCoroutine(PickSomewhere());
}
IEnumerator PickSomewhere() {
while (true) {
intentX = Random.Range(-480/2 + border, 480/2 - border);
intentY = Random.Range(-270/2 + border, 270/2 - border);
yield return new WaitForSeconds(100.0f / diff);
}
}
// Update is called once per frame
void FixedUpdate()
{
Vector2 vel = body.velocity;
Vector2.SmoothDamp(transform.position,
new Vector2(intentX, intentY),
ref vel,
smoothness);
body.velocity = vel;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 22710a656ca670a41b6584192d2a7055
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExplodingPlayerController : MonoBehaviour {
[SerializeField] private float ttl = 2f; // seconds
[SerializeField] private float flash = 0.1f; // seconds
// Start is called before the first frame update
void Start() {
Invoke("SpriteOff", flash);
Invoke("Die", ttl);
}
void SpriteOff() {
GetComponent<SpriteRenderer>().color = Color.clear;
}
void Die() {
Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 657ae82155143a341985c1d30a43a69d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExplosionController : MonoBehaviour
{
[SerializeField] private float ttl = 0.25f; // seconds
// Start is called before the first frame update
void Start()
{
Invoke("Die", ttl);
}
void Die() {
Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: abb53411786b9234ea275e4dcf53d203
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,279 @@
using Com.LuisPedroFonseca.ProCamera2D;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PLIGameController : MonoBehaviour
{
[SerializeField] public int score = 0;
[SerializeField] int level = 1;
[SerializeField] int lives = 3;
[SerializeField] public int power = 0;
[SerializeField] int extraLifePoints = 50000;
[SerializeField] int bonusBase = 1000;
[SerializeField] List<GameObject> enemyWave1;
[SerializeField] List<GameObject> enemyWave2;
[SerializeField] List<GameObject> bosses;
[SerializeField] float deathWaitTime = 5f; // seconds
[SerializeField] AudioClip startLevelClip;
[SerializeField] AudioClip endLevelClip;
[SerializeField] AudioClip ohBabyClip;
[SerializeField] AudioClip ohYeahClip;
[SerializeField] AudioClip extraLifeClip;
[SerializeField] GameObject lifeCounter;
[SerializeField] GameObject lifeIcon;
[SerializeField] TMPro.TextMeshProUGUI scoreTMPro;
[SerializeField] TMPro.TextMeshProUGUI levelTMPro;
[SerializeField] TMPro.TextMeshProUGUI currentLevelTMPro;
[SerializeField] ParticleSystem particles;
[SerializeField] AudioSource music;
[SerializeField] AudioClip bossSong;
[SerializeField] List<AudioClip> songs;
[SerializeField] GameObject player;
AudioSource audioSource;
ProCamera2DShake cameraShaker;
int enemyCount = 0;
int border = 32;
int wavelength = 10;
// todo: implement
int[] nlp = {
25000,
50000,
100000,
250000,
500000,
1000000,
1500000,
2000000,
3000000,
4500000,
6000000,
7500000,
10000000
};
int nextLifePoints;
// Start is called before the first frame update
void Start() {
cameraShaker = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<ProCamera2DShake>();
audioSource = GetComponent<AudioSource>();
nextLifePoints = extraLifePoints;
StartCoroutine(StartTestLevelLogic());
for (int i = 0; i < lives; i++) {
GameObject l = Instantiate(lifeIcon);
l.transform.SetParent(lifeCounter.transform);
}
}
public void ShakeCamera() {
cameraShaker.Shake(1);
}
void CycleMusic() {
if (level%5 == 0 || level%wavelength == 1 || !music.isPlaying) {
music.Stop();
if (level%wavelength == 0) {
music.clip = bossSong;
} else {
music.clip = songs[(level / 5) % songs.Count];
}
music.loop = true;
music.Play();
}
}
public void Score(int points) {
score += points;
if (score >= nextLifePoints) {
nextLifePoints += extraLifePoints;
lives += 1;
GameObject l = Instantiate(lifeIcon);
l.transform.SetParent(lifeCounter.transform);
audioSource.PlayOneShot(extraLifeClip);
}
}
IEnumerator StartTestLevelLogic() {
var main = particles.main;
while (true) {
power = Mathf.Max(0, (level - 1) / wavelength);
yield return new WaitForSeconds(3.0f);
CycleMusic();
main.simulationSpeed = 5;
// TODO: Show level text
Debug.Log("Level " + level.ToString());
audioSource.PlayOneShot(startLevelClip);
levelTMPro.SetText("Level " + level.ToString());
yield return new WaitForSeconds(3.0f);
main.simulationSpeed = 1;
levelTMPro.SetText("");
enemyCount = 0;
if (level == wavelength) {
// Spawn a boss!
SpawnBoss();
} else if (level == 2*wavelength) {
bool left = true;
while (enemyCount < 5) {
enemyCount++;
SpawnBoss2(left);
left = !left;
yield return new WaitForSeconds(10.0f);
}
} else if (level < wavelength) {
// Spawn a bunch of enemies
while (enemyCount < 5 + level * 4) {
enemyCount += 1;
SpawnWave1();
yield return new WaitForSeconds(20.0f / (level + 10));
}
} else if (level < 2*wavelength) {
while (enemyCount < 5 + (level) * 4) {
enemyCount += 1;
SpawnWave2();
yield return new WaitForSeconds(20.0f / (level + 12));
}
}
// Check every 2 seconds to make sure all enemies are dead
while (GameObject.FindGameObjectsWithTag("PegLegIoEnemy").Length > 0) {
yield return new WaitForSeconds(2.0f);
}
audioSource.PlayOneShot(endLevelClip);
levelTMPro.SetText("Level Complete");
yield return new WaitForSeconds(3.0f);
int bonus = lives * bonusBase;
if (bonus >= 10000) {
audioSource.PlayOneShot(ohBabyClip);
} else {
audioSource.PlayOneShot(endLevelClip);
}
levelTMPro.SetText("Bonus\n" + bonus.ToString());
Score(bonus);
yield return new WaitForSeconds(3.0f);
if (level >= 2*wavelength) {
levelTMPro.SetText("Mission Complete");
break;
}
if (level%wavelength == 0) {
audioSource.PlayOneShot(ohYeahClip);
levelTMPro.SetText("Power Up");
yield return new WaitForSeconds(3.0f);
}
levelTMPro.SetText("");
level += 1;
}
}
void SpawnBoss() {
GameObject b = Instantiate(bosses[0]);
b.transform.position = new Vector2(0.0f, 180f);
}
void SpawnBoss2(bool left) {
GameObject b = Instantiate(bosses[1]);
b.transform.position = new Vector2(((left)?-1:1) * 320.0f, 100f);
}
void SpawnWave1() {
int choice = (enemyCount % enemyWave1.Count) % (level / 3 + 1);
if (choice == 1) {
GameObject e = Instantiate(enemyWave1[1]);
e.transform.position = new Vector2(
Random.Range(-180f, 180f),
150f);
} else if (choice == 2) {
GameObject e = Instantiate(enemyWave1[2]);
e.transform.position = new Vector2(
Random.Range(-180f, 180f),
50f);
} else if (choice == 3) {
GameObject e = Instantiate(enemyWave1[3]);
if (Random.Range(0.0f, 1.0f) > 0.5f) {
e.transform.position = new Vector2(-480 / 2 - 24, Random.Range(0, 100));
} else {
e.transform.position = new Vector2(480 / 2 + 24, Random.Range(0, 100));
}
} else {
GameObject e = Instantiate(enemyWave1[0]);
if (Random.Range(0.0f, 1.0f) > 0.5f) {
e.transform.position = new Vector2(-480 / 2 - 24,
Random.Range(-270 / 4 + border, 270 / 2 - border));
} else {
e.transform.position = new Vector2(480 / 2 + 24,
Random.Range(-270 / 4 + border, 270 / 2 - border));
}
}
}
void SpawnWave2() {
int choice;
if (enemyCount % (25 - level) == 0) {
// Spawn Dummies sometimes, more often at higher levels
choice = 0;
} else if (level > 3*wavelength-3 && enemyCount % 5 == 0) {
// Spawn Shooters often at higher levels
choice = 3;
} else {
// Pick between jumpers and bubbles
choice = 1 + (enemyCount % 2);
}
if (choice == 1) {
GameObject e = Instantiate(enemyWave2[1]);
e.transform.position = new Vector2(
Random.Range(-180f, 180f),
150f);
} else if (choice == 2) {
GameObject e = Instantiate(enemyWave2[2]);
e.transform.position = new Vector2(
Random.Range(-180f, 180f),
50f);
} else if (choice == 3) {
GameObject e = Instantiate(enemyWave2[3]);
if (Random.Range(0.0f, 1.0f) > 0.5f) {
e.transform.position = new Vector2(-480 / 2 - 24, Random.Range(0, 100));
} else {
e.transform.position = new Vector2(480 / 2 + 24, Random.Range(0, 100));
}
} else {
GameObject e = Instantiate(enemyWave2[0]);
if (Random.Range(0.0f, 1.0f) > 0.5f) {
e.transform.position = new Vector2(-480 / 2 - 24,
Random.Range(-270 / 4 + border, 270 / 2 - border));
} else {
e.transform.position = new Vector2(480 / 2 + 24,
Random.Range(-270 / 4 + border, 270 / 2 - border));
}
}
}
public IEnumerator PlayerDie() {
lives -= 1;
Destroy(lifeCounter.transform.GetChild(0).gameObject);
yield return new WaitForSeconds(deathWaitTime);
if (lives > 0) {
GameObject p = Instantiate(player);
p.transform.position = new Vector2(0f, -180f);
} else {
levelTMPro.SetText("Game Over!");
Debug.Log("Game Over!");
// TODO: Scoreboard
}
}
// Update is called once per frame
void LateUpdate()
{
scoreTMPro.SetText(score.ToString());
currentLevelTMPro.SetText(level.ToString());
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f9d11a0c201b4c4db5329f603a4fdad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,237 @@
using Com.LuisPedroFonseca.ProCamera2D;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class PegLegIoController : MonoBehaviour {
[SerializeField] float xSpeed = 100f;
[SerializeField] float ySpeed = 100f;
[SerializeField] AudioClip spawn;
[SerializeField] AudioClip turn;
[SerializeField] AudioClip pew;
[SerializeField] AudioClip ouch;
[SerializeField] Sprite center;
[SerializeField] Sprite left;
[SerializeField] Sprite right;
[SerializeField] GameObject bullet1;
[SerializeField] GameObject bullet2;
[SerializeField] List<GameObject> bullets;
[SerializeField] GameObject deathObject;
[SerializeField] List<float> fireSpeeds; // per second
[SerializeField] float hurtTime = 1.5f; // seconds
[SerializeField] int bulletOffset = 8; // pixels
[SerializeField] float smoothness = 0.2f; // seconds to converge to mouse position
[SerializeField] float invincibleTime = 2f; // seconds
[SerializeField] int health = 1;
[SerializeField] Vector2 spawnPoint;
[SerializeField] float spawnTime = 1f; // seconds
Material material;
AudioSource audioSource;
Rigidbody2D body;
PLIGameController game;
SpriteRenderer sprite;
SpriteRenderer poomSprite;
bool isFiring = false;
bool isHurting = false;
bool wantFire = false;
bool invincible = false;
bool isFacingDown = false;
bool isSpawning = true;
int border = 32;
int w = 256;
int h = 256;
// Start is called before the first frame update
void Start() {
game = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<PLIGameController>();
material = GetComponent<Renderer>().material;
audioSource = game.GetComponent<AudioSource>();
body = GetComponent<Rigidbody2D>();
sprite = GetComponent<SpriteRenderer>();
poomSprite = transform.GetChild(0).GetComponent<SpriteRenderer>();
invincible = true;
Invoke("InvincibleOff", invincibleTime);
Invoke("SpawnOff", spawnTime);
audioSource.PlayOneShot(spawn);
poomSprite.color = Color.clear;
}
void SpawnOff() {
isSpawning = false;
}
void InvincibleOff() {
invincible = false;
}
Vector2 Clamp(Vector2 v) {
return new Vector2(
Mathf.Clamp(v.x, -1 * w / 2 + border, w / 2 - border),
Mathf.Clamp(v.y, -1 * h / 2 + border, h / 2 - border));
}
private void SpawnBullet(GameObject proto, Vector2 delta,
float angle = 0) {
GameObject bullet = Instantiate(proto);
bullet.transform.position = new Vector2(
transform.position.x + delta.x,
transform.position.y + delta.y);
bullet.GetComponent<BulletController>().InitializeBullet(isFacingDown, angle);
}
IEnumerator Poom() {
poomSprite.color = new Color(1f, 1f, 1f, 0.5f);
yield return new WaitForSeconds(0.05f);
poomSprite.color = Color.clear;
}
IEnumerator FirePattern1() {
const float yDeltaFar = 12f;
const float xDeltaFar = 4f;
const float yDeltaPoom = 4f;
const float xDeltaFPoom = 10f;
audioSource.PlayOneShot(pew);
StartCoroutine(Poom());
SpawnBullet(bullet2, new Vector2(xDeltaFar, yDeltaFar));
SpawnBullet(bullet2, new Vector2(-1f*xDeltaFar, yDeltaFar));
SpawnBullet(bullet1, new Vector2(xDeltaFPoom, yDeltaPoom),
Mathf.PI / 128f);
SpawnBullet(bullet1, new Vector2(-1f*xDeltaFPoom, yDeltaPoom),
-1f * Mathf.PI / 128f);
yield return new WaitForSeconds(0.1f);
StartCoroutine(Poom());
SpawnBullet(bullet1, new Vector2(xDeltaFPoom, yDeltaPoom),
Mathf.PI / 64f);
SpawnBullet(bullet1, new Vector2(-1f*xDeltaFPoom, yDeltaPoom),
- 1f * Mathf.PI / 64f);
yield return new WaitForSeconds(0.1f);
StartCoroutine(Poom());
SpawnBullet(bullet1, new Vector2(xDeltaFPoom, yDeltaPoom),
Mathf.PI / 32f);
SpawnBullet(bullet1, new Vector2(-1f*xDeltaFPoom, yDeltaPoom),
-1f * Mathf.PI / 32f);
yield return new WaitForSeconds(0.1f);
isFiring = false;
}
IEnumerator Hurt() {
if (!isHurting) {
if (!invincible) {
health -= 1;
}
Debug.Log("OUCH!");
if (health < 1) {
game.StartCoroutine(game.PlayerDie());
Die();
} else {
isHurting = true;
material.EnableKeyword("GLITCH_ON");
material.EnableKeyword("FLICKER_ON");
audioSource.PlayOneShot(ouch);
yield return new WaitForSeconds(hurtTime);
isHurting = false;
material.DisableKeyword("GLITCH_ON");
material.DisableKeyword("FLICKER_ON");
}
}
}
void Die() {
Debug.Log("What a world...!");
GameObject e = Instantiate(deathObject);
e.transform.position = transform.position;
e.GetComponent<Rigidbody2D>().velocity = body.velocity;
game.ShakeCamera();
Destroy(gameObject);
}
private void OnTriggerEnter2D(Collider2D collision) {
if (collision.gameObject.CompareTag("PegLegIoEnemy")) {
collision.gameObject.GetComponent<PegLegIoEnemyController>().Hurt(2, true);
StartCoroutine(Hurt());
}
if (collision.gameObject.CompareTag("PegLegIoBullet")) {
Destroy(collision.gameObject);
StartCoroutine(Hurt());
}
}
// Update is called once per frame
void Update() {
if (!isSpawning) {
if (!wantFire && Input.GetKeyDown(KeyCode.Z)) {
wantFire = true;
}
if (!isFiring && wantFire) {
isFiring = true;
wantFire = false;
StartCoroutine(FirePattern1());
}
float vX = 0, vY = 0;
if (Input.GetKey(KeyCode.LeftArrow)) {
vX -= xSpeed;
}
if (Input.GetKey(KeyCode.RightArrow)) {
vX += ySpeed;
}
if (Input.GetKey(KeyCode.DownArrow)) {
vY -= ySpeed;
}
if (Input.GetKey(KeyCode.UpArrow)) {
vY += ySpeed;
}
body.velocity = new Vector2(vX, vY);
if (vX < -0.1f) sprite.sprite = left;
else if (vX > 0.1f) sprite.sprite = right;
else sprite.sprite = center;
// DEBUG
if (Input.GetMouseButtonDown(2)) {
StartCoroutine(Hurt());
}
if (Input.GetMouseButtonDown(1)) {
isFacingDown = !isFacingDown;
audioSource.PlayOneShot(turn);
transform.localScale = new Vector2(1.0f, -1 * transform.localScale.y);
}
}
}
private void FixedUpdate() {
if (isSpawning) {
Vector2 vel = body.velocity;
Vector2.SmoothDamp(transform.position, Clamp(spawnPoint), ref vel, smoothness);
body.velocity = vel;
} else {
transform.position = Clamp(transform.position);
}
if (health > 1 || invincible) {
material.EnableKeyword("HOLOGRAM_ON");
} else {
material.DisableKeyword("HOLOGRAM_ON");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0bc6cdedfee9e2847a7e07b4d70b103b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PegLegIoEnemyController : MonoBehaviour {
[SerializeField] AudioClip ouch;
[SerializeField] int health = 5;
[SerializeField] float hurtTime = 0.5f;
[SerializeField] int points = 100;
[SerializeField] int hitPoints = 10;
[SerializeField] int healthBlinkThreshold = 0;
[SerializeField] int healthGlitterThreshold = 0;
[SerializeField] GameObject deathExplosion;
[SerializeField] GameObject scoreObject;
Animator animator;
AudioSource audioSource;
PLIGameController game;
SpriteRenderer spriteRenderer;
bool isHurting = false;
bool isAnimated = true;
// Start is called before the first frame update
void Start()
{
game = GameObject.FindGameObjectWithTag("PegLegIoGame").GetComponent<PLIGameController>();
animator = GetComponent<Animator>();
audioSource = game.GetComponent<AudioSource>();
spriteRenderer = GetComponent<SpriteRenderer>();
StartCoroutine(Blink());
if (animator == null || !animator.isActiveAndEnabled) isAnimated = false;
}
public void Hurt(int damage, bool overrideIFrame = false) {
StartCoroutine(HurtCoroutine(damage, overrideIFrame));
}
IEnumerator OneBlink() {
spriteRenderer.color = Color.red;
yield return new WaitForSeconds(0.05f);
spriteRenderer.color = Color.white;
}
IEnumerator Blink() {
int blinkCounter = 0;
const int maxBlink = 2; // divisor for super-fast blink speed
while (true) {
if (health < healthBlinkThreshold) {
blinkCounter = (blinkCounter + 1) % maxBlink;
if (health < healthGlitterThreshold
|| blinkCounter == 0) {
StartCoroutine(OneBlink());
}
}
yield return new WaitForSeconds(0.2f);
}
}
public IEnumerator HurtCoroutine(int damage, bool overrideIFrame) {
if (!isHurting || overrideIFrame) {
audioSource.PlayOneShot(ouch);
if (isAnimated) animator.SetBool("isHurting", true);
health -= damage;
game.Score(hitPoints);
if (health < 1) {
Die();
} else {
isHurting = true;
yield return new WaitForSeconds(hurtTime);
isHurting = false;
if (isAnimated) animator.SetBool("isHurting", false);
}
}
}
void Die() {
GameObject e = Instantiate(deathExplosion);
GameObject s = Instantiate(scoreObject);
e.transform.position = transform.position;
s.transform.position = transform.position;
s.GetComponent<TMPro.TextMeshPro>().SetText(points.ToString());
Destroy(gameObject);
game.Score(points);
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3bfe02cef665ffd49b0ca3a4ede8e29c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScoreTextController : MonoBehaviour
{
[SerializeField] float deathTime = 1.0f; // seconds
// Start is called before the first frame update
void Start()
{
Invoke("Die", deathTime);
}
void Die() {
Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45cad408abc65d54eb3e1eaaa23291b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: