Smoothed out a few things

This commit is contained in:
2018-04-23 10:12:50 +10:00
parent 47713e6012
commit cdfb834285
16 changed files with 465 additions and 88 deletions
+1 -3
View File
@@ -3,8 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour {
Animator animator;
Animator animator;
Rigidbody2D rigidBody;
public float timer;
@@ -16,7 +15,6 @@ public class Bomb : MonoBehaviour {
public Respawner respawner; //this can be respawned
float birthTime;
void Awake() {
animator = GetComponent<Animator> ();
+8 -14
View File
@@ -3,21 +3,15 @@ using System.Collections.Generic;
using UnityEngine;
public class ExplosionSoundManager : MonoBehaviour {
AudioSource asrc;
static AudioSource asrc;
// Use this for initialization
void Awake () {
if (asrc == null)
{
asrc = GetComponent<AudioSource>();
asrc.Play();
}
}
void LateUpdate () {
asrc = null;
asrc = GetComponent<AudioSource>();
//only play the explosion sound if the player is close enough to hear it
Vector3 playerPos = GameObject.Find ("Player").transform.position;
if (Vector3.Distance(transform.position, playerPos) <= 1) {
asrc.Play();
}
}
}
+29
View File
@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lollipop : MonoBehaviour {
Animator animator;
public float timeTillWave = 10;
float timeAccumulated;
void Awake () {
animator = GetComponent<Animator>();
timeAccumulated = Random.Range(0, timeTillWave);
}
void Update () {
timeAccumulated += Time.deltaTime;
if (timeAccumulated >= timeTillWave) {
if (Random.Range(0, 2) == 0) {
animator.SetTrigger("SayHi");
}
timeAccumulated = 0;
}
}
void OnTriggerEnter2D(Collider2D collider) {
//TODO: begin the end screen process
}
}
-29
View File
@@ -1,29 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LollipopSaysHi : MonoBehaviour {
float timeAccumulated;
public float timeTillWave = 10;
// Use this for initialization
Animator a;
void Start () {
timeAccumulated = Random.Range(0, timeTillWave);
a = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
timeAccumulated += Time.deltaTime;
if (timeAccumulated >= timeTillWave)
{
if (Random.Range(0, 2) == 0)
{
a.SetTrigger("SayHi");
}
timeAccumulated = 0;
}
}
}
+9 -10
View File
@@ -21,15 +21,14 @@ public class Player : MonoBehaviour {
public GameObject icePelletPrefab;
public GameObject windPelletPrefab;
AudioSource aSource;
public AudioClip fireClip, iceClip, windClip, switchClip;
AudioSource aSource;
public AudioClip fireClip, iceClip, windClip, switchClip;
void Awake() {
animator = GetComponent<Animator> ();
rigidBody = GetComponent<Rigidbody2D> ();
witchAnimateScript = GetComponent<witchAnimate> ();
aSource = GetComponent<AudioSource>();
aSource = GetComponent<AudioSource>();
speed = 0.79f;
}
@@ -55,7 +54,7 @@ public class Player : MonoBehaviour {
lastDirection = rigidBody.velocity;
}
if (Input.GetButtonDown("Switch")) aSource.PlayOneShot(switchClip);
if (Input.GetButtonDown("Switch")) aSource.PlayOneShot(switchClip);
}
void Move() {
@@ -72,16 +71,16 @@ public class Player : MonoBehaviour {
switch (witchAnimateScript.el) {
case witchAnimate.Element.fire:
aSource.PlayOneShot(fireClip);
aSource.PlayOneShot(fireClip);
pellet = Instantiate (firePelletPrefab);
break;
case witchAnimate.Element.ice:
aSource.PlayOneShot(iceClip);
pellet = Instantiate (icePelletPrefab);
aSource.PlayOneShot(iceClip);
pellet = Instantiate (icePelletPrefab);
break;
case witchAnimate.Element.wind:
aSource.PlayOneShot(windClip);
pellet = Instantiate (windPelletPrefab);
aSource.PlayOneShot(windClip);
pellet = Instantiate (windPelletPrefab);
break;
}
+6 -6
View File
@@ -10,12 +10,12 @@ public class PressurePlate : MonoBehaviour {
GameObject presser;
AudioSource asrc;
public AudioClip sound;
AudioSource asrc;
public AudioClip sound;
void Awake() {
spriteRenderer = GetComponent<SpriteRenderer> ();
asrc = GetComponent<AudioSource>();
asrc = GetComponent<AudioSource>();
}
void OnTriggerEnter2D(Collider2D collider) {
@@ -26,7 +26,7 @@ public class PressurePlate : MonoBehaviour {
presser = go;
pressed = true;
SwitchSprite ();
asrc.PlayOneShot(sound);
asrc.PlayOneShot(sound);
}
}
}
@@ -36,8 +36,8 @@ public class PressurePlate : MonoBehaviour {
presser = null;
pressed = false;
SwitchSprite ();
asrc.PlayOneShot(sound);
}
asrc.PlayOneShot(sound);
}
}
void SwitchSprite() {