Exemplo n.º 1
0
    public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
    {
        if (bIsSpinning)
        {
            return;
        }

        gameObject.transform.SetParent(hitDrawer.transform);

        List <SpriteRenderer> renderers = new List <SpriteRenderer>(GetComponentsInChildren <SpriteRenderer>());

        for (int i = 0; i < renderers.Count; ++i)
        {
            renderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            renderers[i].sortingOrder    = 1;
        }
        List <TextMeshPro> textrenderers = new List <TextMeshPro>(GetComponentsInChildren <TextMeshPro>());

        for (int i = 0; i < textrenderers.Count; ++i)
        {
            textrenderers[i].sortingOrder = 1;
        }
        List <ParticleSystemRenderer> particleRenderers = new List <ParticleSystemRenderer>(GetComponentsInChildren <ParticleSystemRenderer>());

        for (int i = 0; i < particleRenderers.Count; ++i)
        {
            particleRenderers[i].sortingOrder = 2;
        }
        Vector3 tmp = gameObject.transform.localPosition;

        tmp.z = -1;
        gameObject.transform.localPosition = tmp;

        ItemStatus.DrawerStatus = hitDrawer.Type;
    }
Exemplo n.º 2
0
    public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
    {
        gameObject.transform.SetParent(hitDrawer.transform);

        List <SpriteRenderer> renderers = new List <SpriteRenderer>(GetComponentsInChildren <SpriteRenderer>());

        for (int i = 0; i < renderers.Count; ++i)
        {
            renderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            renderers[i].sortingOrder    = 1;
        }
        for (int i = 0; i < TextComponents.Count; ++i)
        {
            TextComponents[i].sortingOrder = 1;
            TextComponents[i].gameObject.SetActive(false);
        }
        Vector3 tmp = gameObject.transform.localPosition;

        tmp.z = -1;
        gameObject.transform.localPosition = tmp;

        gameObject.transform.eulerAngles = RotationDrawerEuler;

        ItemStatus.DrawerStatus = hitDrawer.Type;
    }
Exemplo n.º 3
0
    private void Awake()
    {
        switch (Type)
        {
        case ELeftOrRight.Left:
            instanceLeft = this;
            break;

        case ELeftOrRight.Right:
            instanceRight = this;
            break;
        }
    }
Exemplo n.º 4
0
    public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
    {
        gameObject.transform.SetParent(hitDrawer.transform);


        for (int i = 0; i < AllRenderers.Count; ++i)
        {
            AllRenderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            AllRenderers[i].sortingOrder    = 1;
        }
        Vector3 tmp = gameObject.transform.localPosition;

        tmp.z = -1;
        gameObject.transform.localPosition = tmp;

        ItemStatus.DrawerStatus = hitDrawer.Type;
    }
Exemplo n.º 5
0
    public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
    {
        if (Status == EPaperworkStatus.FOCUS)
        {
            return;
        }

        ParticleInside.gameObject.SetActive(false);
        ParticleEcology.gameObject.SetActive(false);
        ParticlePeace.gameObject.SetActive(false);
        ParticleProsperity.gameObject.SetActive(false);
        ParticleHealth.gameObject.SetActive(false);

        gameObject.transform.SetParent(hitDrawer.transform);

        List <SpriteRenderer> renderers = new List <SpriteRenderer>(GetComponentsInChildren <SpriteRenderer>());

        for (int i = 0; i < renderers.Count; ++i)
        {
            renderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            renderers[i].sortingOrder    = 1;
        }
        List <TextMeshPro> textrenderers = new List <TextMeshPro>(GetComponentsInChildren <TextMeshPro>());

        for (int i = 0; i < textrenderers.Count; ++i)
        {
            textrenderers[i].sortingOrder = 1;
        }
        List <ParticleSystemRenderer> particleRenderers = new List <ParticleSystemRenderer>(GetComponentsInChildren <ParticleSystemRenderer>());

        for (int i = 0; i < particleRenderers.Count; ++i)
        {
            particleRenderers[i].sortingOrder = 1;
        }
        Vector3 tmp = gameObject.transform.localPosition;

        tmp.z = -1.1f;
        gameObject.transform.localPosition = tmp;

        ItemStatus.DrawerStatus = hitDrawer.Type;
    }
Exemplo n.º 6
0
    public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
    {
        gameObject.transform.SetParent(hitDrawer.transform);

        for (int i = 0; i < Renderers.Count; ++i)
        {
            Renderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            Renderers[i].sortingOrder    = 1;
        }
        List <TextMeshPro> textrenderers = new List <TextMeshPro>(GetComponentsInChildren <TextMeshPro>());

        for (int i = 0; i < textrenderers.Count; ++i)
        {
            textrenderers[i].sortingOrder = 1;
        }
        Vector3 tmp = gameObject.transform.localPosition;

        tmp.z = -0.9f;
        gameObject.transform.localPosition = tmp;

        ItemStatus.DrawerStatus = hitDrawer.Type;
    }
Exemplo n.º 7
0
 public void HandleDropIntoDrawer(GrimDeskDrawer hitDrawer)
 {
 }
