init
This commit is contained in:
commit
9afd57306d
323 changed files with 204673 additions and 0 deletions
58
Assets/Scripts/Game13/Game13Bullet.cs
Normal file
58
Assets/Scripts/Game13/Game13Bullet.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Game13Bullet : MonoBehaviour{
|
||||
|
||||
public GameObject death;
|
||||
public GameObject deathParticles;
|
||||
public GameObject killParticles;
|
||||
public float speed;
|
||||
bool canMove;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (canMove){
|
||||
transform.Translate(Vector2.left * speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space) && !canMove){
|
||||
AudioManager.instance.Play("Shoot");
|
||||
canMove = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
if(col.gameObject.tag == "Finish"){
|
||||
GetComponent<SpriteRenderer>().enabled = false;
|
||||
deathParticles.SetActive(true);
|
||||
Time.timeScale = 0;
|
||||
StartCoroutine(Death());
|
||||
AudioManager.instance.Play("Explosion");
|
||||
}else{
|
||||
col.gameObject.SetActive(false);
|
||||
killParticles.transform.position = col.transform.position;
|
||||
killParticles.SetActive(true);
|
||||
StartCoroutine(Win());
|
||||
Time.timeScale = 0;
|
||||
AudioManager.instance.Play("Explosion");
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Win(){
|
||||
yield return new WaitForSecondsRealtime(1f);
|
||||
FindObjectOfType<GameController>().CompleteLevel();
|
||||
}
|
||||
|
||||
IEnumerator Death(){
|
||||
yield return new WaitForSecondsRealtime(1f);
|
||||
death.SetActive(true);
|
||||
yield return new WaitForSecondsRealtime(4f);
|
||||
FindObjectOfType<GameController>().LoseGame();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue