This commit is contained in:
Gerard Gascón 2025-04-24 14:20:42 +02:00
commit 9afd57306d
323 changed files with 204673 additions and 0 deletions

View 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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8bae8006d48aa3247b3fe819ed1c230b
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 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();
}
}

View file

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