Exemplo n.º 1
0
    private void SwitchDayState()
    {
        if (dayState == DayState.day)
        {
            dayState = DayState.night;
            GetComponent <AudioSource> ().PlayOneShot(sounds[1]);

            if (camera != null)
            {
                camera.GetComponent <LFBgSound>().Night();
            }
        }
        else
        {
            dayState = DayState.day;
            GetComponent <AudioSource> ().PlayOneShot(sounds[0]);

            if (camera != null)
            {
                camera.GetComponent <LFBgSound>().Day();
            }
        }

        UpdateDayState();
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (active)
     {
         if (currentState == DayState.NOTHING)
         {
             if (currentCall == numberOfCalls)
             {
                 //day is finished
                 active = false;
             }
             else
             {
                 current        = this.transform.GetChild(currentCall).GetComponent <Call>();
                 current.active = true;
                 currentState   = DayState.CALLING;
             }
         }
         if (currentState == DayState.CALLING && !current.active)
         {
             currentState = DayState.NOTHING;
             currentCall++;
         }
     }
 }
Exemplo n.º 3
0
    private void InitDayCicle()
    {
        int initialDayState = Random.Range(0, 4);

        switch (initialDayState)
        {
        case (int)DayState.Day:
            dayState    = DayState.Day;
            bgDay.color = opaque;
            break;

        case (int)DayState.Sunset:
            dayState       = DayState.Sunset;
            bgSunset.color = opaque;
            break;

        case (int)DayState.Dusk:
            dayState     = DayState.Dusk;
            bgDusk.color = opaque;
            break;

        case (int)DayState.Night:
            dayState      = DayState.Night;
            bgNight.color = opaque;
            break;
        }
    }
Exemplo n.º 4
0
    // Check the time every specified number of seconds
    // then update the current day state
    private IEnumerator CheckTimeForSeconds(float seconds)
    {
        /*
         * // If it's currently raining, skip the time check
         * if (raining)
         * {
         *  yield return null;
         * }
         * else
         * {
         *  // Run a random check to see if the rain event should be triggered
         *  // 5% chance to rain every minute
         *  if (Mathf.Round(Random.Range(0f, 200)) == 69f)
         *  {
         * StartCoroutine(RainEvent());
         * yield return null;
         *  }
         * }
         */

        timeCheckFlag = false;
        yield return(new WaitForSecondsUnpaused(seconds));

        currentHour = System.DateTime.Now.Hour;

        proposedState = ParseHours(currentHour);

        timeCheckFlag   = true;
        changeStateFlag = true;
    }
Exemplo n.º 5
0
    private void Switch()
    {
        fr = dayStates[cur];
        int tmp = cur;


        to = dayStates[(tmp + 1) % dayStates.Length];
        foreach (var a in to.lights)
        {
            a.intensity = 0;
            a.enabled   = true;
        }
        cur = (cur + 1) % dayStates.Length;


        //StartCoroutine(Bs.AddMethod(.2f, delegate
        //{
        foreach (var a in fr.objs)
        {
            a.SetActive(false);
        }
        foreach (var a in to.objs)
        {
            a.SetActive(true);
        }
        //}));
        RenderSettings.fog = _ObsCamera.spec && night;
    }
Exemplo n.º 6
0
 public static void DayStateDidChange(DayState state)
 {
     if (dayState != null)
     {
         dayState(state);
     }
 }
Exemplo n.º 7
0
    void RunTimersInNormal()
    {
        // Count timer
        oneDaysTimer  -= (1 * timeAccel);
        dayNightTimer -= (1 * timeAccel);

        // Swith day/night state when day/night timer is run out and reset timer
        if (dayNightTimer <= 0)
        {
            dayNightTimer = _FramesUntilEnd12h;
            if (dayState == DayState.Day)
            {
                dayState = DayState.Night;
            }
            else
            {
                dayState = DayState.Day;
            }
        }

        // Reset day timer and days count after a day
        if (oneDaysTimer <= 0)
        {
            oneDaysTimer = _FramesUntilEndDay;
            daysCount   += (1 * timeAccel);
        }
    }
