This commit is contained in:
Gerard Gascón 2025-04-24 17:02:43 +02:00
commit fca6784fe7
571 changed files with 84105 additions and 0 deletions

View file

@ -0,0 +1,206 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackManager : MonoBehaviour{
[SerializeField] HandManager hand = default;
public float maxHeight, minHeight;
public float selectSmoothTime = .1f;
[System.Serializable] public class Fingers{
public bool finger1;
public bool finger2;
public bool finger3;
public bool finger4;
public bool finger5;
}
public Fingers[] minimumForPaper = default;
public Fingers[] minimumForScisors = default;
[HideInInspector] public Fingers selectedScisor;
[HideInInspector] public Fingers selectedPaper;
public bool CanScisorAttack(){
bool temp = true;
foreach(Fingers f in minimumForScisors){
temp = true;
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (!hand.finger1 && f.finger1)
temp = false;
break;
case 1:
if (!hand.finger2 && f.finger2)
temp = false;
break;
case 2:
if (!hand.finger3 && f.finger3)
temp = false;
break;
case 3:
if (!hand.finger4 && f.finger4)
temp = false;
break;
case 4:
if (!hand.finger5 && f.finger5)
temp = false;
break;
}
}
if (temp){
selectedScisor = f;
break;
}
}
return temp;
}
public bool CanPaperAttack(){
bool temp = true;
foreach (Fingers f in minimumForPaper){
temp = true;
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (!hand.finger1 && f.finger1)
temp = false;
break;
case 1:
if (!hand.finger2 && f.finger2)
temp = false;
break;
case 2:
if (!hand.finger3 && f.finger3)
temp = false;
break;
case 3:
if (!hand.finger4 && f.finger4)
temp = false;
break;
case 4:
if (!hand.finger5 && f.finger5)
temp = false;
break;
}
}
if (temp){
selectedPaper = f;
break;
}
}
return temp;
}
public bool AttackingWithMeat(bool scisor, bool paper){
if (scisor){
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (selectedScisor.finger1 && hand.finger1Type == HandManager.FingerTypes.Meat)
return true;
break;
case 1:
if (selectedScisor.finger2 && hand.finger2Type == HandManager.FingerTypes.Meat)
return true;
break;
case 2:
if (selectedScisor.finger3 && hand.finger3Type == HandManager.FingerTypes.Meat)
return true;
break;
case 3:
if (selectedScisor.finger4 && hand.finger4Type == HandManager.FingerTypes.Meat)
return true;
break;
case 4:
if (selectedScisor.finger5 && hand.finger5Type == HandManager.FingerTypes.Meat)
return true;
break;
}
}
}else if (paper){
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (selectedPaper.finger1 && hand.finger1Type == HandManager.FingerTypes.Meat)
return true;
break;
case 1:
if (selectedPaper.finger2 && hand.finger2Type == HandManager.FingerTypes.Meat)
return true;
break;
case 2:
if (selectedPaper.finger3 && hand.finger3Type == HandManager.FingerTypes.Meat)
return true;
break;
case 3:
if (selectedPaper.finger4 && hand.finger4Type == HandManager.FingerTypes.Meat)
return true;
break;
case 4:
if (selectedPaper.finger5 && hand.finger5Type == HandManager.FingerTypes.Meat)
return true;
break;
}
}
}
return false;
}
public bool AttackingWithWood(bool scisor, bool paper){
if (scisor){
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (selectedScisor.finger1 && hand.finger1Type == HandManager.FingerTypes.Wood)
return true;
break;
case 1:
if (selectedScisor.finger2 && hand.finger2Type == HandManager.FingerTypes.Wood)
return true;
break;
case 2:
if (selectedScisor.finger3 && hand.finger3Type == HandManager.FingerTypes.Wood)
return true;
break;
case 3:
if (selectedScisor.finger4 && hand.finger4Type == HandManager.FingerTypes.Wood)
return true;
break;
case 4:
if (selectedScisor.finger5 && hand.finger5Type == HandManager.FingerTypes.Wood)
return true;
break;
}
}
}else if (paper){
for (int i = 0; i < 5; i++){
switch (i){
case 0:
if (selectedPaper.finger1 && hand.finger1Type == HandManager.FingerTypes.Wood)
return true;
break;
case 1:
if (selectedPaper.finger2 && hand.finger2Type == HandManager.FingerTypes.Wood)
return true;
break;
case 2:
if (selectedPaper.finger3 && hand.finger3Type == HandManager.FingerTypes.Wood)
return true;
break;
case 3:
if (selectedPaper.finger4 && hand.finger4Type == HandManager.FingerTypes.Wood)
return true;
break;
case 4:
if (selectedPaper.finger5 && hand.finger5Type == HandManager.FingerTypes.Wood)
return true;
break;
}
}
}
return false;
}
}

