This commit is contained in:
Gerard Gascón 2025-04-24 14:23:29 +02:00
commit bd5b1556ff
269 changed files with 6249829 additions and 0 deletions

View file

@ -0,0 +1,131 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Dragon : MonoBehaviour{
public GameObject colliderStop;
public GameObject[] diable;
public GameObject[] phase2Enable;
public GameObject[] phase3Enable;
public Vector2[] phasesPositions;
public GameObject fire;
public GameObject fireball;
public int maxHp;
public float hp;
public Transform mouth;
public CameraShake cameraShake;
Animator anim;
public int phase = 1;
bool vulnerable;
Transform player;
Transform parent;
// Start is called before the first frame update
void Start(){
parent = GetComponentInParent<Transform>();
anim = GetComponent<Animator>();
hp = maxHp;
vulnerable = false;
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
foreach(GameObject g in diable){
g.SetActive(false);
}
if(phase == 2){
anim.SetBool("Phase2", true);
}else if(phase == 3){
anim.SetBool("Phase2", true);
anim.SetBool("Phase3", true);
}
Invoke("DisableColliderStop", 2f);
}
void DisableColliderStop(){
colliderStop.SetActive(false);
}
float speed;
// Update is called once per frame
void Update(){
if(phase == 1){
if(hp <= 60){
phase = 2;
anim.SetBool("Die", true);
foreach (GameObject g in diable){
g.SetActive(false);
}
foreach (GameObject g in phase2Enable){
g.SetActive(true);
}
}
}else if(phase == 2){
if (hp <= 30){
phase = 3;
anim.SetBool("Die", true);
foreach (GameObject g in diable){
g.SetActive(false);
}
foreach (GameObject g in phase3Enable){
g.SetActive(true);
}
}
}else if(phase == 3){
if(hp <= 0){
Die();
}
}
}
void Die(){
anim.SetBool("Die", true);
}
public void TakeDamage(float amt){
if (vulnerable){
hp = Mathf.Clamp(hp - amt, 0f, maxHp);
}
}
public void IsIdle(){
vulnerable = true;
}
public void Shake(){
cameraShake.Shake(.1f, 1.5f);
AudioManager.instance.Play("DragonShout");
}
public void FireSound(){
AudioManager.instance.Play("DragonFire");
}
public void FireAttack(){
vulnerable = false;
Instantiate(fire, mouth.position, Quaternion.identity, mouth);
}
public void EndFireAttack(){
vulnerable = true;
}
public void FireBallAtack(){
AudioManager.instance.Play("DragonFireBall");
vulnerable = false;
Instantiate(fireball, mouth.position, Quaternion.Euler(0, 0, 90f));
}
public void EndFireBallAttack(){
vulnerable = true;
}
public void Win(){
StartCoroutine(WinScreen());
}
IEnumerator WinScreen(){
yield return new WaitForSeconds(2f);
SceneManager.LoadScene(0);
}
}

View file

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

View file

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goomba : MonoBehaviour{
public float speed;
public float maxSpeed;
Rigidbody2D rb2d;
bool canMove;
// Start is called before the first frame update
void Start(){
rb2d = GetComponent<Rigidbody2D>();
}
void OnBecameVisible(){
canMove = true;
}
// Update is called once per frame
void Update(){
rb2d.AddForce(Vector2.left * speed);
float limitedSpeed = Mathf.Clamp(rb2d.velocity.x, -maxSpeed, maxSpeed);
rb2d.velocity = new Vector2(limitedSpeed, rb2d.velocity.y);
}
}

View file

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