// Use this for initialization
 void Start()
 {
     currentTime = clock.getCurrentTime();
     if (currentTime == null)
     {
         Debug.LogError("MOONPHASES: MoonPhases currentTime is null");
     }
 }
        void Start()
        {
            maxIntensityValue = biome.GetMaxIntensityValue();
            //obtener estado inicial como el valor mas probable de cada estado a menos que hayan inconsistencias ( mas lluvia que nubes, lluvia y nieve a la vez....)
            GetInitialSeason(clock.getCurrentDate());
            currentState = GetInitialState();
            visualizeState();
            lastUpdate = clock.getCurrentTime().Clone();

            //calcular matrices acumulativas
            updateAcumulativeValues(currentSeason.GetIndex());
        }
        // Use this for initialization
        void Start()
        {
            Date currentDate = clock.getCurrentDate();

            GetInitialSeason(currentDate);
            currentTime = clock.getCurrentTime();

            if (debug)
            {
                Debug.Log(this.name);
                Debug.Log("Current season: " + currentSeason);
                Debug.Log("start date: " + currentSeason.GetStartDate());
                Debug.Log("current date: " + currentDate);
                Debug.Log("current time: " + currentTime);
            }

            Date transitionInEnd = currentSeason.GetStartDate().DateWithDays(transiotion_days);

            if (debug)
            {
                Debug.Log("TransitionIn end: " + transitionInEnd);
            }

            //TODO: transiotion_days/2 es resultado de division entera, si se mete un numero de dias impar faltará un dia en la transicion. habra que hacer comprobaciones o algo, pero no antes de la presentacion, que hay prisa
            if (currentDate.CompareTo(transitionInEnd) < 0)
            {
                phase          = TRANSITION_IN;
                previousSeason = GetPreviousSeason(currentSeason);                 //TODO: hay que implementar el modo de recuperar la estacion anterior
                ChangeColor(currentSeason.GetStartDate().DaysBetween(currentDate), currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds());
                if (debug)
                {
                    Debug.Log(" initial state detected to be transitioning in from season " + previousSeason.name);
                    Debug.Log("time since the season change: " + (currentSeason.GetStartDate().DaysBetween(currentDate)) + " days and " + (currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()) + "Seconds");
                    Debug.Break();
                }
            }
            else
            {
                phase          = WAITING;
                previousSeason = currentSeason;
                ChangeColor(0, 0);
                if (debug)
                {
                    Debug.Log(" initial state detected to be waiting to season " + currentSeason.ToString());
                }
            }
        }
