/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenCloud(Transform thisTransform, GameObject cloud, Vector3 uvOffset, int amountClouds) { //-------------- for (int i = 0; i < amountClouds; i++) { yield return(delay0); GameObject cloudObject = GameObject.Instantiate(cloud); cloudObject.SetActive(false); Class_AdditionalTools.UvMesh(cloudObject.GetComponent <MeshFilter>().mesh, uvOffset.x, uvOffset.y); Transform cloudTransform = cloudObject.transform; cloudTransform.parent = thisTransform; float cloudScale = 0.1f + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, (amountClouds + i) * 0.41f) / 4); cloudTransform.localScale = Vector3.one * cloudScale; float xt = Class_AdditionalTools.PositionSeed(thisTransform, i + cloudScale * 3.141f) * (0.35f - (0.35f * cloudScale)); float yt = Class_AdditionalTools.PositionSeed(thisTransform, i + cloudScale * 7.23f) * (0.35f - (0.35f * cloudScale)); float zt = Class_AdditionalTools.PositionSeed(thisTransform, i + cloudScale * 6.31f) * (0.35f - (0.35f * cloudScale)); cloudTransform.localPosition = new Vector3(xt, yt, zt); float xr = Class_AdditionalTools.PositionSeed(thisTransform, xt + cloudScale * 7.13f) * 5; float yr = Class_AdditionalTools.PositionSeed(thisTransform, yt + cloudScale * 6.93f) * 5; float zr = Class_AdditionalTools.PositionSeed(thisTransform, zt + cloudScale * 1.13f) * 5; cloudTransform.localRotation = Quaternion.Euler(xr, yr, zr); cloudObject.SetActive(true); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- if (Class_Interface.shadows == true) { bodyLod0.GetComponent <Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; bodyLod0.GetComponent <Renderer>().receiveShadows = true; } else { bodyLod0.GetComponent <Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; bodyLod0.GetComponent <Renderer>().receiveShadows = false; } //-------------- float uvB = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.171f * Class_AI.amountEnemyAIs)); Class_AdditionalTools.UvMesh(bodyLod0.mesh, uvB, 0.7f); Class_AdditionalTools.UvMesh(bodyLod1.mesh, uvB, 0.7f); Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.15f, 0.25f); Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.15f, 0.25f); StartCoroutine(Class_EnemyAI.Customization(gameObject, bodyLod0, eyeLod0, bodyLod1, eyeLod1, particlesDead)); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Moon"); sqrtDistanceLod = Mathf.Pow(Class_Interface.distanceLod, 2); scaleMoon = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.112f)); thisTransform.localScale = Vector3.one * (1 + (scaleMoon * 2)); randomRotationUp = Class_AdditionalTools.PositionSeed(thisTransform, 0.179f) * 0.03f; randomRotationLeft = Class_AdditionalTools.PositionSeed(thisTransform, 0.813f) * 0.03f; float uvOffsetX = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.123f)); landscape.GetComponent <Landscape>().uvOffset = new Vector2(uvOffsetX, 0.5f); //-------------- moonCube = ChunkCubesPool.GiveCube(); moonCubeTransform = moonCube.transform; moonCube.GetComponent <ChunkCube>().uvOffset = new Vector2(uvOffsetX, 0.5f); moonCubeTransform.parent = thisTransform; moonCubeTransform.localScale = Vector3.one * 10; moonCubeTransform.SetPositionAndRotation(thisTransform.position, thisTransform.rotation); moonCube.SetActive(true); //-------------- if (Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.151f)) < 0.6f) { atmosphere.SetActive(false); } else { atmosphere.transform.localRotation = Quaternion.Euler(Mathf.Cos(uvOffsetX * 1.1f) * 16, Mathf.Cos(uvOffsetX * 2.2f) * 16, Mathf.Cos(uvOffsetX * 3.3f) * 16); } if (Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 125.15f)) < 0.5f) { satellitesOrbit.SetActive(false); noSatellites = true; } else { StartCoroutine(Class_Moon.GenSatellites(thisTransform, satellitesOrbitTransform, scaleMoon, uvOffsetX)); } //-------------- StartCoroutine(Optimization()); StartCoroutine(FakeFixedUpdate()); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Cloud"); int amountClouds = 3 + Mathf.RoundToInt(Mathf.Abs(Class_AdditionalTools.PositionSeed(transform, 7.141f)) * 9); StartCoroutine(Class_Atmosphere.GenCloud(transform, cloud, uvOffset, amountClouds)); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Asteroid"); Class_AdditionalTools.RandomName(asteroidCubes, "Asteroid Cubes"); thisTransform.localRotation = Quaternion.Euler(Class_AdditionalTools.PositionSeed(thisTransform, 1.1f) * 90, Class_AdditionalTools.PositionSeed(thisTransform, 2.2f) * 90, Class_AdditionalTools.PositionSeed(thisTransform, 3.3f) * 90); int amountAsteroids = minAmountDetails + Mathf.RoundToInt(Mathf.Abs(Class_AdditionalTools.PositionSeed(transform, 8.98f)) * maxAmountDetails); StartCoroutine(Class_Asteroid.GenAsteroid(thisTransform, asteroidCubes.transform, Mathf.Pow(Class_Interface.distanceLod, 2), asteroidCubes, lod, amountAsteroids)); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenSatellites(Transform thisTransform, Transform satellitesOrbitTransform, float scaleMoon, float uvOffsetX) { //-------------- satellitesOrbitTransform.localRotation = Quaternion.Euler(Class_AdditionalTools.PositionSeed(thisTransform, 1.1f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 2.2f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 3.3f) * 15); float systemSize = 9 - (1 + (scaleMoon * 2.25f)); int systemDensity = 5; Vector3 center = Vector3.zero; for (int x = -systemDensity; x < systemDensity; x++) { for (int z = -systemDensity; z < systemDensity; z++) { yield return(delay0); Vector3 position = new Vector3(x, 0, z); float distance = Vector3.Distance(position, center); if (distance < systemDensity && distance > systemDensity * 0.6f) { float xt = (systemSize * 0.5f - 0.5f) + (x * systemSize); float zt = (systemSize * 0.5f - 0.5f) + (z * systemSize); float cosQtObj = Mathf.Cos((11.1f + xt + z) * (10.3f + x + zt) * Class_StarSystem.seed * 0.033f); float lperlinf = Mathf.PerlinNoise(cosQtObj, cosQtObj); if (lperlinf > 0.1f && lperlinf < 0.75f) { for (int i = 0; i < 2; i++) { GameObject obj = ChunkCubesPool.GiveCube(); obj.GetComponent <ChunkCube>().uvOffset = new Vector2(uvOffsetX, 0.5f); Transform tr = obj.transform; tr.rotation = Random.rotation; tr.localScale = Vector3.one * (1 + (lperlinf * scaleMoon * 8)); tr.parent = satellitesOrbitTransform; float scaleMoonM = scaleMoon * 10; float yt = Mathf.Cos(lperlinf * (lperlinf + xt + zt)) * scaleMoonM; tr.localPosition = new Vector3(xt + (Mathf.Cos(lperlinf * zt) * scaleMoonM), yt, zt + (Mathf.Cos(lperlinf * xt) * scaleMoonM)); obj.SetActive(true); yield return(null); } } } } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenAtmosphere(Transform thisTransform, GameObject clouds, int amountClouds, Vector2 uvOffset) { //-------------- for (int i = 0; i < amountClouds; i++) { yield return(null); GameObject cloudsObject = GameObject.Instantiate(clouds); cloudsObject.GetComponent <Cloud>().uvOffset = uvOffset; Transform cloudsTransform = cloudsObject.transform; cloudsTransform.parent = thisTransform; float cloudScale = (10 + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, (amountClouds + i) * 1.73f) * 11)) * 0.01f; cloudsTransform.localScale = Vector3.one * cloudScale; int sideSelection = Mathf.RoundToInt(1 + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, (amountClouds + i) * cloudScale * 1.73f)) * 5); float lVar0 = Class_AdditionalTools.PositionSeed(thisTransform, sideSelection + i + cloudScale * 3.141f) * (48 - (50 * cloudScale)); float lVar1 = Class_AdditionalTools.PositionSeed(thisTransform, sideSelection + i + cloudScale * 7.23f) * (48 - (50 * cloudScale)); if (sideSelection == 1) { cloudsTransform.localPosition = new Vector3(lVar0 * 0.01f, 0.44f, lVar1 * 0.01f); } if (sideSelection == 2) { cloudsTransform.localPosition = new Vector3(lVar0 * 0.01f, -0.44f, lVar1 * 0.01f); } if (sideSelection == 3) { cloudsTransform.localPosition = new Vector3(0.44f, lVar0 * 0.01f, lVar1 * 0.01f); } if (sideSelection == 4) { cloudsTransform.localPosition = new Vector3(-0.44f, lVar0 * 0.01f, lVar1 * 0.01f); } if (sideSelection == 5) { cloudsTransform.localPosition = new Vector3(lVar1 * 0.01f, lVar0 * 0.01f, 0.44f); } if (sideSelection == 6) { cloudsTransform.localPosition = new Vector3(lVar1 * 0.01f, lVar0 * 0.01f, -0.44f); } float xr = Class_AdditionalTools.PositionSeed(thisTransform, lVar0 + cloudScale * 7.13f) * 5; float yr = Class_AdditionalTools.PositionSeed(thisTransform, lVar0 + lVar1 + cloudScale * 6.93f) * 5; float zr = Class_AdditionalTools.PositionSeed(thisTransform, lVar1 + cloudScale * 1.13f) * 5; cloudsTransform.localRotation = Quaternion.Euler(xr, yr, zr); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Atmosphere"); uvOffset = new Vector2(Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.141f)), 0.5f); Class_AdditionalTools.UvMesh(GetComponent <MeshFilter>().mesh, uvOffset.x, uvOffset.y); int amountClouds = 10 + Mathf.RoundToInt(Mathf.Abs(Class_AdditionalTools.PositionSeed(transform, 3.141f)) * 25); if (cloudsOn == true) { StartCoroutine(Class_Atmosphere.GenAtmosphere(thisTransform, clouds, amountClouds, uvOffset)); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Planet"); sqrtDistanceLod = Mathf.Pow(Class_Interface.distanceLod, 2); Class_PlanetarySystem.listPlanets.Add(gameObject); randomRotationUp = Class_AdditionalTools.PositionSeed(thisTransform, 0.39f) * 0.025f; randomRotationLeft = Class_AdditionalTools.PositionSeed(thisTransform, 0.719f) * 0.025f; float uvOffsetX = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.115f)); landscape.GetComponent <Landscape>().uvOffset = new Vector2(uvOffsetX, 0.5f); //-------------- planetCube = ChunkCubesPool.GiveCube(); planetCubeTransform = planetCube.transform; planetCube.GetComponent <ChunkCube>().uvOffset = new Vector2(uvOffsetX, 0.5f); planetCubeTransform.parent = thisTransform; planetCubeTransform.localScale = Vector3.one * 10; planetCubeTransform.SetPositionAndRotation(thisTransform.position, thisTransform.rotation); planetCube.SetActive(true); //-------------- if (Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.15f)) < 0.3f) { atmosphere.SetActive(false); forest.SetActive(false); } else { atmosphereTransform.localRotation = Quaternion.Euler(Mathf.Cos(uvOffsetX * 1.1f) * 10, Mathf.Cos(uvOffsetX * 2.2f) * 10, Mathf.Cos(uvOffsetX * 3.3f) * 10); atmosphereTransform.localScale = Vector3.one * (18 + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 9.39f) * 4)); } //-------------- StartCoroutine(Optimization()); StartCoroutine(FakeFixedUpdate()); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AdditionalTools.RandomName(gameObject, "Planetary System"); sqrtDistanceLod = Mathf.Pow(Class_Interface.distanceLod, 2); randomRotationUp = Class_AdditionalTools.PositionSeed(thisTransform, 0.73f) * 0.05f; satellitesOrbit.transform.localRotation = Quaternion.Euler(Class_AdditionalTools.PositionSeed(thisTransform, 1.1f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 2.2f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 3.3f) * 15); //-------------- StartCoroutine(Class_PlanetarySystem.Generation(thisTransform, satellitesOrbit, planet, moon, asteroid, spawnAI)); StartCoroutine(Optimization()); StartCoroutine(FakeFixedUpdate()); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenChunkLandscape(Transform thisTransform) { //-------------- Vector2 uvOffset = new Vector2(Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.41f)), 0.5f); int numberCubeOutOfPool = Mathf.FloorToInt(Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 7.18f)) * 3) + 2; float cycleOffset = 1; //-------------- for (int i = 0; i < numberCubeOutOfPool; i++) { yield return(delay0); GameObject cubeOutOfPool = ChunkCubesPool.GiveCube(); Transform cubeTransform = cubeOutOfPool.transform; cubeTransform.parent = thisTransform; cycleOffset += i * 1.33f; float cubeScale = Mathf.Abs(Mathf.Cos(numberCubeOutOfPool * cycleOffset)) * 0.7f + 0.05f; float xs = 1 - (Mathf.Cos(cubeScale * cycleOffset) * 0.2f); float ys = 1 - (Mathf.Cos(cubeScale * cycleOffset * 1.35f) * 0.2f); float zs = 1 - (Mathf.Cos(cubeScale * cycleOffset * 0.76f) * 0.2f); cubeTransform.localScale = new Vector3(cubeScale * xs, cubeScale * ys, cubeScale * zs); float localVar0 = Mathf.Cos(cycleOffset * cubeScale) * 0.5f; float xt = localVar0 - (localVar0 * cubeScale); float localVar1 = Mathf.Cos((1.78f + cycleOffset * 1.14f) * cubeScale) * 0.5f; float yt = localVar1 - (localVar1 * cubeScale); float localVar2 = Mathf.Cos((5.78f + cycleOffset * 1.64f) * cubeScale) * 0.5f; float zt = localVar2 - (localVar2 * cubeScale); cubeTransform.localPosition = new Vector3(xt, yt, zt); float rt = Mathf.Cos(cubeScale * numberCubeOutOfPool * cycleOffset) * 15; cubeTransform.localRotation = Quaternion.Euler(rt, -rt, rt); cubeOutOfPool.GetComponent <ChunkCube>().uvOffset = uvOffset; cubeOutOfPool.SetActive(true); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Start() { //-------------- Class_AI.amountEnemyAIs += 1; Class_AdditionalTools.RandomName(gameObject, "Enemy AI"); distanceToPlayer = 99999; speedTaming = speedBehavior = lodSpeed = sign = variableRotation = 1; counter18 = counter21 = 20; if (seedScaleOn == true) { thisTransform.localScale = Vector3.one * (1 + (Mathf.Pow(Class_AdditionalTools.PositionSeed(thisTransform, 0.364f), 2) * sizeMultiplier)); } localScaleX = thisTransform.localScale.x; amountLife = 10 * (Mathf.Pow(localScaleX, 1.5f) * lifeMultiplier); StartCoroutine(Core()); StartCoroutine(CustomUpdate()); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator Generation(Transform thisTransform, Material treesMaterial) { //-------------- yield return(delay0); float seedGen = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.9f)); Material localTreeMaterial = new Material(treesMaterial); localTreeMaterial.SetTextureOffset("_MainTex", new Vector2(seedGen, 0)); Vector3 treeScale = Vector3.one / thisTransform.lossyScale.x; float scaleProportion = 1 / thisTransform.lossyScale.x; int numberTreeOutOfPool = Mathf.FloorToInt(seedGen * 30) + 50; int treePackType = Mathf.FloorToInt(seedGen * 8) + 1; int treeOutOfPoolSeedPosition = 1; float cycleOffset = 1; GameObject treeObject = null; //-------------- for (int i = 0; i < numberTreeOutOfPool; i++) { yield return(null); cycleOffset += i * 1.37f; float localVar0 = Mathf.Cos((numberTreeOutOfPool + cycleOffset) * (seedGen * 4.7f)); int treeType = Mathf.RoundToInt(Mathf.PerlinNoise(localVar0, localVar0) * 5.7f); if (treePackType == 1) { if (treeType <= 2) { treeObject = TreesPool.GiveTree(6); } else { treeObject = TreesPool.GiveTree(5); } } else if (treePackType == 2) { if (treeType == 1) { treeObject = TreesPool.GiveTree(0); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(6); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(4); } } else if (treePackType == 3) { if (treeType == 1) { treeObject = TreesPool.GiveTree(1); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(5); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(7); } } else if (treePackType == 4) { if (treeType == 1) { treeObject = TreesPool.GiveTree(0); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(5); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(7); } } else if (treePackType == 5) { if (treeType <= 2) { treeObject = TreesPool.GiveTree(3); } else { treeObject = TreesPool.GiveTree(2); } } else if (treePackType == 6) { if (treeType == 1) { treeObject = TreesPool.GiveTree(0); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(6); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(5); } } else if (treePackType == 7) { if (treeType == 1) { treeObject = TreesPool.GiveTree(7); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(6); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(4); } } else if (treePackType == 8) { if (treeType == 1) { treeObject = TreesPool.GiveTree(1); } else if (treeType == 2) { treeObject = TreesPool.GiveTree(3); } else if (treeType == 3) { treeObject = TreesPool.GiveTree(2); } } if (treeObject != null) { Transform treeTransform = treeObject.transform; treeTransform.parent = thisTransform; float treeOutOfPoolScale = 0.5f + (Mathf.Abs(Mathf.Cos(seedGen * cycleOffset)) * 1.25f); treeTransform.localScale = treeScale * treeOutOfPoolScale; treeOutOfPoolSeedPosition = Mathf.FloorToInt(Mathf.Abs(Mathf.Cos(((13.61f * treeOutOfPoolScale) + seedGen) * cycleOffset + treeOutOfPoolSeedPosition)) * 6) + 1; float localVar1 = Mathf.Cos((treeOutOfPoolSeedPosition + cycleOffset + Class_StarSystem.seed) * (treeOutOfPoolScale + seedGen)) * 0.425f; float localVar2 = localVar1 - (localVar1 * scaleProportion); float localVar3 = Mathf.Cos((treeOutOfPoolSeedPosition + cycleOffset + Class_StarSystem.seed) * (treeOutOfPoolScale + seedGen + 0.561f)) * 0.425f; float localVar4 = localVar3 - (localVar3 * scaleProportion); float treeOutOfPoolRotation = Mathf.Cos(cycleOffset * seedGen) * 125; if (treeOutOfPoolSeedPosition == 1) { treeTransform.localPosition = new Vector3(localVar2, 0.5f, localVar4); treeTransform.eulerAngles = new Vector3(0, treeOutOfPoolRotation, 0); } if (treeOutOfPoolSeedPosition == 2) { treeTransform.localPosition = new Vector3(localVar2, -0.5f, localVar4); treeTransform.eulerAngles = new Vector3(0, treeOutOfPoolRotation, 180); } if (treeOutOfPoolSeedPosition == 3) { treeTransform.localPosition = new Vector3(0.5f, localVar2, localVar4); treeTransform.eulerAngles = new Vector3(treeOutOfPoolRotation, 0, -90); } if (treeOutOfPoolSeedPosition == 4) { treeTransform.localPosition = new Vector3(-0.5f, localVar2, localVar4); treeTransform.eulerAngles = new Vector3(treeOutOfPoolRotation, 0, 90); } if (treeOutOfPoolSeedPosition == 5) { treeTransform.localPosition = new Vector3(localVar4, localVar2, 0.5f); treeTransform.eulerAngles = new Vector3(90, treeOutOfPoolRotation, treeOutOfPoolRotation); } if (treeOutOfPoolSeedPosition == 6) { treeTransform.localPosition = new Vector3(localVar4, localVar2, -0.5f); treeTransform.eulerAngles = new Vector3(-90, treeOutOfPoolRotation, -treeOutOfPoolRotation); } foreach (Transform child in treeTransform) { child.GetComponent <Renderer>().material = localTreeMaterial; } treeObject.SetActive(true); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenLandscape(Transform thisTransform, GameObject chunkLandscape, Vector2 uvOffset) { //-------------- float seedGeneration = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 0.22f)); int numberCubeOutOfPool = Mathf.FloorToInt(Mathf.Abs(Mathf.Cos(seedGeneration * Class_StarSystem.seed)) * 11) + 9; int cubeOutOfPoolSeedPosition = 1; float cycleOffset = 1; GameObject cubeOutOfPool; //-------------- for (int i = 0; i < numberCubeOutOfPool; i++) { yield return(delay0); if (seedGeneration > 0.5f) { cubeOutOfPool = ChunkCubesPool.GiveCube(); cubeOutOfPool.GetComponent <ChunkCube>().uvOffset = uvOffset; } else { cubeOutOfPool = GameObject.Instantiate(chunkLandscape); } Transform cubeTransform = cubeOutOfPool.transform; cubeTransform.parent = thisTransform; cycleOffset += i * 1.33f; float cubeScale = Mathf.Abs(Mathf.Cos(numberCubeOutOfPool * cycleOffset * seedGeneration)) * 0.25f + 0.05f; float xs = 1 - (Mathf.Cos((cubeScale + seedGeneration) * cycleOffset) * 0.1f); float ys = 1 - (Mathf.Cos((cubeScale + seedGeneration) * cycleOffset * 1.35f) * 0.1f); float zs = 1 - (Mathf.Cos((cubeScale + seedGeneration) * cycleOffset * 0.76f) * 0.1f); cubeTransform.localScale = new Vector3(cubeScale * xs, cubeScale * ys, cubeScale * zs); cubeOutOfPoolSeedPosition = Mathf.FloorToInt(Mathf.Abs(Mathf.Cos((1.3f + seedGeneration) * cycleOffset + cubeOutOfPoolSeedPosition + cubeScale)) * 6) + 1; float localVar0 = Mathf.Cos((cubeOutOfPoolSeedPosition + cycleOffset) * (cubeScale + seedGeneration)) * 0.46f; float localVar1 = localVar0 - (localVar0 * cubeScale); float localVar2 = Mathf.Cos((cubeOutOfPoolSeedPosition * 1.78f + cycleOffset * 1.14f) * (cubeScale + seedGeneration)) * 0.46f; float localVar3 = localVar2 - (localVar2 * cubeScale); if (cubeOutOfPoolSeedPosition == 1) { cubeTransform.localPosition = new Vector3(localVar1, 0.5f, localVar3); } if (cubeOutOfPoolSeedPosition == 2) { cubeTransform.localPosition = new Vector3(localVar1, -0.5f, localVar3); } if (cubeOutOfPoolSeedPosition == 3) { cubeTransform.localPosition = new Vector3(0.5f, localVar1, localVar3); } if (cubeOutOfPoolSeedPosition == 4) { cubeTransform.localPosition = new Vector3(-0.5f, localVar1, localVar3); } if (cubeOutOfPoolSeedPosition == 5) { cubeTransform.localPosition = new Vector3(localVar3, localVar1, 0.5f); } if (cubeOutOfPoolSeedPosition == 6) { cubeTransform.localPosition = new Vector3(localVar3, localVar1, -0.5f); } float rt = Mathf.Cos((cubeScale + seedGeneration) * numberCubeOutOfPool * cycleOffset) * 20; cubeTransform.localRotation = Quaternion.Euler(rt, -rt, rt); if (cubeOutOfPool.activeSelf == false) { cubeOutOfPool.SetActive(true); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator GenAsteroid(Transform thisTransform, Transform asteroidCubesTransform, float distanceLod, GameObject asteroidCubes, GameObject lod, int amountAsteroids) { //-------------- for (int i = 0; i < amountAsteroids; i++) { yield return(null); GameObject cubeOutOfPool = ChunkCubesPool.GiveCube(); if (cubeOutOfPool != null) { cubeOutOfPool.layer = 30; Transform cubeOutOfPoolTransform = cubeOutOfPool.transform; cubeOutOfPoolTransform.parent = asteroidCubesTransform; float uvOffsetX = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, amountAsteroids + i + 1.27f)); cubeOutOfPool.GetComponent <ChunkCube>().uvOffset = new Vector2(uvOffsetX, 0.025f); float cubeOutOfPoolScaleXZ = 0.15f + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, uvOffsetX + i + 4.13f) * 0.7f); float cubeOutOfPoolY = 0.15f + Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, cubeOutOfPoolScaleXZ + uvOffsetX + i + 1.9f) * 0.7f); cubeOutOfPoolTransform.localScale = new Vector3(cubeOutOfPoolScaleXZ, cubeOutOfPoolY, cubeOutOfPoolScaleXZ); float xt = Class_AdditionalTools.PositionSeed(thisTransform, i + cubeOutOfPoolScaleXZ * 1.241f) * (0.6f - (0.6f * cubeOutOfPoolScaleXZ)); float yt = Class_AdditionalTools.PositionSeed(thisTransform, i + cubeOutOfPoolY * 8.83f) * (0.6f - (0.6f * cubeOutOfPoolY)); float zt = Class_AdditionalTools.PositionSeed(thisTransform, i + cubeOutOfPoolScaleXZ * 3.31f) * (0.6f - (0.6f * cubeOutOfPoolScaleXZ)); cubeOutOfPoolTransform.localPosition = new Vector3(xt, yt, zt); float xr = Class_AdditionalTools.PositionSeed(thisTransform, xt + cubeOutOfPoolScaleXZ * 7.13f) * 20; float yr = Class_AdditionalTools.PositionSeed(thisTransform, yt + cubeOutOfPoolY * 6.93f) * 20; float zr = Class_AdditionalTools.PositionSeed(thisTransform, zt + cubeOutOfPoolScaleXZ * 1.13f) * 20; cubeOutOfPoolTransform.localRotation = Quaternion.Euler(xr, yr, zr); cubeOutOfPool.SetActive(true); } } //-------------- Class_AdditionalTools.UvMesh(lod.GetComponent <MeshFilter>().mesh, 0.4f, 0.025f); while (true) { yield return(delay0); if (asteroidCubes.transform.childCount > 0) { if (Class_Controller.SqrMagnitudeToPlayer(thisTransform) < distanceLod) { asteroidCubes.SetActive(true); lod.SetActive(false); } else { asteroidCubes.SetActive(false); lod.SetActive(true); } } else { thisTransform.gameObject.SetActive(false); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator Generation(Transform thisTransform, Transform satellitesOrbit, GameObject planet, GameObject moon, GameObject asteroid, GameObject spawnAI) { //-------------- float scaleSystem = Mathf.Abs(Class_AdditionalTools.PositionSeed(thisTransform, 5.18f)); int typeAI = 0; int discretenessOrbitRadius = 3; float conditionalSizeOrbit = 80 + (scaleSystem * 40); Transform ptr = Transform.Instantiate(planet).transform; ptr.SetPositionAndRotation(thisTransform.position, thisTransform.rotation); ptr.localScale = Vector3.one * (4.5f + (scaleSystem * 3)); ptr.parent = thisTransform; if (Class_AI.aiSpawnOn == true) { if (listPlanets.Count > 0) { if (Class_AdditionalTools.PositionSeed(thisTransform, 0.456f) < 0.85f) { typeAI = 1; } else { typeAI = 2; } } else { typeAI = 2; } } yield return(delay0); Vector3 curPos = thisTransform.position; Quaternion curRot = thisTransform.rotation; Vector3 center = Vector3.zero; for (int x = -discretenessOrbitRadius; x < discretenessOrbitRadius; x++) { for (int z = -discretenessOrbitRadius; z < discretenessOrbitRadius; z++) { yield return(delay0); Vector3 position = new Vector3(x, 0, z); float distance = Vector3.Distance(position, center); if (distance < discretenessOrbitRadius && distance > discretenessOrbitRadius * 0.5f) { float xt = (conditionalSizeOrbit * 0.5f - 0.5f) + (x * conditionalSizeOrbit); float zt = (conditionalSizeOrbit * 0.5f - 0.5f) + (z * conditionalSizeOrbit); float cosQtObj = Mathf.Cos((11.1f + xt * 3.3f + z) * (10.3f + x + zt * 3.3f) * Class_StarSystem.seed * 0.033f); float lperlinf = Mathf.PerlinNoise(cosQtObj, cosQtObj); if (lperlinf > 0.25f && lperlinf < 0.4f) { Transform mtr = Transform.Instantiate(moon).transform; mtr.parent = satellitesOrbit; float yt = (Mathf.Pow(lperlinf * 10, 5) * 0.5f) - 200; mtr.localPosition = new Vector3(xt, yt, zt); } else if (lperlinf > 0.4f && lperlinf < 0.6f) { Transform atr = Transform.Instantiate(asteroid).transform; atr.localScale = Vector3.one * Mathf.Pow(lperlinf * 10, 1.5f) * 2.5f; atr.parent = satellitesOrbit; float yt = (Mathf.Pow(lperlinf * 10, 4) * 0.5f) - 200; atr.localPosition = new Vector3(xt, yt, zt); } if (lperlinf > 0.4f && Class_AI.aiSpawnOn) { GameObject obj = GameObject.Instantiate(spawnAI, curPos, curRot); if (typeAI == 1) { obj.GetComponent <SpawnAI>().enemyAiOn = true; } if (typeAI == 2) { obj.GetComponent <SpawnAI>().friendlyAiOn = true; } obj.transform.position = curPos + new Vector3(xt * 0.6f, 0, zt * 0.6f); } } } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IEnumerator GenerationBlackHole() { //-------------- material.SetFloat("_HoleSize", 0.7f + (Mathf.Cos(Class_StarSystem.seed * 12.5f) * 0.11f)); Color colorA = new Color(RenderSettings.fogColor.r, RenderSettings.fogColor.g, RenderSettings.fogColor.b, 0.9f); Color colorB = new Color(0.62f, 0.43f, 0.4f, 0.9f); particleMain = crownA.main; particleMain.startColor = new ParticleSystem.MinMaxGradient(colorA, colorB); colorA = new Color(colorA.r * 1.4f, colorA.g * 1.4f, colorA.b * 1.4f, 0.9f); particleMain = crownB.main; particleMain.startColor = new ParticleSystem.MinMaxGradient(colorA, new Color(colorB.r * 1.4f, colorB.g * 1.4f, colorB.b * 1.4f, 0.9f)); colorA = new Color(colorA.r * 1.3f, colorA.g * 1.3f, colorA.b * 1.3f, 0.9f); colorB = new Color(0.9f, 0.4f, 0.4f, 0.9f); particleMain = quasarA.main; particleMain.startColor = new ParticleSystem.MinMaxGradient(colorA, colorB); var particleShape = quasarA.shape; particleShape.radius = Class_StarSystem.SeedAbsCos() * 0.5f; particleShape.angle = 1 + (Mathf.Abs(Mathf.Cos(Class_StarSystem.seed * Class_StarSystem.SeedAbsCos())) * 3); particleMain = quasarB.main; particleMain.startColor = new ParticleSystem.MinMaxGradient(colorA, colorB); particleShape = quasarB.shape; particleShape.radius = Class_StarSystem.SeedAbsCos() * 0.5f; particleShape.angle = 1 + (Mathf.Abs(Mathf.Cos(Class_StarSystem.seed * Class_StarSystem.SeedAbsCos())) * 3); //-------------- thisTransform.localScale = Vector3.one * (Class_StarSystem.SeedAbsCos() + 0.3f) * 0.9f; soundFx.maxDistance = thisTransform.localScale.x * 800; distanceDetectedPlayer = Mathf.Pow(soundFx.maxDistance + 50, 2); float scaleblackHole = (Class_StarSystem.SeedAbsCos() + 0.2f) * 50; thisTransform.rotation = new Quaternion(Class_StarSystem.SeedAbsCos() * 60, Class_StarSystem.SeedAbsCos() * 60, Class_StarSystem.SeedAbsCos() * -60, 0); //-------------- satellitesOrbit.localRotation = Quaternion.Euler(Class_AdditionalTools.PositionSeed(thisTransform, 1.1f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 2.2f) * 15, Class_AdditionalTools.PositionSeed(thisTransform, 3.3f) * 15); float systemSize = 2 * scaleblackHole / thisTransform.localScale.x; int systemDensity = 7; //-------------- for (int x = -systemDensity; x < systemDensity; x++) { for (int z = -systemDensity; z < systemDensity; z++) { yield return(null); float distance = Vector3.Distance(new Vector3(x, 0, z), Vector3.zero); if (distance < systemDensity && distance > systemDensity * 0.6f) { float xt = (systemSize * 0.5f - 0.5f) + (x * systemSize); float zt = (systemSize * 0.5f - 0.5f) + (z * systemSize); float cosQtObj = Mathf.Cos((11.1f + xt + z) * (10.3f + x + zt) * Class_StarSystem.seed * 0.033f); float lperlinf = Mathf.PerlinNoise(cosQtObj, cosQtObj); if (lperlinf > 0.1f && lperlinf < 0.75f) { GameObject obj = Instantiate(asteroid); Transform tr = obj.transform; obj.GetComponent <Asteroid>().minAmountDetails = 2; obj.GetComponent <Asteroid>().maxAmountDetails = 2; tr.rotation = Random.rotation; tr.localScale = Vector3.one * (1 + (lperlinf * scaleblackHole * 0.8f)); tr.parent = satellitesOrbit; float yt = Mathf.Cos(lperlinf * (lperlinf + xt + zt)) * scaleblackHole; tr.localPosition = new Vector3(xt + (Mathf.Cos(lperlinf * zt) * scaleblackHole), yt, zt + (Mathf.Cos(lperlinf * xt) * scaleblackHole)); obj.SetActive(true); } } } } //-------------- while (Class_Controller.playerAlive == true) { triggerDetectedPlayer = Class_Controller.SqrMagnitudeToPlayer(thisTransform) < distanceDetectedPlayer; if (soundFx.enabled != triggerDetectedPlayer) { soundFx.enabled = triggerDetectedPlayer; } QuasarAColider.SetActive(true); QuasarBColider.SetActive(true); yield return(delay0); QuasarAColider.SetActive(false); QuasarBColider.SetActive(false); yield return(delay0); } //-------------- }