init
This commit is contained in:
commit
9afd57306d
323 changed files with 204673 additions and 0 deletions
18
Assets/Scripts/Game09/Enemy09.cs
Normal file
18
Assets/Scripts/Game09/Enemy09.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Enemy09 : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
transform.Translate(Vector2.down * speed * Time.deltaTime);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Game09/Enemy09.cs.meta
Normal file
11
Assets/Scripts/Game09/Enemy09.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8bae8006d48aa3247b3fe819ed1c230b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
Assets/Scripts/Game09/Game09.cs
Normal file
53
Assets/Scripts/Game09/Game09.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Game09 : MonoBehaviour{
|
||||
|
||||
public GameObject particles;
|
||||
public GameObject death;
|
||||
public float turnSpeed;
|
||||
int currentRail = -1;
|
||||
public GameObject enemy;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
for (int i = 0; i < 10; i++){
|
||||
int position = Random.Range(-1, 1);
|
||||
if(position == 0){
|
||||
position = 1;
|
||||
}
|
||||
Instantiate(enemy, new Vector2(position, 6 + 5 * i), Quaternion.identity);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (Input.GetKeyDown(KeyCode.Space)){
|
||||
if(currentRail == -1){
|
||||
currentRail = 1;
|
||||
}else if(currentRail == 1){
|
||||
currentRail = -1;
|
||||
}
|
||||
}
|
||||
float fixedSpeed = turnSpeed * Time.deltaTime;
|
||||
transform.position = Vector3.MoveTowards(transform.position, new Vector2(currentRail, transform.position.y), fixedSpeed);
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
particles.SetActive(true);
|
||||
StartCoroutine(Death());
|
||||
GetComponent<SpriteRenderer>().enabled = false;
|
||||
GetComponent<CircleCollider2D>().enabled = false;
|
||||
AudioManager.instance.Play("Hit");
|
||||
}
|
||||
|
||||
IEnumerator Death(){
|
||||
yield return new WaitForSecondsRealtime(1f);
|
||||
Time.timeScale = 0f;
|
||||
death.SetActive(true);
|
||||
death.SetActive(true);
|
||||
yield return new WaitForSecondsRealtime(4f);
|
||||
FindObjectOfType<GameController>().LoseGame();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Game09/Game09.cs.meta
Normal file
11
Assets/Scripts/Game09/Game09.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7cf72d771f42724fad2fb4d4e6144b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue