Esempio n. 1
0
        private Vector3 randomPosition()
        {
            RockGenerationBehaviour.Rectangle currentTileBounds = config.rockGenerationBehaviour.GetBounds();
            float x = Random.Range(currentTileBounds.minX, currentTileBounds.maxX);
            float y = 100f;
            float z = Random.Range(currentTileBounds.minZ, currentTileBounds.maxZ);

            return(new Vector3(x, y, z));
        }
Esempio n. 2
0
        public void GenerateRowPosZ(RockGenerationBehaviour.Rectangle currentTile)
        {
            Vector3 centerPosition = new Vector3(currentTile.Center().x, 0, currentTile.Center().z + 2 * currentTile.Length());
            Vector3 leftPosition   = new Vector3(centerPosition.x + currentTile.Length(), 0, centerPosition.z);
            Vector3 rightPosition  = new Vector3(centerPosition.x - currentTile.Length(), 0, centerPosition.z);

            if (!tiles.ContainsKey(new OurTuple((int)centerPosition.x, (int)centerPosition.z)))
            {
                GameObject center = Instantiate(config.obstacle, centerPosition, Quaternion.identity);
                tiles.Add(new OurTuple((int)centerPosition.x, (int)centerPosition.z), center.GetComponent <RockGenerationBehaviour>());
            }
            if (!tiles.ContainsKey(new OurTuple((int)leftPosition.x, (int)leftPosition.z)))
            {
                GameObject left = Instantiate(config.obstacle, leftPosition, Quaternion.identity);
                tiles.Add(new OurTuple((int)leftPosition.x, (int)leftPosition.z), left.GetComponent <RockGenerationBehaviour>());
            }
            if (!tiles.ContainsKey(new OurTuple((int)rightPosition.x, (int)rightPosition.z)))
            {
                GameObject right = Instantiate(config.obstacle, rightPosition, Quaternion.identity);
                tiles.Add(new OurTuple((int)rightPosition.x, (int)rightPosition.z), right.GetComponent <RockGenerationBehaviour>());
            }
        }