public void InitCombiner() // 조합창 열 때 초기설정 { // 변수 초기화 recipe = null; selectedChar = 0; btnCombine.interactable = false; combinable = false; // 캐릭터 작업중 UI 표시 for (int i = 0; i < 3; i++) { if (playerStates[i].IsWorking()) { BtnChars.transform.GetChild(i + 1).GetChild(1).gameObject.SetActive(true); } } costInfo.SetActive(false); itemInfo.SetActive(false); // 현재 선택된 캐릭터 기본 선택되도록 함, 미선택 시 첫 번째 아이로 설정 SelectChild(move.getMoveChar()); if (selectedChar == 0) { SelectChild(1); } // 만약 전체 컨트롤 하고 있을 시 통찰력 제일 높은 아이로 설정 if (selectedChar == 4) { int maxIndex = 0; for (int i = 0; i < playerStates.Count; i++) { if (playerStates[maxIndex].insight < playerStates[i].insight) { maxIndex = i; } } SelectChild(maxIndex + 1); } SetCharBtnSelected(selectedChar); SetRecipeBtn(); }
private void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePosition = Input.mousePosition; Ray ray = Camera.main.ScreenPointToRay(mousePosition); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && !EventSystem.current.IsPointerOverGameObject()) { if (hit.collider.gameObject.tag == "Object") // 채집 오브젝트 { clickedObj = hit.collider.gameObject; GetBtn.SetActive(true); // 클릭 시 채집 버튼 뜨도록 Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); GetBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); //GetBtn.transform.position = new Vector2(clickedObj.transform.position.x + 1, clickedObj.transform.position.y + 1); } else if (hit.collider.gameObject.tag == "Huntable") // 사냥 오브젝트 { // 새총 보유중인지 확인 int nowChar = move.getMoveChar(); if (ObjManager.objManager.inventory.getItemCount("sling", nowChar - 1) > 0) { clickedObj = hit.collider.gameObject; Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); // 상호작용 버튼 출력 huntBtn.SetActive(true); huntBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); } } else if (hit.collider.gameObject.tag == "Checkable") // 조사 오브젝트 { clickedObj = hit.collider.gameObject; checkBtn.SetActive(true); Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); checkBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); } else { GetBtn.SetActive(false); huntBtn.SetActive(false); checkBtn.SetActive(false); clickedObj = null; } } } if (clickedObj != null) { if (GetBtn.activeInHierarchy) { Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); GetBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); } if (huntBtn.activeInHierarchy) { Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); huntBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); } if (checkBtn.activeInHierarchy) { Vector3 objPos = Camera.main.WorldToScreenPoint(clickedObj.transform.position); checkBtn.transform.position = new Vector2(objPos.x + 40, objPos.y + 40); } } }