c# 猜拳小遊戲,加屏幕跳轉

public class youxi : MonoBehaviour {

    public Rect r1=new Rect(250,100,400,200);
    public Rect r2=new Rect(250,330,400,200);
//    public Texture t1;
//    public Texture t2;
//    public Texture t3;

    public Texture[] txtures;
    public int computercp;
    public int playercp;
    public string result;
    public bool showtime=true;
    public float maxtime=1;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
        if (showtime) {
            computerShow ();
        } else {
            maxtime-=Time.deltaTime;
            if(maxtime<0){
                showtime=true;
                maxtime = 1;
            }
        }
    }
    void computerShow()
    {
        if(computercp<2){
            computercp++;
        }else {
            computercp=0;
        }
    }
    void OnGUI(){
        GUI.Label (new Rect(410,20,100,30),result);


        r1=GUI.Window (0r1windFan1"computer vs player");
        r2=GUI.Window(1,r2,winFand2,"player");

        if (GUI.Button (new Rect (700010030), "返回")) {       //這裏是跳轉到別的地方
            Application.LoadLevel("chang1");
        }
        if (GUI.Button (new Rect (70010010030), "wu liao")) {
            Application.LoadLevel("chang3");
        }
    }
    void windFan1(int Id){
        GUI.Box(new Rect (30,30,150,150),txtures[computercp]);
        GUI.Box(new Rect (220,30,150,150),txtures[playercp]);

        GUI.DragWindow (new Rect (0045030));
    }
    void winFand2(int Id){
        if (GUI.Button (new Rect (3030100100), txtures [0])) {
            playercp=0;
            computerchupai();
            panding();
        }
        if (GUI.Button (new Rect (15030100100), txtures [1])) {
            playercp=1;
            computerchupai();
            panding();
        }
        if (GUI.Button (new Rect (27030100100), txtures [2])) {
            playercp=2;
            computerchupai();
            panding();
        }
        GUI.DragWindow (new Rect (0045030));
    }

    void computerchupai(){
        showtime = false;
    
        computercp = Random.Range (03);
    }
    void panding(){
        if (computercp - playercp == 0) {
            result = "好可惜,平局";
        } else if (computercp - playercp== -1||computercp - playercp == 2) {
            result ="好遺憾,再來一次";
        } else if(computercp - playercp == 1||computercp - playercp == -2){
            result ="真棒,你贏了";
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章