dice bugfixes

This commit is contained in:
2023-02-12 16:53:09 +01:00
parent a6d71246ff
commit 6dc7a42e5e
5 changed files with 92 additions and 86 deletions

View File

@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -8,24 +7,21 @@ public class Dice : MonoBehaviour {
public Sprite[] diceSides = new Sprite[6];
public SpriteRenderer hely1;
public SpriteRenderer hely2;
public Button dice1btnBtn;
public Button dice2btnBtn;
private Upgrade upgrade;
private Akciopont ap;
private Energia energiasav;
private Targyak targyak;
public int[] diceResult = { 0, 0 };
public List<int> ujertek = new List<int>();
public int valasztottErtek; //a jatekos altal valasztott dobott ertek helye
private bool locked = false; //ne lehessen ujra kivalasztani a masikat ha mar tortent egy valasztas
private bool locked = false; //ne lehessen ujra kivalasztani a masikat ha mar tortent egy valasztas
public bool adrenalinMegerosites = false;
public GameObject adrenalinHasznalat;
public Button confirm;
public Button cancel;
public bool mehet = false;
public BoxCollider2D[] colliders;
//getters setters
@@ -34,21 +30,16 @@ public class Dice : MonoBehaviour {
public void setValasztottErtek(int ujErtek) { valasztottErtek = ujErtek; }
public bool getLocked() { return locked; }
public void setLocked(bool locked) { this.locked = locked; }
public int dobott = 0;
public bool dobottEgyszer = false; //tudjon ujra dobni vagy nem
private void Awake() {
}
private void Start() {
upgrade = FindObjectOfType<Upgrade>();
ap = FindObjectOfType<Akciopont>();
energiasav = FindObjectOfType<Energia>();
targyak = FindObjectOfType<Targyak>();
}
public void ertekValasztas(GameObject gomb) {
if (diceResult[0] != 0 && diceResult[1] != 0 && !locked) { //megnezzuk hogy lett e mar dobva es nem valasztott meg a jatekos
if (gomb.name == "dice1btn") {
@@ -89,11 +80,19 @@ public class Dice : MonoBehaviour {
public void CallRenderDice() => StartCoroutine(renderDice());
public IEnumerator renderDice() {
//ha zarolva van akkor ne tudjon ujra dobni / csak egyszer dobhasson (amig nincs feloldva a kovetkezo dobashoz)
if(dobottEgyszer) yield break;
//dice gombok kikapcsolasa hogy amig nem vegez ne tudjon erteket valasztani
dice1btnBtn.enabled = false;
dice2btnBtn.enabled = false;
do {
diceResult[0] = RollDice();
diceResult[1] = RollDice();
} while (diceResult[0] == diceResult[1]);
//lassa a jatekos mit dobott
hely1.sprite = diceSides[diceResult[0]-1];
hely1.size = new Vector2(38, 38);
@@ -101,6 +100,8 @@ public class Dice : MonoBehaviour {
hely2.sprite = diceSides[diceResult[1]-1];
hely2.size = new Vector2(38, 38);
dobottEgyszer = true;
//ha megvan a targy
if(targyak.adrenalinloket > 0) {
//helyszin collider kikapcsolas a gomb miatt
@@ -121,12 +122,12 @@ public class Dice : MonoBehaviour {
adrenalinHasznalat.gameObject.SetActive(false);
if (adrenalinMegerosites) {
//Debug.Log("belep");
targyak.CallAdrenalinLoket();
yield return new WaitUntil(() => ujertek.Count > 0);
if(mehet){
Debug.Log("belep mehet");
Debug.Log("List: 0: " + ujertek[0] + " 1: " + ujertek[1]);
//EGYENLO ERTEKEK VIZSGALATA
//ha tul nagy vagy tul kicsi erteket ad meg az elso kockanak valtsa at az erteket
if(targyak.ujertek1 > 6 && diceResult[1] != 6 && targyak.ujertek2 != 6){ //ha tul nagy szamot adott meg legyen 6 az ertek
targyak.ujertek1 = 6;
@@ -149,18 +150,15 @@ public class Dice : MonoBehaviour {
targyak.ujertek2 = 1;
}else if(targyak.ujertek2 < 1 && (diceResult[0] == 1 || targyak.ujertek1 == 1)){
targyak.ujertek2 = 2;
}
}
diceResult[0] = targyak.ujertek1;
diceResult[1] = targyak.ujertek2;
dobottEgyszer = true;
}
}
//deaktivalas
Debug.Log("belep2");
adrenalinMegerosites = false;
//HelyszinKiBekapcs(false);
}
hely1.sprite = diceSides[diceResult[0]-1];
@@ -169,6 +167,10 @@ public class Dice : MonoBehaviour {
hely2.sprite = diceSides[diceResult[1]-1];
hely2.size = new Vector2(38, 38);
dobott++;
//ha vegzett mindennel kapcsolja vissza az ertekvalasztast
dice1btnBtn.enabled = true;
dice2btnBtn.enabled = true;
}
public void HelyszinKiBekapcs(bool kikapcsolas){