Exemple #1
0
    private void OnMouseEnter()
    {
        if (!gm)
        {
            gm = FindObjectOfType <GameManager>();
        }

        if (gm.IsSceneBlocked())
        {
            return;
        }

        if (!so)
        {
            so = GetComponent <SpriteOutline>();
        }
        MagnifyingGlass magnifyingGlass = FindObjectOfType <MagnifyingGlass>();

        if (so && (!magnifyingGlass || magnifyingGlass && !magnifyingGlass.IsActive()))
        {
            so.EnableOutline();
        }
    }
Exemple #2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            MagnifyingGlass glass = FindObjectOfType <MagnifyingGlass>();
            if (glass)
            {
                glass.Disable();
            }
            ClearAction();
        }

        if (blockingLayer != null && blockingLayer.activeSelf)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.LeftAlt))
        {
            MagnifyingGlass glass = FindObjectOfType <MagnifyingGlass>();
            if (!glass || !glass.IsActive())
            {
                foreach (SpriteOutline so in FindObjectsOfType <SpriteOutline>())
                {
                    so.EnableOutline();
                }
            }
        }
        else if (Input.GetKeyUp(KeyCode.LeftAlt))
        {
            foreach (SpriteOutline so in FindObjectsOfType <SpriteOutline>())
            {
                so.DisableOutline();
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(new Vector2(
                                                     mainCamera.ScreenToWorldPoint(Input.mousePosition).x,
                                                     mainCamera.ScreenToWorldPoint(Input.mousePosition).y),
                                                 Vector2.zero, 100f, clickableMask, -Mathf.Infinity, Mathf.Infinity);

            if (hit)
            {
                Clickable clickable = hit.collider.GetComponent <Clickable>();

                if (clickable && clickable.enabled)
                {
                    Character c = hit.collider.GetComponent <Character>();
                    if (c && c.GetType() != typeof(Doggo))
                    {
                        ClearCurrentOutline();
                        if (c.OnClick(gm.GetSelectedAction()))
                        {
                            currentActionInfo.source = c;
                            currentActionInfo.target = null;
                            SetCurrentOutline();
                        }
                    }
                    else
                    {
                        if (currentActionInfo.source && !currentActionInfo.target)
                        {
                            currentActionInfo.target = clickable;
                        }
                    }
                }
            }

            if (currentActionInfo.source != null && currentActionInfo.target != null)
            {
                if (currentActionInfo.source.CanInteractWith(gm.GetSelectedAction(), currentActionInfo.target))
                {
                    currentActionInfo.source.Interact(gm.GetSelectedAction(), currentActionInfo.target);
                }
                else
                {
                    currentActionInfo.source.GetComponent <AudioSource>().clip = currentActionInfo.source.angryTrack;
                    currentActionInfo.source.GetComponent <AudioSource>().Play();
                }

                ClearAction();
            }
        }
    }