示例#1
0
文件: Game.cs 项目: nice-shot/BatCave
        public void GenerateInitialTerrain()
        {
            terrainPoints.Clear();
            TerrainGenerator.TerrainPoint point;
            do
            {
                point = TerrainGenerator.GetNextPoint(0);
                terrainPoints.Add(point);
            } while (point.x < minXForGameStart);
            // One more point after that to allow accounting for the next point's slope.
            point = TerrainGenerator.GetNextPoint(0);
            terrainPoints.Add(point);

            DebugUtils.Log("Created " + terrainPoints.Count + " initial points");

            nextPointIndex = 0;
            _score         = 0;

            // Rasterize the terrain.
            nextPointToRasterize = 0;
            int lastPointIndex = -1;

            while (nextPointToRasterize > lastPointIndex)
            {
                lastPointIndex = nextPointToRasterize;
                DebugUtils.Log("Rasterizing point #" + lastPointIndex);
                nextPointToRasterize = TerrainRasterizer.RasterizeNextChunk(lastPointIndex);
            }
        }
示例#2
0
        protected void Awake()
        {
            instance = this;

            Bat.OnDied += OnGameOver;
            TerrainAliveChecker.OnTerrainEnteredScreen += OnTerrainEnteredScreen;
            gameObject.SetActive(false);

            // Generate initial terrain.
            TerrainGenerator.TerrainPoint point;
            do
            {
                point = TerrainGenerator.GetNextPoint(0);
                terrainPoints.Add(point);
            } while (point.x < minXForGameStart);
            // One more point after that to allow accounting for the next point's slope.
            point = TerrainGenerator.GetNextPoint(0);
            terrainPoints.Add(point);

            DebugUtils.Log("Created " + terrainPoints.Count + " initial points");

            nextPointIndex = 0;
            _score         = 0;

            // Rasterize the terrain.
            nextPointToRasterize = 0;
            int lastPointIndex = -1;

            while (nextPointToRasterize > lastPointIndex)
            {
                lastPointIndex = nextPointToRasterize;
                DebugUtils.Log("Rasterizing point #" + lastPointIndex);
                nextPointToRasterize = TerrainRasterizer.RasterizeNextChunk(lastPointIndex);
            }
        }
示例#3
0
文件: Game.cs 项目: nice-shot/BatCave
        private void OnTerrainEnteredScreen()
        {
            DebugUtils.Log("Terrain entered screen");
            // Add points until the terrain is rasterized.
            int lastPointIndex = nextPointToRasterize;

            while (nextPointToRasterize == lastPointIndex)
            {
                var difficulty = DifficultyManager.GetNextDifficulty();
                var point      = TerrainGenerator.GetNextPoint(difficulty);
                terrainPoints.Add(point);
                nextPointToRasterize = TerrainRasterizer.RasterizeNextChunk(lastPointIndex);
            }
        }