bool Move_tile(ulong x, ulong y, ushort player) { if (GameManager.position == (ulong)player) { MarkManager.MarkErasing((ushort)player); Vector3 center = (GameManager.Nowposobj.transform.localPosition + MatrixManager.Maps[y][x].transform.localPosition) * 0.5f; if (MatrixManager.Maps[y][x].transform.localPosition.x == GameManager.Nowposobj.transform.localPosition.x) { center.x -= 1f; if (GameManager.Nowposobj.transform.localPosition.y < MatrixManager.Maps[y][x].transform.localPosition.y) { if (!GameManager.mychar.transform.GetChild(1).gameObject.activeSelf) { GameManager.mychar.transform.GetChild(0).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(1).gameObject.SetActive(true); GameManager.mychar.transform.GetChild(2).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(3).gameObject.SetActive(false); } } } else { if (GameManager.Nowposobj.transform.localPosition.x > MatrixManager.Maps[y][x].transform.localPosition.x) { if (!GameManager.mychar.transform.GetChild(2).gameObject.activeSelf) { GameManager.mychar.transform.GetChild(0).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(1).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(2).gameObject.SetActive(true); GameManager.mychar.transform.GetChild(3).gameObject.SetActive(false); } } else { if (!GameManager.mychar.transform.GetChild(3).gameObject.activeSelf) { GameManager.mychar.transform.GetChild(0).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(1).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(2).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(3).gameObject.SetActive(true); } } center.y -= 1f; } // 클릭한 위치와 본인의 위치가 같을 경우 함수 탈출 if (GameManager.Nowposobj.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { return(true); } // Sleap 구현을 위해 출발점과 도착점의 센터점을 지정 // 윗줄에서 center 선언 // Vector3 center = (GameManager.Nowposobj.transform.localPosition + MatrixManager.Maps[y][x].transform.localPosition) * 0.5f; Vector3 RelCenter = GameManager.Nowposobj.transform.localPosition - center; Vector3 aimRelCenter = MatrixManager.Maps[y][x].transform.localPosition - center; // 처음 한번만 divide와 startTime을 지정해 Time.time이 늘어나면서 fracComplete 변수가 1이 될 때까지 실행(도착 까지) if (divide == 0) { divide = Vector3.Distance( GameManager.Nowposobj.transform.localPosition, MatrixManager.Maps[y][x].transform.localPosition) * 0.2f; startTime = Time.time; } // divide가 클 수록 천천히 증가 float fracComplete = (Time.time - startTime) / divide; // 최소 최대 지정 Mathf.Clamp(fracComplete, 0, 1); if (fracComplete != 0) { GameManager.mychar.transform.localPosition = Vector3.Slerp(RelCenter, aimRelCenter, fracComplete); GameManager.mychar.transform.localPosition += center; } // 도착하면 divide 초기화 if (GameManager.mychar.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { divide = 0; } if (GameManager.mychar.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { Manager_Sound.Instance.Play_SE(SE_INDEX.TILE_CHANGE); GameManager.mychar.transform.GetChild(0).gameObject.SetActive(true); GameManager.mychar.transform.GetChild(1).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(2).gameObject.SetActive(false); GameManager.mychar.transform.GetChild(3).gameObject.SetActive(false); GameManager.Nowposobj = MatrixManager.Maps[y][x]; GameManager.Nowpos = new Vector3(GameManager.Nowposobj.transform.localPosition.x, GameManager.Nowposobj.transform.localPosition.y, GameManager.Nowposobj.transform.localPosition.z); t = 0f; //player = -1; return(true); } } else { return(true); } return(false); }
bool other_Move_tile(ulong x, ulong y, ushort player) { if (GameManager.other_position == (ulong)player) { MarkManager.MarkErasing((ushort)player); Vector3 center = (GameManager.Nowotherobj.transform.localPosition + MatrixManager.Maps[y][x].transform.localPosition) * 0.5f; if (MatrixManager.Maps[y][x].transform.localPosition.x == GameManager.Nowotherobj.transform.localPosition.x) { center.x -= 1f; if (GameManager.Nowotherobj.transform.localPosition.y < MatrixManager.Maps[y][x].transform.localPosition.y) { if (!GameManager.otherchar.transform.GetChild(1).gameObject.activeSelf) { GameManager.otherchar.transform.GetChild(0).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(1).gameObject.SetActive(true); GameManager.otherchar.transform.GetChild(2).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(3).gameObject.SetActive(false); } } } else { if (GameManager.Nowotherobj.transform.localPosition.x > MatrixManager.Maps[y][x].transform.localPosition.x) { if (!GameManager.otherchar.transform.GetChild(2).gameObject.activeSelf) { GameManager.otherchar.transform.GetChild(0).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(1).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(2).gameObject.SetActive(true); GameManager.otherchar.transform.GetChild(3).gameObject.SetActive(false); } } else { if (!GameManager.otherchar.transform.GetChild(3).gameObject.activeSelf) { GameManager.otherchar.transform.GetChild(0).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(1).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(2).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(3).gameObject.SetActive(true); } } center.y -= 1f; } if (GameManager.Nowotherobj.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { return(true); } Vector3 RelCenter = GameManager.Nowotherobj.transform.localPosition - center; Vector3 aimRelCenter = MatrixManager.Maps[y][x].transform.localPosition - center; if (divide == 0) { divide = Vector3.Distance( GameManager.Nowotherobj.transform.localPosition, MatrixManager.Maps[y][x].transform.localPosition) * 0.2f; startTime = Time.time; } float fracComplete = (Time.time - startTime) / divide; Mathf.Clamp(fracComplete, 0, 1); if (fracComplete != 0) { GameManager.otherchar.transform.localPosition = Vector3.Slerp(RelCenter, aimRelCenter, fracComplete); GameManager.otherchar.transform.localPosition += center; } if (GameManager.otherchar.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { divide = 0; } //if (t < 1f) //{ // t += 0.04f; //} //else //{ // t = 0f; //} if (GameManager.otherchar.transform.localPosition == MatrixManager.Maps[y][x].transform.localPosition) { Manager_Sound.Instance.Play_SE(SE_INDEX.TILE_CHANGE); GameManager.otherchar.transform.GetChild(0).gameObject.SetActive(true); GameManager.otherchar.transform.GetChild(1).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(2).gameObject.SetActive(false); GameManager.otherchar.transform.GetChild(3).gameObject.SetActive(false); GameManager.Nowotherobj = MatrixManager.Maps[y][x]; GameManager.Nowotherpos = new Vector3(GameManager.Nowotherobj.transform.localPosition.x, GameManager.Nowotherobj.transform.localPosition.y, GameManager.Nowotherobj.transform.localPosition.z); t = 0f; //player = -1; return(true); } } else { return(true); } return(false); }