Exemplo n.º 8
0
    private void HandleInteractableInput(bool bLeftMouseDown, bool bLeftMouseUp)
    {
        //int layerMask = 1 << LayerMask.NameToLayer("Container");
        Ray          ray             = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit             = Physics2D.GetRayIntersection(ray, Mathf.Infinity);
        Interactable hitInteractable = null;

        if (hit.collider != null)
        {
            //hitInteractable = (Interactable)hit.collider.gameObject.GetComponent(typeof(Interactable));
            //if(hitInteractable == null)
            //{
            //}
            hitInteractable = (Interactable)hit.collider.gameObject.GetComponentInParent(typeof(Interactable));
            //TODO: remove
            //Draggable newDraggable = hit.collider.gameObject.GetComponentInParent<Draggable>();
            //if (CurrentDraggable != null && CurrentDraggable != newDraggable)
            //{
            //    CurrentDraggable.ToggleDragging(false);
            //}

            if (hitInteractable != null && LastHitInteractable != hitInteractable)
            {
                if (LastHitInteractable != null)
                {
                    LastHitInteractable.Unhover();
                }
                LastHitInteractable = hitInteractable;
                if (LastHitInteractable != null)
                {
                    LastHitInteractable.Hover();
                }
                HUDManager.instance.SetHoverText(hitInteractable.GetHoverText());
            }
            else
            {
            }
        }
        else
        {
            //TODO: remove
            //if (CurrentDraggable != null)
            //{
            //    CurrentDraggable.ToggleDragging(false);
            //}

            if (LastHitInteractable != null)
            {
                LastHitInteractable.Unhover();
            }

            HUDManager.instance.SetHoverText("");
            LastHitInteractable = null;
        }

        // once
        if (bLeftMouseDown && !IsPointerOverUIObject() && hit.collider != null)
        {
            DragStart        = Input.mousePosition;
            CurrentDraggable = hit.collider.gameObject.GetComponentInParent <Draggable>();
            if (CurrentDraggable != null && CurrentDraggable.CanDrag())
            {
                CurrentDraggable.UpdateDragGrabPosition(hit.point);
            }

            MouseDownInteractable = hit.collider.gameObject.GetComponentInParent <Interactable>();
        }


        // continous
        if (Input.GetMouseButton(0))
        {
            if (Vector3.Distance(DragStart, Input.mousePosition) >= 15.0f)
            {
                if (CurrentDraggable != null && CurrentDraggable.CanDrag())
                {
                    if (!CurrentDraggable.IsDragging())
                    {
                        //CurrentDraggable.UpdateDragGrabPosition(hit.point);
                        CurrentDraggable.ToggleDragging(true);
                    }

                    int            layerMaskDrag = 1 << LayerMask.NameToLayer("Drawer");
                    Ray            rayDrag       = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit2D   hitDrag       = Physics2D.GetRayIntersection(rayDrag, Mathf.Infinity, layerMaskDrag);
                    GrimDeskDrawer hitDrawer     = null;

                    if (hitDrag.collider != null)
                    {
                        //Debug.Log("drag hit: " + hitDrag.collider.gameObject);

                        //hitInteractable = (Interactable)hit.collider.gameObject.GetComponent(typeof(Interactable));
                        //if(hitInteractable == null)
                        //{
                        //}
                        hitDrawer = hitDrag.collider.gameObject.GetComponentInParent <GrimDeskDrawer>();
                        if (hitDrawer != null)
                        {
                            if (hitDrawer.IsOpen())
                            {
                                CurrentDraggable.HandleDropIntoDrawer(hitDrawer);
                            }
                        }
                        else
                        {
                            CurrentDraggable.HandleDragOutOfDrawer();
                        }
                    }
                    else
                    {
                        CurrentDraggable.HandleDragOutOfDrawer();
                    }
                }
            }
        }

        // once
        if (bLeftMouseUp && !IsPointerOverUIObject())
        {
            DragEnd = Input.mousePosition;

            if (hitInteractable != null)
            {
                if (MouseDownInteractable == hitInteractable)
                {
                    if (CurrentDraggable != null)
                    {
                        if (Vector3.Distance(DragStart, DragEnd) < 15.0f)
                        {
                            hitInteractable.Interact();
                        }
                    }
                    else
                    {
                        if (hit.collider.gameObject.GetComponentInParent <Phone>())
                        {
                            if (Vector3.Distance(DragStart, DragEnd) < 15.0f)
                            {
                                hitInteractable.Interact();
                            }
                        }
                        else
                        {
                            hitInteractable.Interact();
                        }
                    }
                }
                MouseDownInteractable = null;
            }
            else
            {
                if (MarkerOfDeath.instance.IsPickedUp())
                {
                    MarkerOfDeath.instance.Interact();
                }
                else if (Eraser.instance.IsPickedUp())
                {
                    Eraser.instance.Interact();
                }
                else
                {
                }
            }
            if (CurrentDraggable != null)
            {
                if (CurrentDraggable.IsDragging())
                {
                    CurrentDraggable.ToggleDragging(false);
                    Paperwork draggedPaperwork = CurrentDraggable as Paperwork;
                    if (draggedPaperwork != null && draggedPaperwork.Status == EPaperworkStatus.DESK)
                    {
                        int          layerMaskDrag = 1 << LayerMask.NameToLayer("Fax");
                        RaycastHit2D hitFax        = Physics2D.Raycast(draggedPaperwork.gameObject.transform.position, Vector2.down, Mathf.Infinity, layerMaskDrag);
                        if (hitFax.collider != null)
                        {
                            FaxMachine misterfaxobeat = hitFax.collider.gameObject.GetComponent <FaxMachine>();
                            if (misterfaxobeat != null && !misterfaxobeat.IsInDrawer())
                            {
                                misterfaxobeat.Interact();
                            }
                        }
                        else
                        {
                            hitFax = Physics2D.Raycast(draggedPaperwork.FaxTraceMarker.gameObject.transform.position, Vector2.down, Mathf.Infinity, layerMaskDrag);
                            if (hitFax.collider != null)
                            {
                                FaxMachine misterfaxobeat = hitFax.collider.gameObject.GetComponent <FaxMachine>();
                                if (misterfaxobeat != null)
                                {
                                    misterfaxobeat.Interact();
                                }
                            }
                        }
                    }
                    SaveManager.instance.MarkSavegameDirty();
                }
                CurrentDraggable = null;
            }
        }
    }