Exemplo n.º 1
0
    PickedUpItems FillWith(GameObject obj, int x, int y)
    {
        //print("Fill with landtile at " + x + ", " + y);
        Vector3 pos = new Vector3((-totalWidth / 2.0f) + (tileSize / 2.0f) + x * tileSize, (totalHeight / 2.0f) - (tileSize / 2.0f) - tileSize * y, 3);
        //Debug.Log(pos);
        GameObject newTile = Instantiate(obj);

        newTile.transform.SetParent(transform);
        newTile.transform.position = pos;

        LandBrick tile      = newTile.GetComponent <LandBrick>();
        EmptyTile EmptyTile = newTile.GetComponent <EmptyTile>();

        if (tile != null)
        {
            tile.index = new Vector2Int(x, y);
            //Debug.Log("index: " + x + ", " + y);
            return(tile);
        }
        else if (EmptyTile != null)
        {
            EmptyTile.index = new Vector2Int(x, y);
            //Debug.Log("index: " + x + ", " + y);
            return(EmptyTile);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 2
0
    public void RpcUpdateTileMap(int x, int y, int val)
    {
        //currently it is a LandBrick, crack the landbrick
        if (m_map[x, y] != 0)
        {
            LandBrick tile = (LandBrick)m_worldGenerator.getTileComponent(x, y);
            tile.isCracked = true;
            tile.crackALandTile();
        }

        //print("update tile map with value: " + val);
        m_map[x, y] = val;
        m_worldGenerator.FillWithTileType(val, x, y);
    }