Пример #1
0
    private void InitGame()
    {
        UI           = FindObjectOfType <Canvas>().GetComponent <UIController>();
        mainCamera   = Camera.main.GetComponent <CameraFollow>();
        worldDisplay = new WorldDisplay();
        for (int i = 0; i < 3; i++)
        {
            UI.hand.DrawCard();
        }

        playerGO = SpawnPlayer();
        player   = playerGO.GetComponent <PlayerController>();
        mainCamera.SetTarget(playerGO.transform);
        GameObject newEnemy = Instantiate(enemyPrefab, Vector3.right * 7, Quaternion.identity);
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Space))
     {
         testWorld    = WorldGenerator.smoothWorld(testWorld, 1);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha1))
     {
         testWorld    = new World(10, 10);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 65);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha2))
     {
         testWorld    = new World(20, 20);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 65);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha3))
     {
         testWorld    = new World(30, 30);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 60);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha4))
     {
         testWorld    = new World(40, 40);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 55);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha5))
     {
         testWorld    = new World(50, 50);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 55);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
     if (Input.GetKeyUp(KeyCode.Alpha0))
     {
         testWorld    = new World(125, 125);
         testWorld    = WorldGenerator.generateWorld(testWorld, 0, 52);
         display.text = WorldDisplay.worldToLetters(testWorld);
     }
 }
Пример #3
0
    public void GenerateWorld()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(_chunkSize + 2, _chunkSize + 2, _seed, _noiseScale, _octaves, _persistance, _lacunarity, _offset, _radius);

        //Color
        Color[] colorMap = new Color[_chunkSize * _chunkSize];
        for (int x = 0; x < _chunkSize; x++)
        {
            for (int y = 0; y < _chunkSize; y++)
            {
                float currentHeight = noiseMap[x, y];

                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colorMap[y * _chunkSize + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        WorldDisplay display = FindObjectOfType <WorldDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, _chunkSize, _chunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, _meshHeightMultiplier, _meshHeightCurve, _LevelOfDetail, _useTerrainFlatShading), TextureGenerator.TextureFromColorMap(colorMap, _chunkSize, _chunkSize));
        }


        SpawnObjects(noiseMap, _densitiy);
    }
Пример #4
0
    public void RendWorld()
    {
        WorldStats   worldStats = GenerateWorld(Vector2.zero);
        WorldDisplay display    = FindObjectOfType <WorldDisplay>();

        if (drawMode == DrawMode.NoiseWorld)
        {
            display.DrawTexture(Texturing.TextureFromHeightMap(worldStats.heightWorld));
        }
        else if (drawMode == DrawMode.ColourWorld)
        {
            display.DrawTexture(Texturing.TextureFromColourMap(worldStats.colourWorld, worldPartSize, worldPartSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(worldStats.heightWorld, meshHeightMultiplier, meshHeightCurve, ValueLevelOfDetail), Texturing.TextureFromColourMap(worldStats.colourWorld, worldPartSize, worldPartSize));
        }
        else if (drawMode == DrawMode.FallMap)
        {
            display.DrawTexture(Texturing.TextureFromHeightMap(FallGenerator.GenerateFall(worldPartSize)));
        }
    }