コード例 #1
0
    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;
    }
コード例 #2
0
 void DestroyActivePins()
 {
     if (activePinStringGrp != null)
     {
         activePinStringGrp.DestroyAll();
         activePinStringGrp = null;
         CursorMode         = DetectiveCursorMode.Idle;
     }
 }
コード例 #3
0
 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();
         }
     }
 }
コード例 #4
0
    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;
        }
    }
コード例 #5
0
 public void MovePin(PingString pinGrp)
 {
     activePinStringGrp = pinGrp;
     CursorMode         = DetectiveCursorMode.MovingPin;
 }