Beispiel #1
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    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));

        //--------------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    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 OnEnable()
    {
        //--------------

        Vector3 thisPosition = thisTransform.position;

        currentStateTransform.rotation = Random.rotation;

        //--------------

        getIntSeedGeneration = PlayerPrefs.GetInt(Class_MenuController.MenuSeed(thisPosition).ToString(), 0);

        if (getIntSeedGeneration == 0)
        {
            stateFriendly.transform.localScale = Vector3.one * 0.15f;
            stateEnemy.transform.localScale    = Vector3.one * 0.15f;
            stateFriendly.SetActive(true);
            stateEnemy.SetActive(true);
        }
        else if (getIntSeedGeneration == 1)
        {
            stateFriendly.transform.localScale = Vector3.one * 0.2f;
            stateFriendly.SetActive(true);
            stateEnemy.SetActive(false);
        }
        else if (getIntSeedGeneration == 2)
        {
            stateEnemy.transform.localScale = Vector3.one * 0.2f;
            stateFriendly.SetActive(false);
            stateEnemy.SetActive(true);
        }

        selected.SetActive(false);

        //--------------

        float seedAbsCos = Mathf.Abs(Mathf.Cos(Class_MenuController.MenuSeed(thisPosition)));

        if (Class_MenuController.MenuSeed(thisPosition) % 7 == 0)
        {
            sun.SetActive(false);
            blackHole.SetActive(true);
            blackHole.transform.localScale = Vector3.one * (seedAbsCos + 0.35f) * 2.5f;
        }
        else
        {
            blackHole.SetActive(false);
            sun.SetActive(true);
            Class_AdditionalTools.UvMesh(sun.GetComponent <MeshFilter>().mesh, seedAbsCos, 0.5f);
            sun.transform.localScale = Vector3.one * (seedAbsCos + 0.35f);
        }

        //--------------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    public static IEnumerator Customization(GameObject gameObject, MeshFilter bodyLod0, MeshFilter eyeLod0, MeshFilter bodyLod1, MeshFilter eyeLod1, GameObject particlesDead, float eyeLod0UvX)
    {
        //--------------

        FriendlyAI friendlyAI = gameObject.GetComponent <FriendlyAI>();
        bool       trigger0 = false, trigger1 = false;

        //--------------

        while (friendlyAI.dead == false)
        {
            yield return(delay0);

            if (friendlyAI.aiAgr == true)
            {
                if (trigger0 == false)
                {
                    trigger0 = true;
                    trigger1 = false;
                    Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.85f, 0.25f);
                    Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.85f, 0.25f);
                }
            }
            else
            {
                if (trigger1 == false)
                {
                    trigger0 = false;
                    trigger1 = true;
                    Class_AdditionalTools.UvMesh(eyeLod0.mesh, eyeLod0UvX, 0.4f);
                    Class_AdditionalTools.UvMesh(eyeLod1.mesh, eyeLod0UvX, 0.4f);
                }
            }
        }

        //--------------

        if (friendlyAI.dead == true)
        {
            Class_AdditionalTools.UvMesh(bodyLod0.mesh, 0.15f, 0.04f);
            Class_AdditionalTools.UvMesh(bodyLod1.mesh, 0.15f, 0.04f);
            Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.85f, 0.04f);
            Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.85f, 0.04f);
            particlesDead.SetActive(true);
            yield return(delay1);

            particlesDead.SetActive(false);
        }

        //--------------
    }
Beispiel #5
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    public static void DebrisOutOfPool(Transform thisTransform, Renderer thisRenderer, GameObject obj, int numberDebris, float scale, Vector2 uvOffset)
    {
        //--------------

        if (obj != null)
        {
            Transform tr = obj.transform;
            tr.SetPositionAndRotation(thisTransform.position, Random.rotation);
            tr.localScale = (thisRenderer.bounds.size / numberDebris) * scale;
            Class_AdditionalTools.UvMesh(obj.GetComponent <MeshFilter>().mesh, uvOffset.x, uvOffset.y);
            obj.SetActive(true);
        }

        //--------------
    }
Beispiel #6
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    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));
        }

        //--------------
    }
