示例#1
0
        private void Update()
        {
            if (state == State.JOOL_SHRINK)
            {
                joolScale -= SHRINK_RATE * Time.deltaTime;
            }
            else if (state == State.SUN_GROW || state == State.EXPLOSION_GROW)
            {
                float x = (Time.time - stateTime);
                if (state == State.SUN_GROW)
                {
                    float xGR = x * GROW_RATE;
                    if (x < 2 * (FINAL_SCALE - SHRUNK_SCALE) / GROW_RATE)
                    {
                        // This is calculated as a quadratic to give a smoothed growth
                        // b = GROWTH_RATE (to match the initial kick of the explosion
                        // c = SHRUNK_SCALE (to match the starting size)
                        // a = calculated such that at (y = FINAL_SCALE) we have a local maximum

                        joolScale = -(xGR * xGR) / (4 * FINAL_SCALE - SHRUNK_SCALE) + xGR + SHRUNK_SCALE;
                    }
                    else
                    {
                        joolScale = FINAL_SCALE;
                    }
                }
                explosionScale = (SHRUNK_SCALE + x * GROW_RATE) * 1.01f;
            }

            if (transformed && secondSun == null)
            {
                Debug.Log("JoolNova: Setting up second sun");
                Sun old = Sun.Instance;
                secondSun    = Instantiate(Sun.Instance) as Sun;
                Sun.Instance = old;
                foreach (FieldInfo field in typeof(Sun).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    if (field.GetValue(secondSun) == null)
                    {
                        field.SetValue(secondSun, field.GetValue(old));
                    }
                }

                secondSun.GetComponent <Light>().color = newSunColor;
                secondSun.gameObject.SetActive(true);
                secondSun.sun                   = jool;
                secondSun.sunFlare.color        = newSunColor;
                secondSun.sunFlare.brightness  *= 0.25f;
                secondSun.enabled               = true;
                secondSun.useLocalSpaceSunLight = true;
                secondSun.SunlightEnabled(transformed);
            }

            if (secondSun != null)
            {
                // Set the light intensity for our red dwarf - this seems to want to get reset
                Light sunlight = sunLightField.GetValue(secondSun) as Light;
                sunlight.intensity = 0.5f;
            }
        }
示例#2
0
    private void SpawnMySun()
    {
        Sun   sunClone = (Sun)Instantiate(sunPrefab, transform.position, transform.rotation);
        float sunSize  = 2;

        sunClone.transform.localScale = new Vector3(sunSize, sunSize, 0f);
        sunClone.transform.SetParent(sunParent.transform);
        sunClone.transform.localPosition = new Vector3(UnityEngine.Random.Range(-5f, 5f), sunParent.transform.position.y, 0f);
        sunClone.GetComponent <Rigidbody2D>().velocity = new Vector2(Random.Range(-2, 2), UnityEngine.Random.Range(-10, -1));
    }
示例#3
0
 private void LoadLevel(int value)
 {
     Sun.GetComponent <RectTransform>().anchoredPosition = RandomPos();
     win        = false;
     canClick   = false;
     onceCalled = true;
     ShootBtn.GetComponent <BoxCollider2D>().enabled = true;
     text.text = "Prepare";
     delay     = Random.Range(2.0f, 5.0f);
     if (value > 0 && value < 5)
     {
         reverseDelay = Random.Range(0.7f, 0.9f) + MainMenu.s_AdditionalDelay;
     }
     else if (value > 4 && value < 9)
     {
         reverseDelay = Random.Range(0.4f, 0.6f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(65 - MainMenu.s_AddtitionalChance))
         {
             reward = 4;
         }
     }
     else if (value > 8 && value < 13)
     {
         reverseDelay = Random.Range(0.2f, 0.35f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(60 - MainMenu.s_AddtitionalChance))
         {
             reward = 6;
         }
     }
     else if (value > 12)
     {
         reverseDelay = Random.Range(0.05f, 0.2f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(50 - MainMenu.s_AddtitionalChance))
         {
             reward = 8;
         }
     }
     else if (value == -1)
     {
         reverseDelay = Random.Range(0.8f, 1.2f) + MainMenu.s_AdditionalDelay;
     }
     else if (value == -2)
     {
         reverseDelay = Random.Range(0.35f, 0.75f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(65 - MainMenu.s_AddtitionalChance))
         {
             reward = 2;
         }
     }
     else if (value == -3)
     {
         reverseDelay = Random.Range(0.15f, 0.35f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(60 - MainMenu.s_AddtitionalChance))
         {
             reward = Random.Range(3, 6);
         }
     }
     else if (value == -4)
     {
         reverseDelay = Random.Range(0.03f, 0.125f) + MainMenu.s_AdditionalDelay;
         if (ChanceForMoney(40 - MainMenu.s_AddtitionalChance))
         {
             reward = Random.Range(6, 11);
         }
     }
 }
        private void Update()
        {
            if (state == State.JOOL_SHRINK)
            {
                joolScale -= SHRINK_RATE * Time.deltaTime;
            }
            else if (state == State.SUN_GROW || state == State.EXPLOSION_GROW)
            {
                float x = (Time.time - stateTime);
                if (state == State.SUN_GROW)
                {
                    float xGR = x * GROW_RATE;
                    if (x < 2 * (FINAL_SCALE - SHRUNK_SCALE) / GROW_RATE)
                    {
                        // This is calculated as a quadratic to give a smoothed growth
                        // b = GROWTH_RATE (to match the initial kick of the explosion
                        // c = SHRUNK_SCALE (to match the starting size)
                        // a = calculated such that at (y = FINAL_SCALE) we have a local maximum

                        joolScale = -(xGR * xGR) / (4 * FINAL_SCALE - SHRUNK_SCALE) + xGR + SHRUNK_SCALE;
                    }
                    else
                    {
                        joolScale = FINAL_SCALE;
                    }
                }
                explosionScale = (SHRUNK_SCALE + x * GROW_RATE) * 1.01f;
            }

            if (transformed && secondSun == null)
            {
                Debug.Log("JoolNova: Setting up second sun");
                Sun old = Sun.Instance;
                secondSun = Instantiate(Sun.Instance) as Sun;
                Sun.Instance = old;
                foreach (FieldInfo field in typeof(Sun).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    if (field.GetValue(secondSun) == null)
                    {
                        field.SetValue(secondSun, field.GetValue(old));
                    }
                }

                secondSun.GetComponent<Light>().color = newSunColor;
                secondSun.gameObject.SetActive(true);
                secondSun.sun = jool;
                secondSun.sunFlare.color = newSunColor;
                secondSun.sunFlare.brightness *= 0.25f;
                secondSun.enabled = true;
                secondSun.useLocalSpaceSunLight = true;
                secondSun.SunlightEnabled(transformed);
            }

            if (secondSun != null)
            {
                // Set the light intensity for our red dwarf - this seems to want to get reset
                Light sunlight = sunLightField.GetValue(secondSun) as Light;
                sunlight.intensity = 0.5f;
            }
        }