Beispiel #1
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Beispiel #2
0
    protected List <Vector2Int> GetBuffsSpawnPositions(GameMap map, Tileset tileset)
    {
        List <Vector2Int> spawnPositions = new List <Vector2Int>();
        MapModifier       mapModifier    = new MapModifier(map);
        GameData          gameData       = new AssetProxy(typeof(GameData)).LoadAsset("Objects/Data.asset");
        int buffsEntries = 0;

        for (int x = -map.sizeX / 2; x < map.sizeX / 2; x++)
        {
            for (int y = -map.sizeY / 2; y < map.sizeY / 2; y++)
            {
                if (tileset.GetIndoorTiles().Contains(mapModifier.GetGroundTile(new Vector3Int(x, y, 0))) &&
                    !tileset.GetStructureTiles().Contains(mapModifier.GetStructureTile(new Vector3Int(x, y, 0))))
                {
                    //spawn
                    if (Random.value < gameData.GetSpawnRate())
                    {
                        spawnPositions.Add(new Vector2Int(x, y));
                        buffsEntries++;
                    }
                    if (buffsEntries >= MAX_BUFFS_ENTRIES)
                    {
                        return(spawnPositions);
                    }
                }
            }
        }
        Debug.Log("Buffs spawn rate:" + gameData.GetSpawnRate());
        return(spawnPositions);
    }
Beispiel #3
0
    protected Vector2 GetPlayerSpawnPosition(GameMap map, Tileset tileset)
    {
        //creating spawn rect for player
        Rect spawnArea = new Rect(new Vector2(-map.sizeX / 2, -map.sizeY / 2),
                                  new Vector2(map.sizeX, map.sizeY));

        spawnArea.xMin   += map.sizeX / 10; //  map.sizeX / 10 is offsetX
        spawnArea.yMin   += map.sizeY / 10; //  map.sizeY / 10 is offsetY
        spawnArea.width  -= map.sizeX / 5;
        spawnArea.height -= map.sizeY / 5;
        List <Vector2> spawnCorners = new List <Vector2>()
        {
            new Vector2(spawnArea.min.x, spawnArea.min.y),
            new Vector2(spawnArea.min.x, spawnArea.max.y),
            new Vector2(spawnArea.max.x, spawnArea.min.y),
            new Vector2(spawnArea.max.x, spawnArea.max.y)
        };
        MapModifier mapModifier = new MapModifier(map);

        foreach (var corner in spawnCorners)
        {
            if (!tileset.GetStructureTiles().Contains(mapModifier.
                                                      GetStructureTile(new Vector3Int((int)corner.x, (int)corner.y, 0))))
            {
                Debug.Log(new Vector2((int)corner.x + 0.5f, (int)corner.y + 0.5f));
                return(new Vector2((int)corner.x + 0.5f, (int)corner.y + 0.5f));
            }
        }
        return(Vector2Int.zero);
    }
Beispiel #4
0
    // behaviour
    void Start()
    {
        if (focusAgent == null)
        {
            focusAgent = PlayerController.MainInstance.transform;
        }
        lastUpdatePosition = focusAgent.position + 3 * new Vector3(streamingThresholds.x, 0, streamingThresholds.y);

        modifier = GetComponent <MapModifier>();
    }
Beispiel #5
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.LogError("More than one instance of type MapModifier");
     }
 }
Beispiel #6
0
    public MapFacade(GameMap map, Tileset tileset)
    {
        this.map            = map;
        this.tiles          = tileset;
        structuresModifier  = new TilemapModifier(map.structures);
        groundModifier      = new TilemapModifier(map.ground);
        decorationsModifier = new TilemapModifier(map.decorations);

        roomRectangleConstructor      = new RandomRectangleConstructor(new Vector2Int(MIN_WIDTH, MIN_HEIGHT), new Vector2Int(MAX_WIDTH, MAX_HEIGHT));
        globalMapRectangleConstructor = new RandomRectangleConstructor(new Vector2Int(map.sizeX / 3, map.sizeY / 3), new Vector2Int((int)(map.sizeX / 1.2), (int)(map.sizeY / 1.2)));

        mapOperations = new MapModifier(map);
    }
 public void OnEnable()
 {
     _map_modif = (MapModifier)target;
 }