private void Update() { // Update money & hp player_money_go.GetComponent <Text>().text = player_money.ToString(); player_hp_go.GetComponent <Text>().text = player_hp.ToString(); player_round_go.GetComponent <Text>().text = round.ToString() + "/" + total_round.ToString(); // capture mouse click to pick selected Chessman UpdateSelection(); // Draw chess board DrawChessBoard(); // Display chessman info if (selectedChessman != null) { // if select any chessman, display chessman info ShowChessmanInfoCanvas(selectedChessman); } else { // if not, not display info panel if (pressed_inventory_chessman_id < 0 && pressed_shop_chessman_id < 0) { NotShowChessmanInfoCanvas(); } } // Detect new selection if (Input.GetMouseButtonDown(0)) { // Within ChessBoard area if (selectionX >= 0 && selectionY >= 0) { if (selectedChessman == null) { // select the chessman bool ret = SelectChessman(selectionX, selectionY); // if an empty space if (!ret) { if (this.game_phase == 0 && this.pressed_inventory_chessman_id >= 0 && selectionY < 4) { // inventory allows if (ButtonManagerScript.Instance.inventory_chessman_num[pressed_inventory_chessman_id] > 0) { this.SpawnChessman(pressed_inventory_chessman_id, selectionX, selectionY, chessman_spawn_z_height[pressed_inventory_chessman_id]); ButtonManagerScript.Instance.inventory_chessman_num[pressed_inventory_chessman_id] -= 1; this.pressed_inventory_chessman_id = -1; } } } } else { // de-select the chessman DeSelectChessman(); this.pressed_inventory_chessman_id = -1; this.pressed_shop_chessman_id = -1; } } else //not select any thing { DeSelectChessman(); selectedChessman = null; } } // gamephase = 1 : Fighting phase if (this.game_phase == 1 || this.game_phase == -1) { idx_update_i += 1; if (activechessman.Count > 0) { int i = idx_update_i % activechessman.Count; Chessman c = activechessman[i].GetComponent <Chessman>(); if (c != null) { c.AIAction(); } } bool to_end_phase = true; for (int i = 0; i < activechessman.Count; i++) { Chessman c = activechessman[i].GetComponent <Chessman>(); if (!c.come_to_end_phase) { to_end_phase = false; } } if (activechessman_white.Count == 0 || activechessman_black.Count == 0) { to_end_phase = true; } if (to_end_phase && this.game_phase == 1) { this.game_phase = 2; } } // anytime player hp < 0, end game if (this.game_phase == 1 && player_hp < 0) { this.game_phase = 2; } }