#https hatebin com sgyawgbsad
1 messages · Page 1 of 1 (latest)
That code is super convoluted and unreadable.
Describe in short what it is supposed to achieve
basically If you place a dice with the same number as the opposite side it gets rid of all the opposite sides dice that have the same value and sets the isOccupied bool back to false so you can put dice back in that slot
in the video it works perfect on the left side top row but no where else
in other areas its funky
is Tile a script that represent your slots for dices?
What does Dice1 represent then? Why is the code in Start?
Dice1 is the script i put on the dice that is a one Dice6 goes on 6
its in start so that when a clone gets made it checks the other side once
should i send the vid in here?
yes
hello i didnt understand your question but i think using switch statement in your code will make your life much better
switch(GameObject.Find("p1r2c1").transform.childCount)
{
case 0:
GameObject.Find("p1r2c1").GetComponent<Tile>().isOccupied = false;
break;
case 1:
GameObject.Find("p1r2c1").GetComponent<Tile>().isOccupied = false;
break;
what does that do
its like if but for that one condition with multiple values like the
GameObject.Find("p1r2c1").transform.childCount
in your code
syntax :
switch(condition)
{
case 1:
do something
break;
case 2:
do something2
break;}
Here's how I'd do it:
- Have a
game logic managerabove at the root of the hierarchy. - Have both grids parented to it and add a
Gridscript that manages each grid. Gridwould hold an array ofTiles referencing the tiles underneath it.- Have your die rolling logic in the
game logic manager. - When you place a die on one of the
Grids, ask the otherGridto clear anyTiles that may contain a die of the same number that was rolled. - Finally place a die on the
Grid.
You don't need to find anything, nor compare tags or parents.
i can attempt that too