- Home /
help with bidding script
hello could some one help me with this script, basically im up to the point where i need to show the players bid in the gui box and the ai's bid in there aswell, i also need help with making ai to bid against,e.g if i place a bid then the ai places one with a 50/50 chance of being successful at placing a bid until you win, and also have a gui show that you have won the bid. i have no idea how to do that, would anyone be willing to help me out please? cant find anything like this on unity answers or forums.
here is where i am up to
#pragma strict
var information: String;
private var guiOn = false;
private var rect: Rect;
var btnTexture : Texture;
var ClosePostion : Vector2 = new Vector2 (200,5);
var CloseSize : Vector2 = new Vector2 (35,35);
var CloseIcon : Texture;
var MyString = "";
//click to open gui
function OnMouseDown(){
guiOn = true;
rect = Rect(Input.mousePosition.x, Input.mousePosition.y, 300, 100);
yield WaitForSeconds(500);
guiOn = false;
}
function OnGUI(){
if (guiOn){
GUI.Box(Rect(0,0,200,200),"Current bid");
if (!btnTexture) {
Debug.LogError("Assign a texture");
return;
}
if (GUI.Button(Rect(10,10,50,50),btnTexture))
Debug.Log("texturebutton");
if (GUI.Button(Rect(10,70,50,30),"Bid")) {
var bid : int;
if (!int.TryParse(MyString, bid))
bid = 0;
Debug.Log("The bid was: "+bid);
}
var temp = "";
for (var c : char in MyString) {
if (c >= "0"[0] && c <= "9"[0]) {
temp += c;
}
}
MyString = temp;
MyString = GUI.TextField(new Rect(10,130,180,20),MyString,30);
//close button
if (GUI.Button(Rect(160,2,CloseSize.x,CloseSize.y),CloseIcon)) {
guiOn = false;
}
}
}
Please don't re-post similar Question post. Just wait and if you would give more detail in your other post maybe people would want to help you.
On that note, check your other post. I provided a solution or at least some insight for your problem.
this is the last script i need to write and its a bit passed me, been trying to work it out for ages but cant, im completely stuck
var chance = Random.Range(0,1);
if(chance == 1)
{
lost = true;
}
if(chance == 0)
{
won = true;
}
use this as a reference to chances
i get an error saying ArgumentException: RandomRangeInt can only be called from the main thread.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Make player not be seen by AI, when player in foilage and shadows. 1 Answer
Need Help Creating my Tank AI Controller! 1 Answer
Argument out of range. 1 Answer
Enemy AI won't take Damage 1 Answer