Beispiel #1
0
    void InteractWithNPC(ref NPCInteractionController npc)
    {
        if (npc != null)
        {
            comicController.SetComicAndMinigame(ref npc.comic, npc.minigameSceneName);
            comicController.DisplayComicAndShiftCam();
            gameMode = GameMode.COMIC;
        }

        UpdateInteractability();         // Unhighlight NPC
        alpaca.StopWalk();
    }
Beispiel #2
0
    Block lastHighlightBlock = null;     // used to unhighlight block in front
    void UpdateInteractability()
    {
        Vector3 dest = alpaca.GetCurrAlpacaDest(clickedWhere);
        Block   prevHighlightBlock = lastHighlightBlock; // block looked at in the last frame

        lastHighlightBlock = GetBlockAt(dest);           // block currently being looked at

        // Process interactability and highlighting for the block currently being viewed
        switch (gameMode)
        {
        case GameMode.WALKING:                 // UpdateInteractability() called on loop when in this gameMode

            // Looked away from last block
            if (prevHighlightBlock != null && prevHighlightBlock != lastHighlightBlock)
            {
                // Dehighlight previously highlighted block
                if (prevHighlightBlock.isBlockHighlighted())
                {
                    prevHighlightBlock.Unhighlight();
                }
                // If moving away from an NPC, set it to be unclickable/ reset the 'clicked' field.
                if (prevHighlightBlock.b_type == Block.BlockType.NPC)
                {
                    prevHighlightBlock.coord_obj.GetComponent <NPCInteractionController>().SetClickable(false);
                    interactButtClicked = false;
                    blockButt.SetToDeactivated();
                }
            }

            if (lastHighlightBlock != null && lastHighlightBlock.b_type == Block.BlockType.NPC)
            {
                // If an NPC is in front of you, highlight them.
                if (!lastHighlightBlock.isBlockHighlighted())
                {
                    lastHighlightBlock.Highlight();
                }
                // Allow NPC to be clicked, and poll whether it has been clicked to trigger its interaction.
                NPCInteractionController npc = lastHighlightBlock.coord_obj.GetComponent <NPCInteractionController>();
                blockButt.SetToActivated();
                blockButt.GetComponent <RectTransform>().anchoredPosition =
                    comicController.cameraController.WorldToScreenCoords(new Vector3(lastHighlightBlock.p_x, lastHighlightBlock.p_y, lastHighlightBlock.p_z));
                if (npc.isClicked() || interactButtClicked)
                {
                    npc.SetClickable(false);
                    interactButtClicked = false;
                    blockButt.SetToDeactivated();
                    InteractWithNPC(ref npc);
                }
                else
                {
                    npc.SetClickable(true);
                }
            }
            break;


        case GameMode.COMIC:                 // UpdateInteractability() called in this gameMode only when comic is activated
            if (lastHighlightBlock != null && lastHighlightBlock.isBlockHighlighted())
            {
                lastHighlightBlock.Unhighlight();
            }
            break;


        case GameMode.MINIGAME:                 // UpdateInteractability() called in this gameMode only when minigame starts
            if (lastHighlightBlock != null && lastHighlightBlock.isBlockHighlighted())
            {
                lastHighlightBlock.Unhighlight();
            }
            break;


        default:
            break;
        }
    }