Greetings everyone
How have you been? good i hope ^^
Here’s my question:
I’m doing a monopoly game and so far everything is going swell, but now I’m stuck in a part and it would be awesome if you guys could solve my problem and explain me a little more about my question.
So I have these 2 GameObjects pieces that are the players and they move in the board and i get to call the buying functions. The thing is, how do i tell unity to wait for something to happen on the other script?
Here’s some of my script:
This is the function ongui → which is attached to the GameController:
if(lecompra1)
{
GUILayout.BeginArea(Rect(Screen.width / 2, Screen.height / 2, buttonLargura, 400));
if(GUILayout.Button("compro", GUILayout.Height(buttonAltura)))
{
jogadorActual = currentPlayer;
oJogador = jogadorActual.GetComponent("CoisasJogadores");
//Debug.Log(jogadorActual);
//Debug.Log("COMPRO");
//Debug.Log(oJogador.ruaTudoRasca);
if(oJogador.ruaTudoRasca == 0)
{
if(oJogador.dinheiroInicial > 60)
{
//comprado1 = true;
oJogador.dinheiroInicial -= 60;
oJogador.ruaTudoRasca = 1;
Debug.Log(oJogador.ruaTudoRasca);
Debug.Log("A Rua É Tua");
Debug.Log(oJogador.dinheiroInicial);
trocaosJogadores();
}
if(oJogador.dinheiroInicial < 60)
{
Debug.Log("não tens dinheiro");
Debug.Log(oJogador.dinheiroInicial);
trocaosJogadores();
}
}
lecompra1 = false;
}
And this is the script on the tiles where the players will land:
function OnTriggerStay(other:Collider)
{
if(targetTileName == tile8)
{
//Debug.Log("Caiste numa casa de ??????");
Debug.Log(jogadorNaTile);
//Debug.Log(Ajogador.ruaTudoRasca);
if(compra1 == 0)
{
if(jogadorNaTile.GetComponent("CoisasJogadores").ruaTudoRasca == 0)
{
naTile.lecompra1 = true;
//this is where the yield should be }
if(jogadorNaTile.GetComponent("CoisasJogadores").ruaTudoRasca == 1)
{
if(jogadorNaTile == jogador1)
{
compra1Nome = jogador1;
Debug.Log(compra1Nome);
}
if(jogadorNaTile == jogador2)
{
compra1Nome = jogador2;
Debug.Log(compra1Nome);
}
Debug.Log(jogadorNaTile);
Debug.Log(compra1Nome);
}
if(compra1 ==1)
{
Debug.Log("já foi comprada");
}
}
}
I’m just testing in one tile that’s why there’s only one tile being called.
Now in order to call the ongui function that are in the GameController script, lecompra1 must be true, and its true when the player stays in the tile8, so far its good but, how do I tell unity to wait from that point and resume the code where the yield is?
I’m sorry if this sounds confusing and sorry for my bad English but I’m Portuguese ^^".
I thank you all in advance for your help =) very much appreciated d(^^)