public void CloseCharacterInfoPanel() { if (villagerReference) { //villagerReference.gameObject.GetComponent<Renderer>().material.SetFloat("_Outline", 0.0f); villagerReference.SetSelected(false); villagerReference = null; } characterPanel.SetActive(false); }
public virtual void SelectCharacter(BaseVillager chosenVillager) { if (settingUpQuest) { characterScroll.GetComponent <CharacterDisplay>().GetActiveQuest().AddCharacter(chosenVillager); ToggleQuestMenu(false); ToggleCharacterMenu(); settingUpQuest = false; } else if (addingToBuilding) { buildingInfo.GetComponentInChildren <BuildingDisplay>().AddCharacter(chosenVillager, buildingButtonIndex); ToggleCharacterMenu(); ToggleBuildingInfo(); addingToBuilding = false; } else { chosenVillager.SetSelected(true); controller.SetVillagerReference(chosenVillager); controller.OpenCharacterInfoPanel(); ToggleCharacterMenu(); } }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { baseManager.TogglePauseMenu(isPaused); isPaused = !isPaused; } if (!isPaused) { if (Input.GetKeyDown(KeyCode.Mouse1)) { CloseAllMenus(); selectedObject = null; villagerReference = null; buildingReference = null; resourceReference = null; } if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetKeyDown(KeyCode.Mouse0)) { //Debug.Log ("Mouse Click"); selectedObject = FindObjectUnderMouse(); if (selectedObject != null) { //Debug.Log ("Object Selected"); if (selectedObject.GetComponent <BaseVillager>()) { //Debug.Log ("Villager Found"); if (villagerReference == null) { villagerReference = selectedObject.GetComponent <BaseVillager>(); villagerReference.SetSelected(true); OpenCharacterInfoPanel(); } else { CloseCharacterInfoPanel(); } if (buildingReference != null) { CloseBuildingInfoPanel(); } } else if (selectedObject.GetComponent <ResourceTile>()) { //Debug.Log ("Resources Found"); resourceReference = selectedObject.GetComponent <ResourceTile>(); if (villagerReference != null) { //Debug.Log ("Setting Work Area (Controller)"); villagerReference.SelectWorkArea(resourceReference.gameObject); CloseCharacterInfoPanel(); } if (buildingReference != null) { CloseBuildingInfoPanel(); } resourceReference = null; } else if (selectedObject.GetComponent <BaseBuilding>()) { //Debug.Log ("Building Found"); if (buildingReference != null) { //Close panel and remove reference CloseBuildingInfoPanel(); } else { //Set building reference and open info panel buildingReference = selectedObject.GetComponent <BaseBuilding>(); if (buildingReference.IsBuilt() == true) { OpenBuildingInfoPanel(); } else { buildingReference = null; } } if (villagerReference != null) { //buildingReference.OnClicked(villagerReference); CloseCharacterInfoPanel(); } } else if (villagerReference != null) { Ray hitPosition = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(hitPosition, out hit, Mathf.Infinity)) { villagerReference.SetTargetPosition(new Vector3(hit.point.x, 0, hit.point.z)); } CloseCharacterInfoPanel(); } } else { //Debug.Log ("Object is null"); } } } } }