View file

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

View file

@ -0,0 +1,89 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class AttackSelectorUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler{
EnemyController enemy;
[System.Serializable] enum AttackType { Rock, Paper, Scisors}
[SerializeField] AttackType attackType = default;
AttackManager attack;
bool selected;
RectTransform rect;
float velocity;
[SerializeField] PlayerAttack playerAttack = default;
void Awake(){
attack = GetComponentInParent<AttackManager>();
rect = GetComponent<RectTransform>();
}
public void OnPointerEnter(PointerEventData eventData){
selected = true;
switch (CombatManager.instance.enemyType){
case CombatManager.EnemyType.Bear:
enemy = CombatManager.instance.bear;
break;
case CombatManager.EnemyType.Driada:
enemy = CombatManager.instance.driada;
break;
case CombatManager.EnemyType.Loca:
enemy = CombatManager.instance.loca;
break;
case CombatManager.EnemyType.Boss:
enemy = CombatManager.instance.boss;
break;
}
}
public void OnPointerExit(PointerEventData eventData){
selected = false;
}
// Update is called once per frame
void Update(){
if (selected){
if (attackType == AttackType.Paper){
if (attack.CanPaperAttack()){
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
if (Input.GetMouseButtonUp(0)){
playerAttack.open1 = attack.selectedPaper.finger1;
playerAttack.open2 = attack.selectedPaper.finger2;
playerAttack.open3 = attack.selectedPaper.finger3;
playerAttack.open4 = attack.selectedPaper.finger4;
playerAttack.open5 = attack.selectedPaper.finger5;
enemy.Attack(attack.AttackingWithMeat(false, true), attack.AttackingWithWood(false, true), 2);
playerAttack.Attack();
}
}
}else if (attackType == AttackType.Scisors){
if (attack.CanScisorAttack()){
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
if (Input.GetMouseButtonUp(0)){
playerAttack.open1 = attack.selectedScisor.finger1;
playerAttack.open2 = attack.selectedScisor.finger2;
playerAttack.open3 = attack.selectedScisor.finger3;
playerAttack.open4 = attack.selectedScisor.finger4;
playerAttack.open5 = attack.selectedScisor.finger5;
enemy.Attack(attack.AttackingWithMeat(true, false), attack.AttackingWithWood(true, false), 3);
playerAttack.Attack();
}
}
}else{
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
if (Input.GetMouseButtonUp(0)){
playerAttack.open1 = playerAttack.open2 = playerAttack.open3 = playerAttack.open4 = playerAttack.open5 = false;
enemy.Attack(attack.AttackingWithMeat(false, false), attack.AttackingWithWood(false, false), 1);
playerAttack.Attack();
}
}
}else{
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.minHeight, ref velocity, attack.selectSmoothTime));
}
}
}

View file

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

View file

