Beispiel #1
0
    Start()
    {
        // Set outside of the map
        m_LastTileCoordinate = new Vector3Int(-1, -1, -1);

        // Assigns the correct tilemaps / layers
        foreach (UnityEngine.Tilemaps.Tilemap tilemap in m_Grid.GetComponentsInChildren <UnityEngine.Tilemaps.Tilemap>())
        {
            if (tilemap.name == "Background")
            {
                m_Background = tilemap;
            }
            else if (tilemap.name == "Minerals")
            {
                m_Minerals = tilemap;
            }
            else if (tilemap.name == "Buildings")
            {
                m_Buildings = tilemap;
            }
            else if (tilemap.name == "UILayer")
            {
                m_UILayer = tilemap;
            }
        }

        // Initializes dictionary
        m_MineralDeposits = new Dictionary <Vector3Int, Transform>();
        // Stores the position and object in dictionary
        foreach (Transform transform in m_Minerals.GetComponentInChildren <Transform>())
        {
            Vector3Int objPos = m_Grid.WorldToCell(transform.position);
            m_MineralDeposits.Add(objPos, transform);
        }

        // Assigns the UI elements
        foreach (UnityEngine.UI.Text text in m_Panel.GetComponentsInChildren <UnityEngine.UI.Text>())
        {
            if (text.name == "ResourceTypeEntry")
            {
                m_TypeEntry = text;
            }
            else if (text.name == "ResourceAmountEntry")
            {
                m_AmountEntry = text;
            }
            else if (text.name == "OwnerEntry")
            {
                m_OwnerEntry = text;
            }
        }
    }