Ejemplo n.º 1
0
 // Debug Purposes
 public void RegenerateAll()
 {
     foreach (Chunk c in Chunks.Values)
     {
         ChunkRenderer renderer = c.GetComponent <ChunkRenderer>();
         // Procedural Generation & Mesh
         ProceduralGeneration.AsyncGenerateChunk(c, () => renderer.RegenerateMesh());
     }
 }
Ejemplo n.º 2
0
 private void Start()
 {
     borderLines                  = FindObjectOfType <GameLines>().GetComponent <GameLines>();
     playerActionsClass           = playerPrefab.GetComponent <PlayerActions>();
     currentActiveBackgroundIndex = 0;
     proceduralGeneration         = FindObjectOfType <ProceduralGeneration>();
     playerStats                  = FindObjectOfType <PlayerStatistics>();
     if (proceduralGeneration == null)
     {
         SetActiveBackgroundIndex();
         FrameBordersPlayerAreaAndLevelProgress();
     }
 }
Ejemplo n.º 3
0
    private void IncrementTrapDifficulty()
    {
        minInterval = minInitialInterval +
                      (float)ProceduralGeneration.Logistic(
            lvlManager.PlayTime * lvlManager.MinSpawnIntervalTrapValues[3],
            lvlManager.MinSpawnIntervalTrapValues[0],
            lvlManager.MinSpawnIntervalTrapValues[1],
            lvlManager.MinSpawnIntervalTrapValues[2]);

        maxInterval = maxInitialInterval +
                      (float)ProceduralGeneration.Logistic(
            lvlManager.PlayTime * lvlManager.MinSpawnIntervalTrapValues[3],
            lvlManager.MinSpawnIntervalTrapValues[0],
            lvlManager.MinSpawnIntervalTrapValues[1],
            lvlManager.MinSpawnIntervalTrapValues[2]);
    }
Ejemplo n.º 4
0
 private void Start()
 {
     taskHandlerClass     = FindObjectOfType <TaskHandler>();
     levelControllerClass = levelController.GetComponent <LevelController>();
     playerActions        = playerPrefab.GetComponent <PlayerActions>();
     timerLabel           = playerTimerUI.GetComponent <TextMeshProUGUI>();
     pg = FindObjectOfType <ProceduralGeneration>();
     if (pg != null)
     {
         playerTimer = PersistentInformation.timerForInfinitelevel;
     }
     else
     {
         PersistentInformation.timerForInfinitelevel = 0f;
     }
     playerStats = FindObjectOfType <PlayerStatistics>();
 }
Ejemplo n.º 5
0
    void Start()
    {
        // Singletone pattern
        if (instance == null)
        {
            instance = this;
        }
        else if (instance == this)
        {
            Destroy(gameObject);
        }

        // Prerender
        prerendering = true;
        ring         = 1;
        StartCoroutine(DelayedPrerender());
    }
    // Start is called before the first frame update
    void Awake()
    {
        s_currentPlayerTurn = 0;
        InitCityNames();
        m_numberOfPlayers = GameController.GetNumberOfPlayers();
        m_mapGrid         = FindObjectOfType <MapGrid>();
        ProceduralGeneration.GenerateMap(m_mapGrid);

        InitPlayers();
        CreateStartUnits();
        SetTurnStartUI();
        m_players[s_currentPlayerTurn].TurnStart();

        if (m_camera != null)
        {
            m_camera.SetPosition(m_players[s_currentPlayerTurn].GetUnits()[0].transform.position);
        }
    }
Ejemplo n.º 7
0
    private void CreateChunk(Vector3Int index)
    {
        // Create GameObject, Componentes, Position and Parent
        GameObject newChunk = new GameObject(index.ToString());
        Chunk      c        = newChunk.AddComponent <Chunk>();

        c.Index = index;
        ChunkRenderer renderer = newChunk.AddComponent <ChunkRenderer>();

        c.SetChunkRenderer(renderer);
        newChunk.transform.position = Vector3.Scale(Chunk.ChunkSize, index) + new Vector3(0.5f, 0.5f, 0.5f);
        newChunk.transform.SetParent(transform, true); // Chunk is a child of ChunkManager
                                                       // Add to Dictionary
        Chunks.Add(index, c);
        // Procedural Generation & Mesh
        ProceduralGeneration.AsyncGenerateChunk(c, () => renderer.RegenerateMesh());
        // Main Thread operations
        NotFinishedChunks.Add(c);
    }
Ejemplo n.º 8
0
 private void Start()
 {
     slowmotionClass                       = slowmotion.GetComponent <Slowmotion>();
     playerClass                           = player.GetComponent <Player>();
     playerActionsClass                    = player.GetComponent <PlayerActions>();
     coinsAcquiredOnScreenText             = coinsAcquired.GetComponent <TextMeshProUGUI>();
     coinsInScene                          = FindObjectsOfType <Coin>().Length;
     coinsAcquiredOnScreenText.text        = currentCoinsAcquired.ToString() + " / " + coinsInScene;
     playerStats                           = FindObjectOfType <PlayerStatistics>();
     taskHandler                           = FindObjectOfType <TaskHandler>();
     prevLowerBound                        = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 0)).y;
     playSpaceCollider                     = playSpace.GetComponent <PolygonCollider2D>();
     gameLinesClass                        = gameLines.GetComponent <GameLines>();
     levelCompletedText                    = levelCompletedTextGO.GetComponent <TextMeshProUGUI>();
     PersistentInformation.LevelIdentifier = gameObject.scene.name;
     pg = FindObjectOfType <ProceduralGeneration>();
     initialTimeForAdButtonAnimation = timeForAdButtonAnimation;
     adMobClass = FindObjectOfType <AdMob>();
     adMobClass.RequestRewardBasedVideo();
     adMobClass.RequestInterstitial();
 }