Exemplo n.º 8
0
        public async Task <PartialViewResult> SetDayOff(int Id)
        {
            var schedule = _ISchedulesRepository.Schedules.FirstOrDefault(p => p.id == Id);

            _ISchedulesRepository.EditSchedule(new Schedule
            {
                id        = schedule.id,
                date      = schedule.date,
                doctor_id = schedule.doctor_id,
                day_off   = true,
                hour_from = schedule.hour_from,
                hour_to   = schedule.hour_to
            });

            var assistantRoleId = RoleManager.Roles.FirstOrDefault(x => x.Name == "Asystentka").Id;
            var assistantId     = (from user in UserManager.Users
                                   where user.Roles.Any(r => r.RoleId == assistantRoleId)
                                   select user)
                                  .FirstOrDefault().Id;

            string title = "Stomatolog " + schedule.Doctor.first_name + " " + schedule.Doctor.last_name + " wziął dzień wolny.";
            string body  = "Proszę poinformować pacjentów o zmianie planów, którzy dnia " + schedule.date.ToShortDateString() + "mieli umówione wizyty.";

            await UserManager.SendEmailAsync(assistantId, title, body);

            TempData["Success"] = "Dzień " + schedule.date.ToShortDateString() + " jest wolny.";

            var model = new DayState
            {
                DayOff = null
            };

            return(PartialView("_ScheduleEditButtons", model));
        }
Exemplo n.º 9
0
    private void ChangeDayState(DayState state)
    {
        switch (state)
        {
        case DayState.MORNING:
            houseAmbiantLight.intensity = 15f;
            mySpriteRenderer.sprite     = morningSprite;
            changeStateFlag             = false;
            break;

        case DayState.DAY:
            houseAmbiantLight.intensity = 25f;
            mySpriteRenderer.sprite     = daySprite;
            changeStateFlag             = false;
            break;

        case DayState.NOON:
            houseAmbiantLight.intensity = 15f;
            mySpriteRenderer.sprite     = noonSprite;
            changeStateFlag             = false;
            break;

        case DayState.NIGHT:
            houseAmbiantLight.intensity = 5f;
            mySpriteRenderer.sprite     = nightSprite;
            changeStateFlag             = false;
            break;
        }
    }
    // Use this for initialization
    void Start()
    {
        startPosition = transform.position;
        currentState  = DayState.Day;

        StartCoroutine(DayNightCycle());
    }
Exemplo n.º 11
0
 public void DoClock(Context context, int hour)
 {
     if (9 <= hour && hour < 17)
     {
         context.ChangeState(DayState.GetInstance());
     }
 }
Exemplo n.º 12
0
Arquivo: Day.cs Projeto: ArildF/Weeky
 public void NextState()
 {
     State = State + 1;
     if (State > DayState.Good)
     {
         State = DayState.NotSet;
     }
 }
Exemplo n.º 13
0
 public void ChangeDayStateNight()
 {
     dayColor    = lights.color;
     delta.x     = (night.r - dayColor.r);
     delta.y     = (night.g - dayColor.g);
     delta.z     = (night.b - dayColor.b);
     counter     = 0;
     currentTime = 0;
     day         = DayState.Night;
 }
Exemplo n.º 14
0
 // Adjust the house according to the hour of day
 private void Start()
 {
     try {
         mySpriteRenderer = GetComponent <SpriteRenderer> ();
         currentHour      = System.DateTime.Now.Hour;
         currentState     = ParseHours(currentHour);
         ChangeDayState(currentState);
     } catch {
     }
 }
Exemplo n.º 15
0
    private DayState proposedState;      // Used to compare & see if we're transitioning to a new state

    // Adjust the sprites of the menu items according to the hour of day
    private void Start()
    {
        // Try to find the sprite renderers of the logo & sky sprites
        try {
            currentHour  = System.DateTime.Now.Hour;
            currentState = ParseHours(currentHour);
            ChangeDayState(currentState);
        } catch {
        }
    }
Exemplo n.º 16
0
 public void ChangeDayStateAfternoon()
 {
     dayColor    = lights.color;
     delta.x     = (afternoon.r - dayColor.r);
     delta.y     = (afternoon.g - dayColor.g);
     delta.z     = (afternoon.b - dayColor.b);
     counter     = 0;
     currentTime = 0;
     day         = DayState.Afternoon;
 }
