Exemplo n.º 1
0
    void Update()
    {
        CheckSizeLimit(m_widthField);
        CheckSizeLimit(m_heightField);

        if (Input.GetMouseButtonDown(0))
        {
            if (m_mapEditor.m_map.m_isCreated)
            {
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = 1;
                Vector2 worldPosition = Camera.main.ScreenToWorldPoint(mousePos);

                MapIndex mapIndex = m_mapEditor.m_map.WorldPositionToMapIndex(worldPosition);

                if (m_selectedSprite != null)
                {
                    m_mapEditor.ChangeTileSprite(mapIndex, m_selectedSprite);
                }

                else if (m_selectedObject != null)
                {
                    PlaceMapObject(mapIndex);
                }

                else if (m_removeObjectFromMap)
                {
                    m_mapEditor.RemoveMapObject(mapIndex);
                }
            }
        }
    }
Exemplo n.º 2
0
    public IEnumerator PlaceSprite()
    {
        string   path     = "MapGridComponent/Sprites/Wall";
        MapIndex indexPos = new MapIndex(2, 1);

        Assert.True(m_mapEditor.LoadtTileSprite(path) == true);
        Assert.True(m_mapEditor.m_tileSprites.ContainsKey(path) == true);

        yield return(new WaitForSeconds(0.1f));

        m_mapEditor.ChangeTileSprite(indexPos, m_mapEditor.m_tileSprites[path]);

        Assert.True(m_map.GetTile(indexPos).GetSprite() == m_mapEditor.m_tileSprites[path]);

        yield return(new WaitForSeconds(0.1f));
    }