public void ToggleDetectiveWallVisibility() { if (!DetectiveWallOpened) { detectiveWallAnimator.Play("Open"); detectiveWallCanvasGroup.interactable = true; detectiveWallCanvasGroup.blocksRaycasts = true; DetectiveWallOpened = true; if (DetectiveWallOpens != null) { DetectiveWallOpens(); } } else { detectiveWallAnimator.Play("Close"); detectiveWallCanvasGroup.interactable = false; detectiveWallCanvasGroup.blocksRaycasts = false; DetectiveWallOpened = false; DestroyActivePins(); } CursorMode = DetectiveCursorMode.Idle; activePinStringGrp = null; }
void Start() { DialogManager.OnAddLogEntry += AddLogEntry; LogLeftPage_SingleEntry.OnEntryButtonPressed += ButtonClicked; CursorMode = DetectiveCursorMode.Idle; logCanvasGroup.alpha = 0; UpdateArrowsVisibility(); }
void DestroyActivePins() { if (activePinStringGrp != null) { activePinStringGrp.DestroyAll(); activePinStringGrp = null; CursorMode = DetectiveCursorMode.Idle; } }
void DetectiveWallUpdate() { //Pinning if (CursorMode == DetectiveCursorMode.Idle || CursorMode == DetectiveCursorMode.Pinning) { //Try pinning if (Input.GetMouseButtonDown(0)) { TryPinning(); } //Change color else if (Input.GetMouseButtonDown(1)) { if (activePinStringGrp != null) { activePinStringGrp.ToggleColor(); } } } //Destroy pin else if (CursorMode == DetectiveCursorMode.Pinning && Input.GetKeyDown(KeyCode.Escape)) { DestroyActivePins(); CursorMode = DetectiveCursorMode.Idle; } //Moving pin else if (CursorMode == DetectiveCursorMode.MovingPin) { //Finish moving if (Input.GetMouseButtonUp(0)) { //maybe put these in a seperate TryFinishMovePin() method activePinStringGrp.FinishMoving(); activePinStringGrp = null; CursorMode = DetectiveCursorMode.Idle; } //Change color else if (Input.GetMouseButtonDown(1)) { activePinStringGrp.ToggleColor(); } //Destroy else if (Input.GetKeyDown(KeyCode.Escape)) { DestroyActivePins(); } } }
void TryPinning() { //Do a raycast to see what kind of object is being hit. PointerEventData pointerData = new PointerEventData(EventSystem.current); pointerData.position = Input.mousePosition; List <RaycastResult> raycastResults = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointerData, raycastResults); //print("raycastResults.Count: " + raycastResults.Count); foreach (var obj in raycastResults) { if ((CursorMode == DetectiveCursorMode.Idle && obj.gameObject.tag == "DWall_Pins") || obj.gameObject.tag == "DWall_QuitButton") { return; } } if (CursorMode != DetectiveCursorMode.Pinning) { //print("Start"); GameObject pinStringGo = Instantiate(pinStringPf, Input.mousePosition, Quaternion.identity, detectiveWallCanvasGroup.transform) as GameObject; activePinStringGrp = pinStringGo.GetComponent <PingString>(); activePinStringGrp.BeginPlacement(this); CursorMode = DetectiveCursorMode.Pinning; } else if (CursorMode == DetectiveCursorMode.Pinning && activePinStringGrp != null) { //print("Finished"); activePinStringGrp.FinishPlacement(); activePinStringGrp = null; CursorMode = DetectiveCursorMode.Idle; } }
public void MovePin(PingString pinGrp) { activePinStringGrp = pinGrp; CursorMode = DetectiveCursorMode.MovingPin; }