Exemplo n.º 17
0
 public void ChangeDayStateMorning()
 {
     dayColor    = lights.color;
     delta.x     = (morning.r - dayColor.r);
     delta.y     = (morning.g - dayColor.g);
     delta.z     = (morning.b - dayColor.b);
     counter     = 0;
     currentTime = 0;
     day         = DayState.Morning;
 }
Exemplo n.º 18
0
        public PartialViewResult ActivateScheduleEditButtons(int Id)
        {
            bool isDayOff = _ISchedulesRepository.Schedules.FirstOrDefault(p => p.id == Id).day_off;

            var model = new DayState
            {
                DayOff = isDayOff
            };

            return(PartialView("_ScheduleEditButtons", model));
        }
Exemplo n.º 19
0
    private const float _FramesUntilEndDay = 86400 * 60;         // Count down second to end a day = 24h

    // Start is called before the first frame update
    void Start()
    {
        // Todo Load start time in save file
        // If new game, game start at 12h at noon
        if (dayNightTimer == 0 && daysCount == 0 && oneDaysTimer == 0)
        {
            dayState      = DayState.Day;
            dayNightTimer = _FramesUntilEnd12h;
            oneDaysTimer  = _FramesUntilEnd12h;
        }
    }
    void Start()
    {
        if (this.transform.eulerAngles.x < 90f)
        {
            _DayState = DayState.PrepareDay;
        }

        if (this.transform.eulerAngles.x > 200f && this.transform.eulerAngles.x < 350f)
        {
            _DayState = DayState.PrepareNight;
        }
    }
Exemplo n.º 21
0
    // Check the time every specified number of seconds
    // then update the current day state
    private IEnumerator CheckTimeForSeconds(float seconds)
    {
        timeCheckFlag = false;
        yield return(new WaitForSecondsUnpaused(seconds));

        currentHour = System.DateTime.Now.Hour;

        proposedState = ParseHours(currentHour);

        timeCheckFlag   = true;
        changeStateFlag = true;
    }
Exemplo n.º 22
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
            CreateGraves();
        if (cur == 1 || Input.GetKeyDown(KeyCode.L))
        {
            if (Input.GetKeyDown(KeyCode.L) || Time.time - nextLightning > 0)
            {
                if (nextLightning != 0)
                    StartCoroutine(Lighning());

                nextLightning = Time.time + Random.Range(5, 60);
            }
        }
        if (Input.GetKeyDown(KeyCode.C))
            Switch();
        if (fr != null)
        {
            bool progress = false;
            for (int i = 0; i < fr.lights.Count; i++)
            {
                fr.lights[i].intensity = Mathf.Lerp(fr.lights[i].intensity, 0, Time.deltaTime * 3);
                if (fr.lights[i].intensity < .01)
                    fr.lights[i].intensity = 0;
                else
                    progress = true;
            }
            if (!progress)
            {
                foreach (var a in fr.lights)
                    a.enabled = false;
                fr = null;
            }
        }

        if (to != null)
        {
            bool progress = false;
            for (int i = 0; i < to.lights.Count; i++)
            {
                to.lights[i].intensity = Mathf.Lerp(to.lights[i].intensity, to.lightdefs[i], Time.deltaTime * 3);
                if (to.lightdefs[i] - to.lights[i].intensity < .1f)
                    to.lights[i].intensity = to.lightdefs[i];
                else
                    progress = true;
            }
            if (!progress)
                to = null;
        }
    }
    IEnumerator DoSunrise()
    {
        float timeElapsed = 0f;

        while (timeElapsed < 1)
        {
            transform.position = Vector3.Lerp(targetPosition, startPosition, timeElapsed);
            timeElapsed       += Time.deltaTime * .05f;
            yield return(new WaitForEndOfFrame());
        }

        transform.position = startPosition;
        currentState       = DayState.Day;
    }
