Esempio n. 1
0
    public void SetMap(EMap pMap)
    {
        SoundController.PlayMusic(ESound.Music_Game);

        for (int i = 0; i < transform.childCount; i++)
        {
            ActiveMap = transform.GetChild(i).GetComponent <Map>();
            ActiveMap.SetActive(false);
            if (ActiveMap != null && ActiveMap.name.Contains(pMap.ToString()))
            {
                Debug.LogWarning("Map is already present in the scene");
                if (!Brainiacs.SelfInitGame)
                {
                    Debug.LogError("Map object cant be present in the scene [not error if debugging]");
                }

                ActiveMap.SetActive(true);
                return;
            }
        }

        //if(transform.childCount > 0)
        //{
        //	ActiveMap = transform.GetChild(0).GetComponent<Map>();
        //	if(ActiveMap != null)
        //	{
        //		Debug.LogWarning("Map is already present in the scene");
        //		if(!Brainiacs.SelfInitGame)
        //			Debug.LogError("Map object cant be present in the scene [not error if debugging]");
        //		return;
        //	}
        //}

        ActiveMap = Instantiate(brainiacs.MapManager.GetMapConfig(pMap).Prefab);
        if (ActiveMap == null)
        {
            Debug.LogError("No map selected");
            return;
        }

        ActiveMap.transform.parent = transform;
    }