TO SQUASH: Added yummies.
This commit is contained in:
@@ -80,5 +80,4 @@ public class BasicBall : BallBase
|
||||
speed = Vector2.Reflect(speed, contact.normal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class Player : MonoBehaviour
|
||||
|
||||
public int laserCount = 0;
|
||||
|
||||
public float barPower = 0f;
|
||||
|
||||
public GameObject magnetLeft;
|
||||
|
||||
public GameObject magnetRight;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d48f712735a2398ecbb68bf1dba4ba11
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CakeSpawner : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fca49826eed1e6b2eb4be6ccac32574f
|
||||
@@ -0,0 +1,94 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class YummyBase : MonoBehaviour
|
||||
{
|
||||
public AudioClip bounceSound;
|
||||
|
||||
public AudioClip obtainedSound;
|
||||
|
||||
public AudioClip missedSound;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private Animator animator;
|
||||
|
||||
private SpriteRenderer spriteRenderer;
|
||||
|
||||
private Vector2 speed;
|
||||
|
||||
private bool isObtained = false;
|
||||
|
||||
private float missedTimer = 0f;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
speed = new Vector2(Random.Range(-0.05f, 0.05f), Random.Range(-0.05f, 0.05f)).normalized * 0.05f;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (isObtained)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
transform.Translate(speed);
|
||||
|
||||
missedTimer += Time.fixedDeltaTime;
|
||||
|
||||
if (missedTimer >= 5f)
|
||||
{
|
||||
audioSource.PlayOneShot(missedSound);
|
||||
animator.SetTrigger("missed");
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (isObtained)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(other.gameObject.CompareTag("Bar"))
|
||||
{
|
||||
audioSource.PlayOneShot(obtainedSound);
|
||||
|
||||
var player = GameObject.FindGameObjectWithTag("Player");
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ObtainedCallback(player.GetComponent<Player>());
|
||||
}
|
||||
|
||||
isObtained = true;
|
||||
spriteRenderer.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Wall"))
|
||||
{
|
||||
ContactPoint2D contact = collision.GetContact(0);
|
||||
speed = Vector2.Reflect(speed, contact.normal);
|
||||
audioSource.PlayOneShot(bounceSound);
|
||||
}
|
||||
else
|
||||
{
|
||||
Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public void DestroyYummy()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
protected abstract void ObtainedCallback(Player player);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f866185e9ba9e7046973036d982cb183
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class YummyCake : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1946b527c8b37475beebe4e5bfc084a
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class YummyKey : YummyBase
|
||||
{
|
||||
protected override void ObtainedCallback(Player player)
|
||||
{
|
||||
player.lives += 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 129b890d57f56973ba30a1e3c6d39d37
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class YummyLaser : YummyBase
|
||||
{
|
||||
protected override void ObtainedCallback(Player player)
|
||||
{
|
||||
player.laserCount += 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed4184b81a11f783196c7f906c5ba3a7
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class YummyLightningBolt : YummyBase
|
||||
{
|
||||
protected override void ObtainedCallback(Player player)
|
||||
{
|
||||
player.barPower += 0.1f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db7fbe2925d76d339923dc4ef26d667c
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class YummyMagnet : YummyBase
|
||||
{
|
||||
protected override void ObtainedCallback(Player player)
|
||||
{
|
||||
player.magnetCount += 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0791d43c08a120d94aba7064ba6f2175
|
||||
Reference in New Issue
Block a user