Exemplo n.º 24
0
    void Update()
    {
        if (Application.loadedLevel != 0)
        {
            if (dayCicleCount < 30)
            {
                dayCicleCount++;
                return;
            }
            dayCicleCount = 0;

            if (dayState == DayState.Day)
            {
                bgDay.color    -= alphaOffset;
                bgSunset.color += alphaOffset;
                if (bgSunset.color.a >= 1)
                {
                    dayState = DayState.Sunset;
                }
            }
            else if (dayState == DayState.Sunset)
            {
                bgSunset.color -= alphaOffset;
                bgDusk.color   += alphaOffset;
                if (bgDusk.color.a >= 1)
                {
                    dayState = DayState.Dusk;
                }
            }
            else if (dayState == DayState.Dusk)
            {
                bgDusk.color  -= alphaOffset;
                bgNight.color += alphaOffset;
                if (bgNight.color.a >= 1)
                {
                    dayState = DayState.Night;
                }
            }
            else if (dayState == DayState.Night)
            {
                bgNight.color -= alphaOffset;
                bgDay.color   += alphaOffset;
                if (bgDay.color.a >= 1)
                {
                    dayState = DayState.Day;
                }
            }
        }
    }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        dayState = (DayState)Random.Range(0, 2);
        typeDay  = (TypeDay)Random.Range(0, 2);
        //maxCapacity = new List<int> ();
        //locations = new List<List<GameObject>> ();
        Debug.Log(dayState);
        Debug.Log(typeDay);

        switch (dayState)
        {
        case DayState.Clear:
            multiplyFactor = 1.2f;
            break;

        case DayState.Rain:
            multiplyFactor = .5f;
            break;
        }

        switch (typeDay)
        {
        case TypeDay.Standard:
            standardSpawns = new int[2] {
                8, 10
            };
            break;

        case TypeDay.Fishing:
            standardSpawns = new int[2] {
                10, 12
            };
            break;
        }
        for (int i = 0; i < standardSpawns.Length; ++i)
        {
            standardSpawns [i] = Mathf.RoundToInt(standardSpawns [i] * multiplyFactor);
            Debug.Log(standardSpawns [i]);
        }
        setLists();

        //aiList = new List<GameObject> ();


        spawnUnits();
    }
    IEnumerator DayNightCycle()
    {
        yield return(new WaitForSeconds(30f));

        if (currentState == DayState.Day)
        {
            StartCoroutine(DoSunset());
            currentState = DayState.Sunset;
        }
        else if (currentState == DayState.Night)
        {
            StartCoroutine(DoSunrise());
            currentState = DayState.Sunrise;
        }

        StartCoroutine(DayNightCycle());
    }
Exemplo n.º 27
0
    private void ChangeDayState(DayState state)
    {
        // First, disable all the sprite renderers for each dynamic object on the screen
        SpriteRenderer[] all_dyn_sprites = GameObject.Find("dynamic_sprites").GetComponentsInChildren <SpriteRenderer> ();
        for (int i = 0; i < all_dyn_sprites.Length; i++)
        {
            all_dyn_sprites [i].enabled = false;
        }

        // Then, enable them according to state
        switch (state)
        {
        case DayState.MORNING:
            skyImage.sprite = morningSprite;
            changeStateFlag = false;
            break;

        case DayState.DAY:
            all_dyn_sprites = GameObject.FindGameObjectWithTag("DaySprites").GetComponentsInChildren <SpriteRenderer> ();
            for (int i = 0; i < all_dyn_sprites.Length; i++)
            {
                all_dyn_sprites [i].enabled = true;
            }

            skyImage.sprite = daySprite;
            changeStateFlag = false;
            break;

        case DayState.NOON:
            skyImage.sprite = noonSprite;
            changeStateFlag = false;
            break;

        case DayState.NIGHT:
            all_dyn_sprites = GameObject.FindGameObjectWithTag("NightSprites").GetComponentsInChildren <SpriteRenderer> ();
            for (int i = 0; i < all_dyn_sprites.Length; i++)
            {
                all_dyn_sprites [i].enabled = true;
            }

            skyImage.sprite = nightSprite;
            changeStateFlag = false;
            break;
        }
    }
