void Update() { //클릭이 UI위이면 그냥 return if (EventSystem.current.IsPointerOverGameObject()) { return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, _layerMask)) { GameObject ourHitObject = hitInfo.collider.transform.gameObject; if (ourHitObject.GetComponent <Hex>() != null && !ourHitObject.GetComponent <Hex>().thisBaseCamp&& NetworkRoundManager.isMyTurn) { //Debug.Log("Raycast hit: " + ourHitObject.name); if (Input.GetMouseButtonDown(0)) { //mr = ourHitObject.GetComponentInChildren<MeshRenderer>(); //ps = ourHitObject.GetComponentInChildren<ParticleSystem>(); //Debug.Log(ps); ourHitObject.GetComponentInChildren <ParticleSystem>(); if (choice_Map == false) { choice_Map_x = ourHitObject.GetComponent <Hex>().x; choice_Map_y = ourHitObject.GetComponent <Hex>().y; mr = ourHitObject.GetComponentInChildren <MeshRenderer>(); ps = ourHitObject.GetComponentInChildren <ParticleSystem>(); // 선택된 땅이 없으면 선택된 땅의 x, y값을 저장 후 색변환 ps.Play(); int tresh = NetworkRoundManager.public_Player_Id; mr.material.color = NetworkRoundManager.getMyColor(tresh); choice_Map = true; } // if(chice_map == true) 선택된 땅이 있다면 이전 선택된 x,y 와 비교 후 진행 else { // x, y값이 같으면 if (ourHitObject.GetComponent <Hex>().x == choice_Map_x && choice_Map_y == ourHitObject.GetComponent <Hex>().y) { if (ps.isPlaying == true) { ps.Stop(); ps.Clear(); } //녹색으로 다시 변환, Color로 변환을 할때에는 Unity에 색상표 / 255f 해줘야 보이는색으로 표현됨 int occTileId = GameObject.Find("EventSystem").GetComponent <EventManager>().getOccTiles(choice_Map_x, choice_Map_y); mr.material.color = NetworkRoundManager.getMyColor(occTileId); choice_Map = false; } // x, y값이 다르면 else { if (isMyMsg) { StartCoroutine("MsgNotice"); } } } } } if (Input.GetMouseButtonDown(1)) { right_choice_Map_x = ourHitObject.GetComponent <Hex>().x; right_choice_Map_y = ourHitObject.GetComponent <Hex>().y; if (EventManager.selectTiles[right_choice_Map_x][right_choice_Map_y].Count != 0) { if (war_onoff == false) { result_pannel.SetActive(true); // selectTiles x,y좌표확인후 0초과면 // playerid, cardid // locX, locY, 패널.setActive(true), //실행되야될 함수 : 패널==> locX, locY(화면 텍스트 위치표시 용도), for (int i = 0; i < EventManager.selectTiles[right_choice_Map_x][right_choice_Map_y].Count; i++) { Instantiate(War_prefab).transform.SetParent(GameObject.Find("war_result_Content").transform, false); } war_result_make(); } else { war_result_off(); } } else { war_result_off(); } } } }
// 타일 위치에 관한 이벤트 처리 IEnumerator RoundResult() { int occPlayerId, checkPlayer, checkCard; List <Tiles> resultTiles = new List <Tiles>(); //실행을 받으면 타일 하나씩 순회하면서 해당 타일의 최종 점령 playerId를 확인한다. //종료시점에 occPlayerId에 playerId를 넣고 occTile에 occPlayerId값을 입력, 종료시 타일 clear() for (int i = 0; i < tileLocX.Count; ++i) { resultTiles.Clear(); occPlayerId = 0; LocX = tileLocX[i]; LocY = tileLocY[i]; Debug.Log("<color=red>Prefab create : </color>" + LocX + ", " + LocY); PrefebManager.CreateArrowPrefeb(arrow_tile, LocX, LocY); SoundManager.instance.PlayArrowSound(); yield return(new WaitForSeconds(1)); SoundManager.instance.PlayArrowSound(); yield return(new WaitForSeconds(1)); MouseScripts.result_pannel_roundover(LocX, LocY); for (int j = 0; j < selectTiles[LocX][LocY].Count; ++j) { checkPlayer = selectTiles[LocX][LocY][j].playerId; checkCard = selectTiles[LocX][LocY][j].cardId; //사용 카드 처리 switch (checkCard) { case 1: //점령 { resultTiles.Add(new Tiles(checkPlayer, checkCard)); break; } case 2: //방어 { //방어카드를 사용한 플레이어의 땅이라면? if (occTiles[LocX, LocY] == checkPlayer) { int idx = 0; while (idx < resultTiles.Count) { if (resultTiles[idx].playerId != checkPlayer) { Debug.Log("삭제! " + resultTiles[idx].playerId); resultTiles.RemoveAt(idx); break; } ++idx; } } break; } case 3: //매수 { int idx = 0; while (idx < resultTiles.Count) { if (resultTiles[idx].cardId == 1) { resultTiles.RemoveAt(idx); } else { ++idx; } } resultTiles.Add(new Tiles(checkPlayer, checkCard)); break; } default: //블러핑 break; } } /* 게임창의 카드사용 개수가 * 3개 이하이면 2초 * 3개 초과이면 4초 * 7개 이상이면 6초 */ GameObject content_go = GameObject.Find("war_result_Content"); if (content_go.transform.childCount <= 10) { yield return(new WaitForSeconds(4)); } //if (content_go.transform.childCount <= 3) { // yield return new WaitForSeconds(2); //} //else if (3 < content_go.transform.childCount && content_go.transform.childCount < 6){ // yield return new WaitForSeconds(4); //} //else { yield return new WaitForSeconds(6); } MouseScripts.war_result_off(); //탐색이 끝난 타일 초기화 selectTiles[LocX][LocY].Clear(); //프리팹 삭제 PrefebManager.DestroyPrefebs(LocX, LocY); //변경값이 있는가 if (resultTiles.Count > 0) { Debug.Log($"({LocX} , {LocY}) = {resultTiles[0].playerId}"); occPlayerId = resultTiles[0].playerId; } //해당 타일 프리팹 생성 if (occPlayerId != 0) { occTiles[LocX, LocY] = occPlayerId; PrefebManager.CreatePrefeb(flag[occPlayerId - 1], LocX, LocY, NetworkRoundManager.getMyColor(occPlayerId)); } else if (occTiles[LocX, LocY] != 0) { int tempid = occTiles[LocX, LocY]; PrefebManager.CreatePrefeb(flag[tempid - 1], LocX, LocY, NetworkRoundManager.getMyColor(tempid)); } yield return(new WaitForSeconds(1)); } //최종적으로 player_count를 재탐색하고 타일 초기화 -> occTile에 따른 결과 반영 tileLocX.Clear(); tileLocY.Clear(); //라운드결과 종료 => 점령지, 점수 계산 RoundResultEnd(); NetworkRoundManager.nowRound += 1; Debug.Log("<color=red>nowRound, roundLimit : </color>" + NetworkRoundManager.nowRound + ", " + NetworkRoundManager.roundLimit); if (NetworkRoundManager.nowRound > NetworkRoundManager.roundLimit) { yield return(new WaitForSeconds(1)); if (GameOver.player_is_win == true) { SoundManager.instance.audioSource.Stop(); SoundManager.instance.PlayWinSound(); } else { SoundManager.instance.audioSource.Stop(); SoundManager.instance.PlayLoseSound(); } game_result_pannel.SetActive(true); } else { yield return(new WaitForSeconds(1)); //라운드 텍스트 이동 NetworkRoundManager.roundProcessBool = false; TweenMoveObj(); } }