Ejemplo n.º 9
0
    public IEnumerator SizeVariation()
    {
        ProceduralGeneration.SetGenerationSize(GenerationSize.Small);
        ProceduralGeneration.GenerateMap(m_mapGrid);

        Assert.True(m_mapGrid.GetWidth() == ProceduralGeneration.s_smallSize.x);
        Assert.True(m_mapGrid.GetHeight() == ProceduralGeneration.s_smallSize.y);

        ProceduralGeneration.SetGenerationSize(GenerationSize.Medium);
        ProceduralGeneration.GenerateMap(m_mapGrid);

        Assert.True(m_mapGrid.GetWidth() == ProceduralGeneration.s_mediumSize.x);
        Assert.True(m_mapGrid.GetHeight() == ProceduralGeneration.s_mediumSize.y);

        ProceduralGeneration.SetGenerationSize(GenerationSize.Large);
        ProceduralGeneration.GenerateMap(m_mapGrid);

        Assert.True(m_mapGrid.GetWidth() == ProceduralGeneration.s_largeSize.x);
        Assert.True(m_mapGrid.GetHeight() == ProceduralGeneration.s_largeSize.y);

        yield return(null);
    }
Ejemplo n.º 10
0
    public IEnumerator CustomSeed()
    {
        ProceduralGeneration.SetSeed("Test");
        ProceduralGeneration.GenerateMap(m_mapGrid);

        GameObject mapGridObject2 = GameObject.Instantiate(m_mapGridPrefab, Vector2.zero, Quaternion.identity);

        MapGrid mapGrid2 = mapGridObject2.GetComponent <MapGrid>();

        ProceduralGeneration.GenerateMap(mapGrid2);

        for (int x = 0; x < m_mapGrid.GetWidth(); x++)
        {
            for (int y = 0; y < m_mapGrid.GetHeight(); y++)
            {
                Assert.True(m_mapGrid.m_grid[x][y].GetTileType() == mapGrid2.m_grid[x][y].GetTileType());
            }
        }

        GameObject.Destroy(mapGridObject2);

        yield return(null);
    }
Ejemplo n.º 11
0
    public IEnumerator RandomSeed()
    {
        ProceduralGeneration.GenerateRandomSeed();
        ProceduralGeneration.GenerateMap(m_mapGrid);

        string seed1 = ProceduralGeneration.GetSeed();

        GameObject mapGridObject2 = GameObject.Instantiate(m_mapGridPrefab, Vector2.zero, Quaternion.identity);

        MapGrid mapGrid2 = mapGridObject2.GetComponent <MapGrid>();

        ProceduralGeneration.GenerateRandomSeed();
        ProceduralGeneration.GenerateMap(mapGrid2);

        string seed2 = ProceduralGeneration.GetSeed();

        Assert.True(seed1 != seed2);

        bool isIdentical = true;

        for (int x = 0; x < m_mapGrid.GetWidth() && isIdentical; x++)
        {
            for (int y = 0; y < m_mapGrid.GetHeight() && isIdentical; y++)
            {
                if (m_mapGrid.m_grid[x][y].GetTileType() != mapGrid2.m_grid[x][y].GetTileType())
                {
                    isIdentical = false;
                }
            }
        }

        Assert.True(isIdentical == false);

        GameObject.Destroy(mapGridObject2);

        yield return(null);
    }
Ejemplo n.º 12
0
    public IEnumerator ResourcePlacment()
    {
        ProceduralGeneration.SetGenerationSize(GenerationSize.Small);
        ProceduralGeneration.GenerateMap(m_mapGrid);

        List <ResourceTile> resourceTiles = new List <ResourceTile>();

        for (int x = 0; x < m_mapGrid.GetWidth(); x++)
        {
            for (int y = 0; y < m_mapGrid.GetHeight(); y++)
            {
                if (m_mapGrid.m_grid[x][y].GetResourceTile() != null)
                {
                    resourceTiles.Add(m_mapGrid.m_grid[x][y].GetResourceTile());
                }
            }
        }

        int count;

        foreach (ResourceType type in Enum.GetValues(typeof(ResourceType)))
        {
            count = 0;

            foreach (ResourceTile resourceTile in resourceTiles)
            {
                if (resourceTile.GetResourceType() == type)
                {
                    count++;
                }
            }

            Assert.True(count == ProceduralGeneration.s_resourceCountSmall);
        }

        yield return(null);
    }
Ejemplo n.º 13
0
 private void Awake()
 {
     _Instance = this;
 }
Ejemplo n.º 14
0
    public void RandomizeSeed()
    {
        ProceduralGeneration.GenerateRandomSeed();

        m_seedInput.text = ProceduralGeneration.s_seed;
    }
Ejemplo n.º 15
0
 private void Awake()
 {
     instance = this;
 }