Exemplo n.º 28
0
    private void Update()
    {
        // See if it's time to update the time again
        if (timeCheckFlag)
        {
            StartCoroutine(CheckTimeForSeconds(secsUntilTimecheck));
        }

        // If the new, upcoming state is different, then transition to the new one
        if (changeStateFlag)
        {
            if (proposedState != currentState)
            {
                currentState = proposedState;
                ChangeDayState(currentState);
            }
        }
    }
    private void SetState(DayState state, string stateString)
    {
        currentStateString = stateString;
        currentState       = state;
        stateTimer         = 0;
        fadeTimer          = 0;

        onDayStateChangeCallback?.Invoke();

        if (inDungeon)
        {
            return;
        }

        if (state == DayState.Dawn && !LevelManager.instance.playerDead)
        {
            AudioManager.current.CrossFadeMusicClips(dayMusic);
        }
        else if (state == DayState.Dusk && !LevelManager.instance.playerDead)
        {
            AudioManager.current.CrossFadeMusicClips(nightMusic);
        }
    }
Exemplo n.º 30
0
    void StartTimersInFirstDay()
    {
        oneDaysTimer -= (1 * timeAccel);

        // When over 18h in game
        if (oneDaysTimer <= _FramesUntilEnd12h / 2)
        {
            // Switch on night state at 18h
            if (dayState == DayState.Day)
            {
                dayState = DayState.Night;
            }
            // Start the day/night timer at 18h
            dayNightTimer -= (1 * timeAccel);
        }

        // When 24 night in game
        if (oneDaysTimer <= 0)
        {
            daysCount    = 1;
            oneDaysTimer = _FramesUntilEndDay;
        }
    }
Exemplo n.º 31
0
        public ActionResult CurrentSchedule()
        {
            var schedules = GetSchedules(CurrentUserInfo.id);
            var dayState  = new DayState {
                DayOff = null
            };
            var hours = new HoursAtWork
            {
                ScheduleID = 0,
                HourFrom   = 8,
                HourTo     = 16,
                HoursFrom  = GetHoursFrom(),
                HoursTo    = GetHoursTo()
            };

            var model = new CurrentScheduleViewModel
            {
                Schedules   = schedules,
                DayState    = dayState,
                HoursAtWork = hours
            };

            return(View(model));
        }
Exemplo n.º 32
0
Arquivo: Day.cs Projeto: ArildF/Weeky
 public Day(DateTime date, DayState state)
 {
     Date = date;
     State = state;
 }
Exemplo n.º 33
0
    public AbstractState checkSight()
    {
        List<survivorAI> characters = FindsurvivorAIsInSight ();
        if (characters.Count == 0){
            //Debug.Log("do Search running!" + (Time.fixedTime - startSearch) );
            //RunState run = new RunState();
            //run.Parent = this;
            //run.survivorAI = this.survivorAI;
            //return run; //We have nothing to do, our next state is out current states

            Mover2 m = survivorAI.GetComponent<Mover2> ();

            if(m.found == true || (Time.fixedTime - startSearch) > 5.0f)
            {
                DayState run = new DayState(survivorAI);
                return run;
            }

            return this;
        }

        //We have to deal with the character that is getting close to the searcher

        float random = Random.value;
        if (random >= 0f && random <= 0.6f) {
            TalkState talk = new TalkState(survivorAI);
            talk.Parent = this;
            talk.Enemy = characters.First ();
            return talk;

        } else if(random >= 0.6f && random <= 0.8f)
        {
            FightState fight = new FightState(survivorAI);
            fight.Parent = this;
            fight.Enemy = characters.First();
            return fight;
        } else
        {
            RunState run = new RunState(survivorAI);
            run.Parent = this;
            run.Enemy = characters.First();
            return run;
        }
    }
Exemplo n.º 34
0
 public DayTapped(DateTime dateTime, IEnumerable <ICalendarViewEvent> events, DayState state)
 {
     DateTime = dateTime;
     Events   = events;
     State    = state;
 }
Exemplo n.º 35
0
    private void Switch()
    {
        fr = dayStates[cur];
        int tmp = cur;

        to = dayStates[(tmp + 1)%dayStates.Length];
        foreach (var a in to.lights)
        {
            a.intensity = 0;
            a.enabled = true;
        }
        cur = (cur + 1)%dayStates.Length;

        //StartCoroutine(Bs.AddMethod(.2f, delegate
        //{
        foreach (var a in fr.objs)
            a.SetActive(false);
        foreach (var a in to.objs)
            a.SetActive(true);
        //}));
        RenderSettings.fog = _ObsCamera.spec && night;
    }