private void OnEnable()
    {
        td_target = (TopDownUINpcNameBar)target;

        if (TopDownIcon == null)
        {
            TopDownIcon = Resources.Load("TopDownIcon") as Texture;
        }
    }
コード例 #2
0
    private void Start()
    {
        if (character != null)
        {
            name      = character.name;
            health    = character.health;
            maxHealth = character.health;
            energy    = character.energy;
            maxEnergy = character.energy;
        }
        else
        {
            name = aiName;
        }

        main             = GetComponent <TopDownControllerMain>();
        interact         = GetComponent <TopDownControllerInteract>();
        equipmentManager = GetComponent <TopDownEquipmentManager>();
        if (TopDownCharacterManager.instance != null)
        {
            characterManager = TopDownCharacterManager.instance;
        }
        if (TopDownUIManager.instance != null)
        {
            npcBar           = TopDownUIManager.instance.npcWorldName.GetComponent <TopDownUINpcNameBar>();
            placeBarOverHead = npcBar.placeBarOverHead;
            uiManager        = TopDownUIManager.instance;
        }

        if (GameObject.FindGameObjectWithTag("MainCamera"))
        {
            mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        }
        else if (GameObject.FindObjectOfType <Camera>())
        {
            mainCamera = GameObject.FindObjectOfType <Camera>();
        }

        if (GetComponent <TopDownAI>())
        {
            maxHealth = health;
            GetComponent <TopDownAI>().name             = aiName;
            GetComponent <TopDownAI>().voiceSet         = aiVoiceSet;
            GetComponent <TopDownAI>().visionCollider   = aiVision;
            GetComponent <TopDownAI>().detectRadius     = aiDetectRadius;
            GetComponent <TopDownAI>().fieldOfViewAngle = aiFieldOfView;
        }

        if (GetComponent <TopDownControllerInteract>())
        {
            int layerInt = gameObject.layer;

            if (inventoryCamera != null)
            {
                inventoryCamera.GetComponent <Camera>().cullingMask = 1 << layerInt;

                if (TopDownCharacterManager.instance != null)
                {
                    if (TopDownCharacterManager.instance.controllingCharacter != gameObject)
                    {
                        inventoryCamera.SetActive(false);
                    }
                }
            }
        }

        Transform[] allChildren = GetComponentsInChildren <Transform>();
        for (int i = 0; i < allChildren.Length; i++)
        {
            if (allChildren[i].name.Contains("head") || allChildren[i].name.Contains("HEAD") || allChildren[i].name.Contains("Head"))
            {
                nameBarPosition = allChildren[i];
            }
        }
    }