Beispiel #7
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Start()
    {
        //--------------

        if (on == true)
        {
            rotateSeedG = Class_StarSystem.SeedAbsCos() * 0.02f;

            Class_AdditionalTools.UvMesh(sunBody.GetComponent <MeshFilter>().mesh, Class_StarSystem.SeedAbsCos(), 0.5f);
            thisTransform.localScale = Vector3.one * (Class_StarSystem.SeedAbsCos() + 0.2f);
            Color sunParticleColor = Color.HSVToRGB(Class_StarSystem.SeedAbsCos(), 1, 0.1f);
            ParticleSystem.MainModule sunCrownMain = sunCrown.main;
            sunCrownMain.startColor = new ParticleSystem.MinMaxGradient(new Color(sunParticleColor.r, sunParticleColor.g, sunParticleColor.b, 0.95f));
            ParticleSystem.MainModule sunPlasmaMain = sunPlasma.main;
            sunPlasmaMain.startColor = new ParticleSystem.MinMaxGradient(new Color(sunParticleColor.r * 9, sunParticleColor.g * 9, sunParticleColor.b * 9, 0.7f));
        }

        //--------------
    }
Beispiel #8
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void OnEnable()
    {
        //--------------

        if (outPool == false)
        {
            outPool = true;
            Class_AdditionalTools.RandomName(gameObject, "Chunk Cube");
            Class_AdditionalTools.UvMesh(GetComponent <MeshFilter>().mesh, uvOffset.x, uvOffset.y);
            amountDamage = currentDamage = 0;
            brokenStage0 = false;
            thisScaleX   = thisTransform.lossyScale.x;

            if (thisScaleX <= 4)
            {
                gameObject.layer = 21;
            }
            else if (thisScaleX > 4 && thisScaleX <= 8)
            {
                gameObject.layer = 20;
            }
            else if (thisScaleX > 8)
            {
                gameObject.layer = 19;
            }

            faultSize            = Random.Range(2.0f, 3.0f) + thisScaleX * 0.75f;
            faultSizeOptimize    = 1;
            numberDebris         = Random.Range(2, 5);
            numberCubeOutOfPool  = Random.Range(2, 4);
            cubeOutOfPoolScale   = 1.0f / numberCubeOutOfPool;
            thisRenderer.enabled = thisBoxCollider.enabled = 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 Customization(GameObject gameObject, MeshFilter bodyLod0, MeshFilter eyeLod0, MeshFilter bodyLod1, MeshFilter eyeLod1, GameObject particlesDead)
    {
        //--------------

        EnemyAI enemyAI = gameObject.GetComponent <EnemyAI>();
        bool    aggression = false, taming = false, trigger0 = false, trigger1 = false, trigger2 = false;

        //--------------

        while (enemyAI.dead == false)
        {
            yield return(delay0);

            if (Class_Interface.tamingEnabled == true)
            {
                taming     = true;
                aggression = false;
            }
            else
            {
                taming = false;
                if (enemyAI.aiAgr == true)
                {
                    aggression = true;
                }
                else
                {
                    aggression = false;
                }
            }

            //---

            if (taming == false && aggression == false)
            {
                if (trigger0 == false)
                {
                    trigger0 = true;
                    trigger1 = false;
                    trigger2 = false;
                    Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.15f, 0.25f);
                    Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.15f, 0.25f);
                }
            }
            else if (taming == true && aggression == false)
            {
                if (trigger1 == false)
                {
                    trigger0 = false;
                    trigger1 = true;
                    trigger2 = false;
                    Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.5f, 0.25f);
                    Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.5f, 0.25f);
                }
            }
            else if (taming == false && aggression == true)
            {
                if (trigger2 == false)
                {
                    trigger0 = false;
                    trigger1 = false;
                    trigger2 = true;
                    Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.85f, 0.25f);
                    Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.85f, 0.25f);
                }
            }
        }

        //--------------

        if (enemyAI.dead == true)
        {
            Class_AdditionalTools.UvMesh(bodyLod0.mesh, 0.15f, 0.04f);
            Class_AdditionalTools.UvMesh(bodyLod1.mesh, 0.15f, 0.04f);
            Class_AdditionalTools.UvMesh(eyeLod0.mesh, 0.85f, 0.04f);
            Class_AdditionalTools.UvMesh(eyeLod1.mesh, 0.85f, 0.04f);
            particlesDead.SetActive(true);
            yield return(delay1);

            particlesDead.SetActive(false);
        }

        //--------------
    }