简体   繁体   中英

How can I check that if a specific name is taking part of a conversation then enable true if not false?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerLockState : MonoBehaviour
{
    public Camera playerCamera;
    public camMouseLook mouselook;
    public Conversation conversation;
    public ConversationTrigger conversationtrigger;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (playerCamera.enabled == false ||
            conversationtrigger.conversationEnd == false)
        {
            PlayerController.disablePlayerController = true;

            if (conversation.Dialogues.Count > 0)
            {
                for (int i = 0; i < conversation.Dialogues.Count; i++)
                {
                    if (conversation.Dialogues[i].Name == "Navi")
                    {
                        mouselook.enabled = true;
                    }
                    else
                    {
                        mouselook.enabled = false;
                    }
                }
            }

            transform.Rotate(new Vector3(0, 0, 0));
        }
        else
        {
            PlayerController.disablePlayerController = false;
            mouselook.enabled = true;
        }
    }
}

At this part I'm checking if the specific name is taking part of a conversation:

if (conversation.Dialogues.Count > 0)
            {
                for (int i = 0; i < conversation.Dialogues.Count; i++)
                {
                    if (conversation.Dialogues[i].Name == "Navi")
                    {
                        mouselook.enabled = true;
                    }
                    else
                    {
                        mouselook.enabled = false;
                    }
                }
            }

If the player is taking part of a conversation, set mouselook to true, if not, set the mouselook to false. But when set to false, I also want to check if the:

playerCamera.enabled == false

The mouselook should be false only if the playerCamera is also false. And the mouselook should be true only if Navi is part of the conversation even if the playerCamera is false.

                if (conversation.Dialogues[i].Name == "Navi")
                {
                    playerCamera.enabled == true;
                    mouselook.enabled = true;
                }
                else
                {
                    playerCamera.enabled == false;
                    mouselook.enabled = false;
                }

Correct me if i'm missing something here. Not exactly sure why you'd need to

I also want to check if the:

playerCamera.enabled == false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM