コード例 #1
0
ファイル: Actors.cs プロジェクト: Lenakeiz/LudumDare33
    // Use this for initialization
    void Start()
    {
        this.transform.position = currentTile.characterPosition;
        this.talkTarget         = null;
        pathHelper = gameObject.GetComponent <Astar>() as Astar;

        audioSource                       = GetComponent <AudioSource>();
        audioSource.playOnAwake           = false;
        audioSource.outputAudioMixerGroup = sfx;
//		audioManager = GameObject.FindObjectOfType<AudioManager>();
//
//		if(audioManager == null)
//		{
//			Debug.LogError("Audio Manager is not in the scene");
//		}

        GameObject uiElement = GameObject.FindGameObjectWithTag("UILife");

        if (uiElement != null)
        {
            Transform targetChild = uiElement.transform.GetChild(uiIndex);
            if (targetChild != null)
            {
                barScript = targetChild.gameObject.GetComponentInChildren <BarScript>();
                barScript.SetName(gameObject.name);
            }
            else
            {
                Debug.LogError("UI Child Not Found");
            };
        }
        else
        {
            Debug.LogError("UI for lifes not found");
        }

        GameObject[] tiles    = GameObject.FindGameObjectsWithTag("Tile");
        Tile         currTile = null;

        for (int i = 0; i < tiles.Length; i++)
        {
            currTile = tiles[i].GetComponent <Tile>();
            if (currTile.useAstar || Random.Range(0, 101) < markedTilesPercentage)
            {
                pathHelper.AddTile(currTile);
            }
        }
        roamingT = 0f;
    }