@ -0,0 +1,194 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CombatManager : MonoBehaviour{
public enum EnemyType { Bear, Driada, Loca, Boss }
public EnemyType enemyType = default;
[Space]
public EnemyController bear = default;
public EnemyController driada = default;
public EnemyController loca = default;
public EnemyController boss = default;
[Space]
public GameObject bearHand = default;
public GameObject driadaHand = default;
public GameObject locaHand = default;
public GameObject bossHand = default;
[Space]
[SerializeField] GameObject bearBackground = default;
[SerializeField] GameObject driadaBackground = default;
[SerializeField] GameObject locaBackground = default;
[SerializeField] GameObject bossBackground = default;
[Space]
[SerializeField] Animator anim = default;
[SerializeField] CustomTMP_Animated dialogue = default;
[SerializeField] Dialogue bearDialogue = default;
[SerializeField] Dialogue driadaDialogue = default;
[SerializeField] Dialogue locaDialogue = default;
[SerializeField] Dialogue bossDialogue = default;
[Space]
[SerializeField] Animator bearHandAnim = default;
[SerializeField] Animator driadaHandAnim = default;
[SerializeField] Animator locaHandAnim = default;
[SerializeField] Animator bossHandAnim = default;
[SerializeField] Animator playerHandAnim = default;
int dialogueIndex;
bool dialogueStarted;
public static CombatManager instance;
void Awake(){
instance = this;
}
// Start is called before the first frame update
void Start(){
if(GameMaster.instance != null)
enemyType = (EnemyType)GameMaster.instance.enemyType[GameMaster.instance.currentGrid];
AudioManager.instance.StopAll();
AudioManager.instance.Play("FightNoBrass");
switch (enemyType){
case EnemyType.Bear:
driada.gameObject.SetActive(false);
loca.gameObject.SetActive(false);
driadaHand.SetActive(false);
locaHand.SetActive(false);
boss.gameObject.SetActive(false);
bossHand.SetActive(false);
driadaBackground.SetActive(false);
locaBackground.SetActive(false);
bossBackground.SetActive(false);
break;
case EnemyType.Driada:
bear.gameObject.SetActive(false);
loca.gameObject.SetActive(false);
bearHand.SetActive(false);
locaHand.SetActive(false);
boss.gameObject.SetActive(false);
bossHand.SetActive(false);
bearBackground.SetActive(false);
locaBackground.SetActive(false);
bossBackground.SetActive(false);
break;
case EnemyType.Loca:
driada.gameObject.SetActive(false);
bear.gameObject.SetActive(false);
driadaHand.SetActive(false);
bearHand.SetActive(false);
boss.gameObject.SetActive(false);
bossHand.SetActive(false);
driadaBackground.SetActive(false);
bearBackground.SetActive(false);
bossBackground.SetActive(false);
break;
case EnemyType.Boss:
AudioManager.instance.Stop("FightNoBrass");
AudioManager.instance.Play("fightFull");
driada.gameObject.SetActive(false);
bear.gameObject.SetActive(false);
loca.gameObject.SetActive(false);
locaHand.SetActive(false);
driadaHand.SetActive(false);
bearHand.SetActive(false);
driadaBackground.SetActive(false);
bearBackground.SetActive(false);
bearBackground.SetActive(false);
break;
}
}
public void OnStartDialogue(){
switch (enemyType){
case EnemyType.Bear:
dialogue.ReadText(bearDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Driada:
dialogue.ReadText(driadaDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Loca:
dialogue.ReadText(locaDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Boss:
dialogue.ReadText(bossDialogue.sentences[dialogueIndex]);
break;
}
anim.SetTrigger("Enter");
dialogueStarted = true;
dialogueIndex++;
}
// Update is called once per frame
void Update(){
if (dialogueStarted){
if (Input.anyKeyDown){
switch (enemyType){
case EnemyType.Bear:
if (dialogueIndex == bearDialogue.sentences.Length){
StartGame(EnemyType.Bear);
break;
}
dialogue.ReadText(bearDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Driada:
if (dialogueIndex == driadaDialogue.sentences.Length){
StartGame(EnemyType.Driada);
break;
}
dialogue.ReadText(driadaDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Loca:
if (dialogueIndex == locaDialogue.sentences.Length){
StartGame(EnemyType.Loca);
break;
}
dialogue.ReadText(locaDialogue.sentences[dialogueIndex]);
break;
case EnemyType.Boss:
if (dialogueIndex == bossDialogue.sentences.Length){
StartGame(EnemyType.Boss);
break;
}
dialogue.ReadText(bossDialogue.sentences[dialogueIndex]);
break;
}
dialogueIndex++;
}
}
}
void StartGame(EnemyType enemy){
switch (enemy){
case EnemyType.Bear:
bearHandAnim.SetTrigger("Enter");
AudioManager.instance.Play("oso_risa");
break;
case EnemyType.Boss:
bossHandAnim.SetTrigger("Enter");
break;
case EnemyType.Driada:
driadaHandAnim.SetTrigger("Enter");
AudioManager.instance.Play("driada_risa");
break;
case EnemyType.Loca:
locaHandAnim.SetTrigger("Enter");
AudioManager.instance.Play("loca_risa");
break;
}
dialogueStarted = false;
anim.SetTrigger("Exit");
playerHandAnim.SetTrigger("Enter");
}
}

View file

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

View file

@ -0,0 +1,165 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class EnemyController : MonoBehaviour{
[SerializeField] Dialogue loseDialogue = default;
[SerializeField] HandManager playerHand = default;
[SerializeField] CustomTMP_Animated text = default;
[SerializeField] Animator textAnim = default;
[SerializeField, Range(0, 100)] int percentageWood = 0;
[SerializeField, Range(0, 100)] int percentageMeat = 0;
[Space]
[SerializeField] Sprite rock = default;
[SerializeField] Sprite paper = default;
[SerializeField] Sprite scisors = default;
[SerializeField] Sprite deathSprite = default;
[SerializeField] Animator playerAnim = default;
[SerializeField] Animator anim = default;
[SerializeField] Image image = default;
[SerializeField] GameObject[] heart = default;
int life = 3;
[SerializeField] GameObject[] playerHeart = default;
int playerLife = 3;
int enemyAttack;
int playerAttack;
bool lost;
public void Attack(bool attackingWithMeat, bool attackingWithWood, int attack){
float randomNumber = Random.Range(0f, 100f);
if(randomNumber > percentageWood && attackingWithWood){
Debug.Log("Wait, that's illegal");
}
if(randomNumber > percentageMeat && attackingWithMeat){
Debug.Log("Wait, that's illegal");
}
enemyAttack = Mathf.RoundToInt(Random.Range(100f, 300f) / 100f);
playerAttack = attack;
switch (enemyAttack){
case 1:
//Rock
if(playerAttack == 2){
anim.SetTrigger("Die");
}else if(playerAttack == 3){
playerAnim.SetTrigger("Die");
}
break;
case 2:
//Paper
if (playerAttack == 3){
anim.SetTrigger("Die");
}else if (playerAttack == 1){
playerAnim.SetTrigger("Die");
}
break;
case 3:
//Scisors
if (playerAttack == 1){
anim.SetTrigger("Die");
}else if (playerAttack == 2){
playerAnim.SetTrigger("Die");
}
break;
}
}
int count;
void Update(){
if(lost && count == 0){
if (Input.anyKeyDown){
textAnim.SetTrigger("Exit");
count = 1;
}
}
}
public void ShowArm(){
switch (enemyAttack){
case 1:
//Rock
image.sprite = rock;
if (playerAttack == 2){
heart[life - 1].SetActive(false);
life--;
if (life == 0){
OnDie();
}
}else if (playerAttack == 3){
playerHeart[playerLife - 1].SetActive(false);
playerLife--;
if (playerLife == 0){
Lose();
}
}
break;
case 2:
//Paper
image.sprite = paper;
if (playerAttack == 3){
heart[life - 1].SetActive(false);
life--;
if (life == 0){
OnDie();
}
}else if (playerAttack == 1){
playerHeart[playerLife - 1].SetActive(false);
playerLife--;
if (playerLife == 0){
Lose();
}
}
break;
case 3:
//Scisors
image.sprite = scisors;
if (playerAttack == 1){
heart[life - 1].SetActive(false);
life--;
if (life == 0){
OnDie();
}
}else if (playerAttack == 2){
playerHeart[playerLife - 1].SetActive(false);
playerLife--;
if (playerLife == 0){
Lose();
}
}
break;
}
}
void Lose(){
text.ReadText(loseDialogue.sentences[0]);
lost = true;
playerHand.canCut = true;
textAnim.SetTrigger("Enter");
playerHand.GetComponentInParent<Animator>().SetTrigger("EnterDeath");
}
public void Shake(){
image.sprite = rock;
}
void OnDie(){
if (!gameObject.activeSelf)
return;
GetComponent<Image>().sprite = deathSprite;
StartCoroutine(Die());
}
IEnumerator Die(){
yield return new WaitForSeconds(.5f);
GameMaster.instance.CompleteGrid(GameMaster.instance.currentGrid);
}
}

View file

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

View file

@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameMaster : MonoBehaviour{
[HideInInspector] public int gridLength;
[HideInInspector] public int currentGrid;
[HideInInspector] public Dictionary<int, bool> grids;
[HideInInspector] public Dictionary<int, int> enemyType;
public static GameMaster instance;
public bool finger1;
public bool finger2;
public bool finger3;
public bool finger4;
public bool finger5;
// Start is called before the first frame update
void Awake(){
if(instance == null){
instance = this;
}else{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
}
public void LoadGrid(int grid){
currentGrid = grid;
Loader.Load(2);
}
public void LoadBoss(int grid){
currentGrid = grid;
enemyType[grid] = 3;
Loader.Load(2);
}
public void CompleteGrid(int grid){
grids[grid] = true;
Loader.Load(1);
}
public void DestroyGameMaster(){
instance = null;
Destroy(gameObject);
}
}

View file

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

View file

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour{
[SerializeField] Animator attack = default;
[SerializeField] Animator[] enemyAnim = default;
[SerializeField] Animator flash = default;
[SerializeField] EnemyController[] enemy = default;
[SerializeField] HandManager hand = default;
[Space]
public bool open1;
public bool open2;
public bool open3;
public bool open4;
public bool open5;
public void Attack(){
hand.open1 = false;
hand.open2 = false;
hand.open3 = false;
hand.open4 = false;
hand.open5 = false;
attack.SetTrigger("Attack");
foreach(Animator anim in enemyAnim){
anim.SetTrigger("Attack");
}
foreach(EnemyController e in enemy){
e.Shake();
}
}
public void CountdownSound(){
AudioManager.instance.PlayOneShot("cuentaAtras");
}
public void ShowArms(){
hand.open1 = open1;
hand.open2 = open2;
hand.open3 = open3;
hand.open4 = open4;
hand.open5 = open5;
GetComponent<HandManager>().enabled = true;
flash.SetTrigger("Flash");
AudioManager.instance.Play("lanzar");
foreach (EnemyController e in enemy){
e.ShowArm();
}
}
}

View file

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