public void game_finish() { AI_control.SetActive(false); red_goal_UI.SetActive(false); blue_goal_UI.SetActive(false); king_UI.SetActive(false); blue_goal.GetComponent <Text>().text = "藍隊目標墩數:" + blue_goal_score; red_goal.GetComponent <Text>().text = "紅隊目標墩數:" + red_goal_score; red_team_score.GetComponent <Text>().text = "紅隊獲得墩數:" + red_score; blue_team_score.GetComponent <Text>().text = "藍隊獲得墩數:" + blue_score; }
public void Startcard() { //將各項變數重製更新 short[,] playerindex = new short[4, 13]; short[] index = new short[52]; short b, k, temp, i, f, rcard; player = new GameObject[4, 13]; rcard = 52; handcardnum = new int[] { 13, 13, 13, 13 }; table_card = new GameObject[4]; player_in_game = new GameObject[4, 13]; call_number = 1; temp_king = 0; pass = 0; table_card_number = 0; call_card_finish = false; blue_score = 0; red_score = 0; for (i = 0; i < 4; i++) { playerUI[i].SetActive(true); player_call_card[i].SetActive(true); player_call_card[i].GetComponent <Text>().text = "尚未喊牌"; }//重製各玩家的喊牌狀況UI red_goal_UI.SetActive(false); blue_goal_UI.SetActive(false); king_UI.SetActive(false); //AI模式的設定 if (AI_mode == true) { AI_control.SetActive(true); foreach (GameObject h in number_button) { h.GetComponent <Button>().interactable = true; } foreach (GameObject h in color_button) { h.GetComponent <Button>().interactable = true; } } if (net_mode == true) { GameObject[] player = new GameObject[4]; } color_distribute();//把每張牌標上花色 //隨機分配各張牌的index到各玩家手中 for (i = 0; i < 52; i++) { index[i] = i; } for (i = 0; i < 52; i++) { b = (short)Random.Range(0, rcard); if (i < 13) { playerindex[0, i] = index[b]; } else if (i < 26) { playerindex[1, i - 13] = index[b]; } else if (i < 39) { playerindex[2, i - 26] = index[b]; } else { playerindex[3, i - 39] = index[b]; } rcard--; for (k = b; k < rcard; k++) { index[k] = index[k + 1]; } } for (k = 0; k < 4; k++) { for (b = 0; b < 12; b++) { for (f = 0; f < 12 - b; f++) { if (playerindex[k, f] > playerindex[k, f + 1]) { temp = playerindex[k, f]; playerindex[k, f] = playerindex[k, f + 1]; playerindex[k, f + 1] = temp; } } }//把每位玩家手中的牌的index排序 for (i = 0; i < 13; i++) { Instantiate(Poker[playerindex[k, i]], new Vector2(-0.63f, 0.09f), Quaternion.identity); player[k, i] = GameObject.Find(Poker[playerindex[k, i]].name + "(Clone)"); player[k, i].transform.Rotate(new Vector3(0, 0, 90 * k)); player[k, i].gameObject.GetComponent <SpriteRenderer>().sortingOrder = i; if (k == 0) { player[k, i].transform.position = new Vector2(leftcardhorizonpos[k] + i * (handcardlength[k] / 12), cardverticalpos[k]); player[k, i].transform.localScale = cardnormalscale[k]; } if (k == 1) { player[k, i].transform.position = new Vector2(cardverticalpos[k], leftcardhorizonpos[k] + i * (handcardlength[k] / 12)); player[k, i].transform.localScale = cardnormalscale[k]; } if (k == 2) { player[k, i].transform.position = new Vector2(leftcardhorizonpos[k] - i * (handcardlength[k] / 12), cardverticalpos[k]); player[k, i].transform.localScale = cardnormalscale[k]; } if (k == 3) { player[k, i].transform.position = new Vector2(cardverticalpos[k], leftcardhorizonpos[k] - i * (handcardlength[k] / 12)); player[k, i].transform.localScale = cardnormalscale[k]; } player[k, i].AddComponent <BoxCollider2D>(); player[k, i].GetComponent <BoxCollider2D>().isTrigger = true; if (AI_mode == false) { player[k, i].AddComponent <mousecontrol>(); } else if (k == 0) { player[k, i].AddComponent <mousecontrol>(); } player_in_game[k, i] = player[k, i]; } //依照index把各張牌分配到各玩家手中,並設好位置、屬性 } //把每位玩家手中的牌的index排序,並依照index把各張牌分配到各玩家手中,並設好位置、屬性 for (i = 1; i < 4; i++) { if (count_card_point(i, "clover") + count_card_point(i, "diamond") + count_card_point(i, "heart") + count_card_point(i, "spade") < 4) { restart_button.GetComponent <Button>().onClick.Invoke(); } } //倒牌機制 } //開始一場遊戲,重製各項數據,把牌發好整理到各玩家手中