public void onClick() { HandleUsrScissors usrScissors = GameObject.Find("usr_scissors").GetComponent <HandleUsrScissors>(); HandleUsrRock usrRock = GameObject.Find("usr_rock").GetComponent <HandleUsrRock>(); HandleUsrPaper usrPaper = GameObject.Find("usr_paper").GetComponent <HandleUsrPaper>(); usrScissors.move_to(); usrRock.move_to(); usrPaper.move_to(); transform.position = new Vector3(25f, 25f, 0f); }
public void play_game(string usr_fist = "Scissors") { HandleUsrScissors usrScissors = GameObject.Find("usr_scissors").GetComponent <HandleUsrScissors>(); HandleUsrRock usrRock = GameObject.Find("usr_rock").GetComponent <HandleUsrRock>(); HandleUsrPaper usrPaper = GameObject.Find("usr_paper").GetComponent <HandleUsrPaper>(); HandleRobotScissors robotScissors = GameObject.Find("robot_scissors").GetComponent <HandleRobotScissors>(); HandleRobotRock robotRock = GameObject.Find("robot_rock").GetComponent <HandleRobotRock>(); HandleRobotPaper robotPaper = GameObject.Find("robot_paper").GetComponent <HandleRobotPaper>(); int robot_fist_code, usr_fist_code = 0; switch (usr_fist) { case "Scissors": usr_fist_code = 1; usr_fist_history.Add(1); usrRock.init(); usrPaper.init(); usrScissors.move_to(0f, -1.5f); break; case "Rock": usr_fist_code = 2; usr_fist_history.Add(0); usrPaper.init(); usrScissors.init(); usrRock.move_to(0f, -2f); break; case "Paper": usr_fist_code = 3; usr_fist_history.Add(2); usrRock.init(); usrScissors.init(); usrPaper.move_to(0f, -2.2f); break; } robot_fist_code = getRobotFistCode(); switch (robot_fist_code) { case 1: robotScissors.move_to(); robotScissors.setRigidbodyWakeUp(true); break; case 2: case -1: robotRock.move_to(); robotRock.setRigidbodyWakeUp(true); break; case 3: robotPaper.move_to(); robotPaper.setRigidbodyWakeUp(true); break; } // ====Fist Code==== // code 1: Scissors // code 2: Rock // code 3: Paper // ================= int tmp = usr_fist_code - robot_fist_code; if (tmp == 1 || tmp == -2) { usr_score++; updateScoreBoard(); Mibo.startTTS("恭喜你贏了,耶"); Mibo.motionPlay("666_SP_HorizontalBar"); } else if (tmp == 0) { Mibo.startTTS("平手,看來我們不相上下呢"); // DRAW } else { robot_score++; updateScoreBoard(); Mibo.startTTS("唉呀,你輸了,加把勁"); Mibo.motionPlay("666_PE_Phubbing"); } }