Example #4
0
 // Update is called once per frame
 void Update()
 {
     timeText.text         = clock.getCurrentTime().ToString();
     dateText.text         = clock.getCurrentDate().ToString();
     SeasonText.text       = clock.GetSeason().name;
     sunsetAndSunrise.text = "Sunrise: " + clock.getSunriseTime().ToString() + "\tSunset: " + clock.getSunsetTime().ToString();
     weatherStateText.text = weatherController.ToString();
 }
        void Start()
        {
            if (debug)
            {
                Debug.Log(this.name);
            }
            currentTime = clock.getCurrentTime();
            Date currentDate = clock.getCurrentDate();

            GetInitialSeason(currentDate);


            Time midnight = clock.GetMidnightTime();


            if (currentSeason.GetStartDate().CompareTo(fade_start.GetStartDate()) >= 0 && currentSeason.GetEndDate().CompareTo(fade_end.GetEndDate()) < 0)
            {
                if (currentDate.Equals(fade_start.GetStartDate()))
                {
                    if (midnight.SecondsBetween(currentTime) < minutesToFade * 60)
                    {
                        phase = FADING_IN;
                        float opacity = midnight.SecondsBetween(currentTime) * opacityChangePerSecond;
                        if (debug)
                        {
                            Debug.Log("initial phase determined to be: " + phase + " FADING_IN \n" +
                                      "Seconds since midnight: " + midnight.SecondsBetween(currentTime) +
                                      "opacity per second: " + opacityChangePerSecond +
                                      "Opacity set to: " + opacity);
                        }
                        setOpacity(opacity);
                    }
                    else
                    {
                        phase = SHINING;
                        if (debug)
                        {
                            Debug.Log("initial phase determined to be: " + phase + " SHINING \n" +
                                      "Opacity set to: " + 1);
                        }
                        setOpacity(1);
                    }
                }
                else
                {
                    phase = SHINING;
                    if (debug)
                    {
                        Debug.Log("initial phase determined to be: " + phase + " SHINING \n" +
                                  "Opacity set to: " + 1);
                    }
                    setOpacity(1);
                }
            }
            else if (currentDate.Equals(fade_end.GetStartDate()))
            {
                if (midnight.SecondsBetween(currentTime) < minutesToFade * 60)
                {
                    phase = FADING_OUT;
                    float opacity = 1 - midnight.SecondsBetween(currentTime) * opacityChangePerSecond;
                    if (debug)
                    {
                        Debug.Log("initial phase determined to be: " + phase + " FADING_OUT \n" +
                                  "Opacity set to: " + opacity);
                    }
                    setOpacity(opacity);
                }
                else
                {
                    phase = FADED;
                    if (debug)
                    {
                        Debug.Log("initial phase determined to be: " + phase + " FADED \n" +
                                  "Opacity set to: " + 0);
                    }
                    setOpacity(0);
                }
            }
            else
            {
                phase = FADED;
                if (debug)
                {
                    Debug.Log("initial phase determined to be: " + phase + " FADED \n" +
                              "Opacity set to: " + 0);
                }
                setOpacity(0);
            }

            previousTime   = currentTime.Clone();
            previousSeason = currentSeason;
        }
        // Use this for initialization
        void Start()
        {
            currentTime = clock.getCurrentTime();
            //recordar que tanto el sol como la luna se tienen que dejar en el editor en la posicion de medianoche

            Time startDaySunrise = clock.getSunriseTime();
            Time startDaySunset  = clock.getSunsetTime();

            Time start = previousTime;
            Time end   = clock.getCurrentTime();

            if (debug)
            {
                Debug.Log("INITIALIZING SUN/MOON POSITION-----------------------");
                Debug.Log("dayTime: " + daytime + "\n" +
                          "start: " + start.ToString() + "\t end: " + end.ToString());
            }

            //the first speed will always be the night speed becouse we are forcing the user to set the environment as midnight
            //TODO: change sun moon rotation so that the initial position is at midday not midnight

            //night speed:
            Date yesterday       = clock.getCurrentDate().DateWithDays(-1);
            Time yesterdaySunset = clock.getSunsetTime(yesterday);

            if (debug)
            {
                Debug.Log("  CALCULATING INITIAL SPEED -------------------------");
                Debug.Log("SUN/MOON ROTATION" + this.name + ": yesterday: " + yesterday);
                Debug.Log("SUN/MOON ROTATION" + this.name + ": Yesterda's sunset: " + yesterdaySunset.ToString() + "\n" +
                          "today sunrise: " + startDaySunrise);
                Debug.Log("SUN/MOON ROTATION" + this.name + ": Time between them: " + yesterdaySunset.SecondsBetween(startDaySunrise));
            }
            int PhaseTotalTime = yesterdaySunset.SecondsBetween(startDaySunrise);

            rotationSpeed = 180.0f / PhaseTotalTime; //speed in degrees per second
            int   timePased;
            float rotationAngle;

            if (end.CompareTo(startDaySunrise) >= 0)
            {
                if (debug)
                {
                    Debug.Log("SUN/MOON ROTATION" + this.name + ": end time is past sunrise, therefore the total movement will be seccioned. \n" +
                              "the firs secction is from start: " + start.ToString() + "  to sunrise: " + startDaySunrise.ToString());
                    Debug.Break();
                }
                Time provisionalEnd = startDaySunrise.Clone();
                timePased     = start.SecondsBetween(provisionalEnd);
                rotationAngle = rotationSpeed * timePased;
                if (debug)
                {
                    Debug.Log("SUN/MOON ROTATION" + this.name + ": soconds passed from start to end: " + timePased + "\n"
                              + " the speed used is: " + rotationSpeed + "degrees per second");
                    Debug.Log("SUN/MOON ROTATION" + this.name + ": new rotation angle generated: " + rotationAngle);
                    Debug.Break();
                }
                transform.RotateAround(Vector3.zero, Vector3.right, rotationAngle);
                start = startDaySunrise.Clone();

                daytime = true;
                //dayTime speed calculations

                PhaseTotalTime = startDaySunrise.SecondsBetween(startDaySunset);
                rotationSpeed  = 180.0f / PhaseTotalTime;

                if (end.CompareTo(startDaySunset) >= 0)
                {
                    if (debug)
                    {
                        Debug.Log("SUN/MOON ROTATION" + this.name + ": end time is past sunset, therefore the remaining movement will be secctioned. \n" +
                                  "The firs section is from start: " + start.ToString() + "  to sunset: " + startDaySunset.ToString());
                        Debug.Break();
                    }
                    provisionalEnd = startDaySunset.Clone();
                    timePased      = start.SecondsBetween(provisionalEnd);
                    rotationAngle  = rotationSpeed * timePased;
                    if (debug)
                    {
                        Debug.Log("SUN/MOON ROTATION" + this.name + ": soconds passed since sunrise: " + timePased + "\n" +
                                  "new rotation angle generated: " + rotationAngle);
                        Debug.Break();
                    }
                    transform.RotateAround(Vector3.zero, Vector3.right, rotationAngle);
                    start = startDaySunset.Clone();

                    daytime = false;

                    PhaseTotalTime = startDaySunset.SecondsBetween(clock.getNextSunriseTime());
                    rotationSpeed  = 180.0f / PhaseTotalTime;
                    timePased      = start.SecondsBetween(end);
                    rotationAngle  = rotationSpeed * timePased;

                    if (debug)
                    {
                        Debug.Log("SUN/MOON ROTATION" + this.name + ": soconds passed since sunset: " + timePased + "\n" +
                                  "new rotation angle generated: " + rotationAngle);
                        Debug.Break();
                    }
                    transform.RotateAround(Vector3.zero, Vector3.right, rotationAngle);
                }
                else
                {
                    timePased     = start.SecondsBetween(end);
                    rotationAngle = rotationSpeed * timePased;
                    if (debug)
                    {
                        Debug.Log("SUN/MOON ROTATION" + this.name + ": soconds passed since sunrise: " + timePased + "\n" +
                                  "new rotation angle generated: " + rotationAngle);
                        Debug.Break();
                    }
                    transform.RotateAround(Vector3.zero, Vector3.right, rotationAngle);

                    daytime = true;
                }
            }
            else
            {
                timePased     = start.SecondsBetween(end);
                rotationAngle = rotationSpeed * timePased;
                if (debug)
                {
                    Debug.Log("SUN/MOON ROTATION" + this.name + ": soconds passed since midnight: " + timePased + "\n" +
                              "new rotation angle generated: " + rotationAngle);
                    Debug.Break();
                }
                transform.RotateAround(Vector3.zero, Vector3.right, rotationAngle);

                daytime = false;
            }

            previousTime = currentTime.Clone();
        }
