Ejemplo n.º 1
0
Archivo: Game.cs Proyecto: vilcans/LD41
    public void NewLevel()
    {
        if (level != null)
        {
            for (int i = 0, len = level.creatures.Count; i < len; ++i)
            {
                Level.Creature creature = level.creatures[i];
                creature.Destroy();
            }
            level = null;
        }

        ++dungeonLevel;
        level = new Level(dungeonLevel);

        UpdateStatusText();

        int numberOfTiles = level.map.width * level.map.height;

        if (tilesParent != null)
        {
            Destroy(tilesParent.gameObject);
            tilesParent = null;
        }
        tilesParent = new GameObject("Level").transform;
        tilesParent.hierarchyCapacity = Math.Max(tilesParent.hierarchyCapacity, numberOfTiles + 10);

        for (int row = 0; row < level.map.height; ++row)
        {
            for (int column = 0; column < level.map.width; ++column)
            {
                Vector2Int   square = new Vector2Int(column, row);
                TileMap.Tile tile   = level.map.GetTile(square);
                CreateTile(tile, square);
            }
        }

        playerPosition           = level.map.entryPoint;
        cameraTransform.position = GridToWorldPosition(playerPosition) + cameraOffset;
        state = State.EnteringLevel;
    }
Ejemplo n.º 2
0
Archivo: Game.cs Proyecto: vilcans/LD41
 private void RemoveCreature(Level.Creature creature)
 {
     creature.Destroy();
     level.creatures.Remove(creature);
 }