void GetDiceValue() { number += 1; diceNumber = UnityEngine.Random.Range(1, 7); if (diceNumber == 1) { GetDiceActive(registerdices[0]); } else if (diceNumber == 2) { GetDiceActive(registerdices[1]); } else if (diceNumber == 3) { GetDiceActive(registerdices[2]); } else if (diceNumber == 4) { GetDiceActive(registerdices[3]); } else if (diceNumber == 5) { GetDiceActive(registerdices[4]); } else { GetDiceActive(registerdices[5]); } if (number == 15) { CancelInvoke(); int pan = int.Parse(tempcurrentactive); number = 0; diceNumberResult = diceNumber; //handling rotation more than date 31 nextplayerposition = playercurrentposition[pan - 1] + diceNumberResult; if (nextplayerposition > 31) { nextplayerposition -= 31; } //save the history to database and print it to interface hismsg = "Player " + pan + "(" + PlayerNameActive + ")" + " Dice Result is " + diceNumberResult + ", Player " + pan + "(" + PlayerNameActive + ")" + " walks from " + playercurrentposition[pan - 1] + " to " + nextplayerposition; db.InsertHistory(hismsg, session_id); HistPrint(hismsg); //Update current position to array list playercurrentposition[pan - 1] = nextplayerposition; //automatically go to info or problem scene for special dates checkinfoorproblem(); } }
// Use this for initialization to connect database void Start() { //Load required scenes for the games SceneManager.UnloadScene("New"); setassetscene(); //get values of active session and number of active players activesessionid = GameObject.Find("EventSystem").GetComponent <StartGame>().active_session_id; avataractive = GameObject.Find("EventSystem").GetComponent <StartGame>().avataractive; //db = GetComponent<dbAccess>(); db = GameObject.Find("database").GetComponent <dbAccess>(); db.OpenDB("mydb.sdb"); ArrayList result = db.SelectLastRecord("id", "tbl_Sessions"); session_id = ((string[])result[0])[0]; //Set active_session_id on EventSystem to be used laterduring the game GameObject.Find("EventSystem").GetComponent <StartGame>().active_session_id = session_id; //this function is to insert history into table hismsg = "Game Starts"; db.InsertHistory(hismsg, session_id); HistPrint("-"); HistPrint("-"); HistPrint(hismsg); totplayeractive = db.BasicQuery("SELECT COUNT(id) FROM tbl_players WHERE tbl_Sessions_id=" + session_id); totplayeractive.Read(); totnumplayeractive = totplayeractive.GetInt32(0); playernumber = db.BasicQuery("SELECT id FROM tbl_players WHERE tbl_Sessions_id=" + session_id); playernum = new ArrayList(); while (playernumber.Read()) { for (var i = 0; i < playernumber.FieldCount; i++) { playernum.Add(playernumber.GetValue(i)); // This reads the entries in a row } } avatarnumber = db.BasicQuery("SELECT avatar_number FROM tbl_players WHERE tbl_Sessions_id=" + session_id); avatarnum = new ArrayList(); while (avatarnumber.Read()) { for (var k = 0; k < avatarnumber.FieldCount; k++) { avatarnum.Add(avatarnumber.GetValue(k)); // This reads the entries in a row } } disableandenabletab(); disableandenabletab2(); PlayerOnClick(1); GameObject.Find("BtnPlayer" + nextactive).GetComponent <Image>().color = Color.blue; PlayerNameActive = GameObject.Find("numPlayerName").GetComponent <Text>().text; }
public void checkanswer() { string choice = EventSystem.current.currentSelectedGameObject.name; string playername = msg.PlayerNameActive; if (choice == "btnTrue") { choice = "True"; } else { choice = "False"; } if (choice == correctanswer) { // insert new data to history hismsg = playername + ", Your answer is CORRECT"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); hismsg = desc + " is TRUE statement"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); hismsg = "you receive " + reward + " for your reward"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); } else { // insert new data to history hismsg = playername + ", Your answer is WRONG"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); hismsg = desc + " is TRUE statement"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); hismsg = "you loss " + reward + " reward"; db.InsertHistory(hismsg, session_id); msg.HistPrint(hismsg); } GameObject.Find("TabCode").GetComponent <Tab>().Boardgame(); }