Example #7
0
        void Start()
        {
            currentTime = clock.getCurrentTime();
            Time sunrise     = clock.getSunriseTime();
            Time sunset      = clock.getSunsetTime();
            Time fadeOutEnd  = sunrise.TimeWithSeconds(sunrise, (int)(minutesToFade * 60));
            Time fadeInStart = sunset.TimeWithSeconds(sunset, -(int)(minutesToFade * 60));

            if (debug)
            {
                Debug.Log("STARFADE: CALCULATING INITIAL STATE ---------------------");
                Debug.Log("STARFADE: currentTime: " + currentTime.ToString() + "\n" +
                          "\t Sunrise: " + sunrise + "\t sunset: " + sunset);
                Debug.Log("STARFADE: Transition length (in minutes): " + minutesToFade + "\n" +
                          "\t Fade out start: " + fadeInStart + "\t Fade in end: " + fadeOutEnd);
                Debug.Break();
            }

            if (currentTime.CompareTo(sunrise) < 0)
            {
                phase = SHINING;
                if (debug)
                {
                    Debug.Log("STARFADE: Current time fount out to be bewteen midnight and sunrise\n" +
                              "Phase set to " + phase + " SHINING, \t opacity set to 1");
                    Debug.Break();
                }
                setOpacity(1);
            }
            else if (currentTime.CompareTo(sunrise) >= 0 && currentTime.CompareTo(fadeOutEnd) < 0)
            {
                phase = FADING_OUT;
                float decrease = -currentTime.SecondsBetween(sunrise.TimeWithSeconds(sunrise, -(int)(minutesToFade * 60))) * opacityChangePerSecond;
                if (debug)
                {
                    Debug.Log("STARFADE: Current time fount out to be bewteen sunrise and fadeOutEnd\n" +
                              "Phase set to " + phase + " FADING_OUT, \t opacity set to :" + (1 - decrease));
                    Debug.Break();
                }
                setOpacity(1 - decrease);
            }
            else if (currentTime.CompareTo(fadeOutEnd) >= 0 && currentTime.CompareTo(fadeInStart) < 0)
            {
                phase = FADED;
                if (debug)
                {
                    Debug.Log("STARFADE: Current time fount out to be bewteen fadeOutEnd and fadeInStart \n" +
                              "Phase set to " + phase + " FADED, \t opacity set to :" + (0));
                    Debug.Break();
                }
                setOpacity(0);
            }
            else if (currentTime.CompareTo(fadeInStart) >= 0 && currentTime.CompareTo(sunset) < 0)
            {
                phase = FADING_IN;
                float increase = currentTime.SecondsBetween(sunset) * opacityChangePerSecond;
                if (debug)
                {
                    Debug.Log("STARFADE: Current time fount out to be bewteen fadeInStart and sunset \n" +
                              "Phase set to " + phase + " FADING_IN, \t opacity set to :" + (0 + increase));
                    Debug.Break();
                }
                setOpacity(0 + increase);
            }
            else
            {
                phase = SHINING;
                if (debug)
                {
                    Debug.Log("STARFADE: Current time fount out to be past sunset and before midnight \n" +
                              "Phase set to " + phase + " SHINING, \t opacity set to 1");
                    Debug.Break();
                }
                setOpacity(1);
            }

            previousTime = currentTime.Clone();
        }
        // Use this for initialization
        void Start()
        {
            currentTime = clock.getCurrentTime();
            Time sunrise          = clock.getSunriseTime();
            Time sunset           = clock.getSunsetTime();
            Time dayToDuskEnd     = sunset.TimeWithSeconds(sunrise, (int)(endMinutesAfterDawnDusk * 60));
            Time dayToDuskStart   = sunset.TimeWithSeconds(sunset, -(int)(startMinutesBeforeDawnDusk * 60));
            Time nightToDawnEnd   = sunrise.TimeWithSeconds(sunrise, (int)(startMinutesBeforeDawnDusk * 60));
            Time nightToDawnStart = sunrise.TimeWithSeconds(sunset, -(int)(endMinutesAfterDawnDusk * 60));

            if (debug)
            {
                Debug.Log("CLOUDCOLOR: CALCULATING INITIAL STATE ---------------------");
                Debug.Log("CLOUDCOLOR: currentTime: " + currentTime.ToString() + "\n" +
                          "\t Sunrise: " + sunrise + "\t sunset: " + sunset);
                Debug.Log("CLOUDCOLOR: dayToDuskStart: " + dayToDuskStart.ToString() + "\t dayToDuskEnd: " + dayToDuskEnd + "\n" +
                          "\t nightToDawnStart: " + nightToDawnStart + "\t nightToDawnEnd: " + nightToDawnEnd);
                Debug.Break();
            }

            if (currentTime.CompareTo(nightToDawnStart) < 0)
            {
                phase = NIGHT;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen midnight and the start of sunrise color change\n" +
                              "Phase set to " + phase + " NIGHT, color set to night");
                    Debug.Break();
                }
                ChangeColor(0);
            }
            else if (currentTime.CompareTo(nightToDawnStart) >= 0 && currentTime.CompareTo(sunrise) < 0)
            {
                phase = NIGHT_TO_DAWN;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen start and end of night to dawn \n" +
                              "Phase set to " + phase + " NIGHT_TO_DAWN");
                    Debug.Break();
                }
                ChangeColor(nightToDawnStart.SecondsBetween(sunrise));
            }
            else if (currentTime.CompareTo(sunrise) >= 0 && currentTime.CompareTo(nightToDawnEnd) < 0)
            {
                phase = DAWN_TO_DAY;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen start and end of night to dawn \n" +
                              "Phase set to " + phase + " NIGHT_TO_DAWN");
                    Debug.Break();
                }
                ChangeColor(sunrise.SecondsBetween(nightToDawnEnd));
            }
            else if (currentTime.CompareTo(nightToDawnEnd) >= 0 && currentTime.CompareTo(dayToDuskStart) < 0)
            {
                phase = DAY;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen fadeOutEnd and fadeInStart \n" +
                              "Phase set to " + phase + " DAY");
                    Debug.Break();
                }
                ChangeColor(0);
            }
            else if (currentTime.CompareTo(dayToDuskStart) >= 0 && currentTime.CompareTo(sunset) < 0)
            {
                phase = DAY_TO_DUSK;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen fadeInStart and sunset \n" +
                              "Phase set to " + phase + " DAY_TO_DUSK");
                    Debug.Break();
                }
                ChangeColor(dayToDuskStart.SecondsBetween(sunset));
            }
            else if (currentTime.CompareTo(sunset) >= 0 && currentTime.CompareTo(dayToDuskEnd) < 0)
            {
                phase = DUSK_TO_NIGHT;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be bewteen fadeInStart and sunset \n" +
                              "Phase set to " + phase + " DAY_TO_DUSK");
                    Debug.Break();
                }
                ChangeColor(sunset.SecondsBetween(dayToDuskEnd));
            }
            else
            {
                phase = NIGHT;
                if (debug)
                {
                    Debug.Log("CLOUDCOLOR: Current time fount out to be past sunset and before midnight \n" +
                              "Phase set to " + phase + " SHINING, \t opacity set to 1");
                    Debug.Break();
                }
                ChangeColor(0);
            }

            previousTime = currentTime.Clone();
        }