コード例 #1
0
    private bool TalkInteraction(GameObject interactor)
    {
        InteractionTalk interaction = interactor.GetComponent <InteractionTalk>();

        if (interaction && interaction.pnj)
        {
            interaction.pnj.SetActive(false);
            DiscussionSystem.instance.SetActive(true);
            DiscussionSystem.instance.pnj = interaction.pnj;
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #2
0
ファイル: InteractionUI.cs プロジェクト: Titwin/TinyWorld
    void Update()
    {
        if (juicer.hovered)
        {
            // Construction progress
            constructionController = juicer.hovered.GetComponent <ConstructionController>();
            if (constructionController != null)
            {
                UpdateConstructionProgress(constructionController);
            }
            else
            {
                ResetConstructionProgress();
            }

            // local resource container
            resourceContainer = juicer.hovered.GetComponent <ResourceContainer>();
            if (resourceContainer != null && constructionController == null)
            {
                UpdateContainerViewer(resourceContainer);
            }
            else
            {
                ResetContainerViewer();
            }

            // simple interaction
            bool simpleInteraction = false;

            // talk interaction
            InteractionTalk interactionTalk = juicer.hovered.GetComponent <InteractionTalk>();
            if (interactionTalk != null && !DiscussionSystem.instance.activated)
            {
                simpleInteractionText.gameObject.SetActive(true);
                simpleInteractionText.text = "Talk to " + interactionTalk.pnj.pnjName;
                simpleInteraction          = true;
            }
            else
            {
                simpleInteractionText.gameObject.SetActive(simpleInteraction);
            }

            // forge interaction
            if (isForge(juicer.hovered) && !ForgeSystem.instance.activated)
            {
                simpleInteractionText.gameObject.SetActive(true);
                simpleInteractionText.text = "Open the forge";
                simpleInteraction          = true;
            }
            else
            {
                simpleInteractionText.gameObject.SetActive(simpleInteraction);
            }

            // resource collection interaction
            if (isResourceCollection(juicer.hovered))
            {
                simpleInteractionText.gameObject.SetActive(true);
                InteractionType.Type collectionType = juicer.hovered.GetComponent <InteractionType>().type;
                if (ResourceDictionary.instance.resourcesFromType.ContainsKey(collectionType))
                {
                    simpleInteractionText.text = "Collect " + ResourceDictionary.instance.resourcesFromType[collectionType].name;
                }
                else
                {
                    simpleInteractionText.text = "Error: ResourceDictionary doesn't contain resource for interaction " + collectionType.ToString();
                }
                simpleInteraction = true;
            }
            else
            {
                simpleInteractionText.gameObject.SetActive(simpleInteraction);
            }
        }
        else
        {
            constructionController = null;
            resourceContainer      = null;
            ResetConstructionProgress();
            ResetContainerViewer();
            simpleInteractionText.gameObject.SetActive(false);
        }
    }