Пример #1
0
    public void Refresh(Vector2Int playerPosition, List <Vector2Int> exploredList, List <Vector2Int> wallList)
    {
        _texture2d.SetPixel(_playerPosition.x - _mapBound.xMin + 1, _playerPosition.y - _mapBound.yMin + 1, Color.white);

        Vector2Int texturePos;

        for (int i = 0; i < exploredList.Count; i++)
        {
            texturePos = new Vector2Int(exploredList[i].x - _mapBound.xMin + 1, exploredList[i].y - _mapBound.yMin + 1);
            _texture2d.SetPixel(texturePos.x, texturePos.y, Color.white);

            if (exploredList[i] == _goalPosition)
            {
                //Goal.SetActive(true);
                LittleMap.SetGoalVisible(true);
                BigMap.SetGoalVisible(true);
            }
        }

        for (int i = 0; i < wallList.Count; i++)
        {
            texturePos = new Vector2Int(wallList[i].x - _mapBound.xMin + 1, wallList[i].y - _mapBound.yMin + 1);
            _texture2d.SetPixel(texturePos.x, texturePos.y, Color.black);
        }

        _playerPosition = playerPosition;
        //_texture2d.SetPixel(_playerPosition.x - _mapBound.xMin + 1, _playerPosition.y - _mapBound.yMin + 1, Color.red);
        _texture2d.Apply();

        float   positionX         = (_mapBound.center.x - _playerPosition.x) * Scale;
        float   positionY         = (_mapBound.center.y - _playerPosition.y) * Scale;
        Vector2 mapPosition       = new Vector2(positionX, positionY);
        Vector2 mapPlayerPosition = new Vector2((_playerPosition.x - _mapBound.center.x) * Scale, (_playerPosition.y - _mapBound.center.y) * Scale);

        //LittleMap.transform.localPosition = new Vector2(positionX, positionY);
        //BigMap.transform.localPosition = new Vector2(positionX, positionY);

        //Player.transform.localPosition = new Vector2((_playerPosition.x - _mapBound.center.x) * Scale, (_playerPosition.y - _mapBound.center.y) * Scale);
        LittleMap.Refresh(mapPlayerPosition, mapPosition);
        BigMap.Refresh(mapPlayerPosition, mapPosition);
    }