This commit is contained in:
Gerard Gascón 2025-04-24 16:56:52 +02:00
commit 862afc9b7a
478 changed files with 197737 additions and 0 deletions

View file

@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonFalling : MonoBehaviour{
public Transform[] wall;
public bool pressed = false;
public Sprite off;
[Space(10)]
public GameObject[] fallingPlatforms;
private void OnCollisionEnter2D(Collision2D collision){
if ((collision.transform.tag == "Player") && !pressed || collision.gameObject.tag == "Bullet" && !pressed){
Press();
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if ((collision.transform.tag == "Player"))
{
Press();
}
}
public void Press(){
if (fallingPlatforms != null){
foreach (GameObject platform in fallingPlatforms){
platform.GetComponent<FallingPlatformButton>().ButtonFall();
}
}
if (wall != null){
for (int i = 0; i < wall.Length; i++){
wall[i].GetComponent<Collider2D>().enabled = !wall[i].GetComponent<Collider2D>().enabled;
if (wall[i].GetComponent<SpriteRenderer>()){
Color col = wall[i].GetComponent<SpriteRenderer>().color;
if (wall[i].GetComponent<Collider2D>().enabled)
col.a = 1;
else col.a = 0.25f;
wall[i].GetComponent<SpriteRenderer>().color = col;
}
for (int f = 0; f < wall[i].childCount; f++){
if (wall[i].GetChild(f).GetComponent<SpriteRenderer>()){
Color col = wall[i].GetChild(f).GetComponent<SpriteRenderer>().color;
if (wall[i].GetComponent<Collider2D>().enabled)
col.a = 1;
else col.a = 0.25f;
wall[i].GetChild(f).GetComponent<SpriteRenderer>().color = col;
}
}
}
}
pressed = true;
GetComponent<Collider2D>().enabled = false;
GetComponent<SpriteRenderer>().sprite = off;
}
}