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

@@ -198,7 +198,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &16285950
RectTransform:
@@ -3434,6 +3434,8 @@ MonoBehaviour:
- {fileID: 21300000, guid: 8d8a82287846c3d4892b15d8ab640d68, type: 3}
hely1: {fileID: 1620774317}
hely2: {fileID: 921900544}
dice1btnBtn: {fileID: 1620774314}
dice2btnBtn: {fileID: 921900541}
diceResult: 0000000000000000
ujertek:
valasztottErtek: 0
@@ -3456,6 +3458,7 @@ MonoBehaviour:
- {fileID: 710452256}
- {fileID: 255844036}
dobott: 0
dobottEgyszer: 0
--- !u!114 &197904222
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -5242,7 +5245,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 0
--- !u!224 &274472944
RectTransform:
@@ -5322,7 +5325,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &278097272
RectTransform:
@@ -5932,7 +5935,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &305492121
RectTransform:
@@ -5986,7 +5989,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &305972457
RectTransform:
@@ -9986,7 +9989,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@@ -11399,7 +11402,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 0
--- !u!224 &628297614
RectTransform:
@@ -13965,7 +13968,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 0
--- !u!224 &762817986
RectTransform:
@@ -15334,7 +15337,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 0
--- !u!224 &815764583
RectTransform:
@@ -17048,7 +17051,7 @@ Canvas:
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_SortingOrder: 2
m_TargetDisplay: 0
--- !u!224 &891272366
RectTransform:
@@ -17853,7 +17856,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_SortingOrder: 3
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -20828,7 +20831,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1006554990
RectTransform:
@@ -23656,7 +23659,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1155991840
RectTransform:
@@ -24471,7 +24474,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1188450186
RectTransform:
@@ -27202,7 +27205,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1345558467
RectTransform:
@@ -32129,7 +32132,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_SortingOrder: 1
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_FlipX: 0
@@ -32236,7 +32239,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 0
--- !u!224 &1569152954
RectTransform:
@@ -33676,7 +33679,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1617719566
RectTransform:
@@ -34126,7 +34129,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_SortingOrder: 3
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -34867,7 +34870,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1657431395
RectTransform:
@@ -36188,7 +36191,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1705902974
RectTransform:
@@ -38017,7 +38020,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1794797041
RectTransform:
@@ -39991,7 +39994,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_SortingOrder: 1
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 0, g: 0.011921406, b: 1, a: 1}
m_FlipX: 0
@@ -40787,7 +40790,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &1958549383
RectTransform:

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){

View File

@@ -121,11 +121,12 @@ public class Targyak : MonoBehaviour
yield break; //kilepeshez
}else{
deactivateInputOk(false);
dice.HelyszinKiBekapcs(false);
}
//ha nem lepett ki eddig
dice.ujertek[0] = dice.getDices()[0];
dice.ujertek[1] = dice.getDices()[1]; //regi adat, hogy ne legyen hibas
//dice.ujertek[0] = dice.getDices()[0];
//dice.ujertek[1] = dice.getDices()[1]; //regi adat, hogy ne legyen hibas
}
public void deactivateInputOk(bool targyelvesztes) {