valasztott szam az akciok mezobe megjelenik

This commit is contained in:
2022-11-02 13:15:47 +01:00
parent 73ee069e8b
commit 39b73cf5a8
3 changed files with 111 additions and 100 deletions

View File

@@ -2,24 +2,38 @@
using UnityEngine;
public class Dice : MonoBehaviour {
public Sprite[] diceSides = new Sprite[6];
public SpriteRenderer hely1;
public SpriteRenderer hely2;
public SpriteRenderer hely3;
private int[] diceResult = { 0, 0 };
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
public void ertekValasztas(GameObject gomb) {
//getters setters
public int[] getDices() { return diceResult; }
public int getValasztottErtek() { return valasztottErtek; }
public void setValasztottErtek(int ujErtek) { valasztottErtek = ujErtek; }
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") {
if (gomb.name == "dice1btn") {
valasztottErtek = diceResult[0];
//a valasztott szam atirasa az akcio mezobe
hely3.sprite = diceSides[valasztottErtek-1];
hely3.size = new Vector2(38, 38);
locked = true;
}else if (gomb.name == "dice2btn") {
} else if (gomb.name == "dice2btn") {
valasztottErtek = diceResult[1];
//a valasztott szam atirasa az akcio mezobe
hely3.sprite = diceSides[valasztottErtek-1];
hely3.size = new Vector2(38, 38);
locked = true;
}
}
@@ -27,9 +41,6 @@ public class Dice : MonoBehaviour {
Debug.Log("valasztott ertek: " + valasztottErtek + "locked status: " + locked);
}
public int[] getDices() { return diceResult; }
private int RollDice(SpriteRenderer renderer) {
int randomDiceSide = Random.Range(0, 5);
int finalSide = randomDiceSide + 1;