コード例 #1
0
ファイル: NPCData.cs プロジェクト: MarieNielly/Blossom-Island
        public ScheduleSlot GetNextPosition()
        {
            if (CurrentSchedule == null)
            {
                Debug.LogError("No schedule defined");
            }
            GetCurrentSlot();
            int nextSlotIndex = 0;

            for (int i = 0; i < CurrentSchedule.Schedule.Count; i++)
            {
                ScheduleSlot slot = CurrentSchedule.Schedule[i];
                if (slot.Level == CurrentSlot.Level && slot.Position == CurrentSlot.Position)
                {
                    if (i == CurrentSchedule.Schedule.Count - 1)
                    {
                        nextSlotIndex = 0;
                    }
                    else
                    {
                        nextSlotIndex = i + 1;
                    }
                }
            }
            return(CurrentSchedule.Schedule[nextSlotIndex]);
        }
コード例 #2
0
ファイル: NPCData.cs プロジェクト: MarieNielly/Blossom-Island
        public ScheduleSlot GetPreviousPosition()
        {
            if (CurrentSchedule == null)
            {
                Debug.LogError("No schedule defined");
            }
            GetCurrentSlot();
            int prevSlotIndex = 0;

            for (int i = 0; i < CurrentSchedule.Schedule.Count; i++)
            {
                ScheduleSlot slot = CurrentSchedule.Schedule[i];
                if (slot.Level == CurrentSlot.Level && slot.Position == CurrentSlot.Position)
                {
                    if (i == 0)
                    {
                        prevSlotIndex = CurrentSchedule.Schedule.Count - 1;
                    }
                    else
                    {
                        prevSlotIndex = i - 1;
                    }
                }
            }
            return(CurrentSchedule.Schedule[prevSlotIndex]);
        }
コード例 #3
0
ファイル: NPCData.cs プロジェクト: MarieNielly/Blossom-Island
        void GetCurrentSlot()
        {
            if (CurrentSchedule == null)
            {
                return;
            }
            SlotChanged = false;

            int currentHour   = TimeManager.Instance.CurrentHour;
            int currentMinute = TimeManager.Instance.CurrentMinute;
            int totalMinutes  = (currentHour * 60) + currentMinute;

            for (int i = 0; i < CurrentSchedule.Schedule.Count; i++)
            {
                ScheduleSlot slot = CurrentSchedule.Schedule[i];
                ScheduleSlot nextSlot;


                //if this is the last slot
                if (i + 1 >= CurrentSchedule.Schedule.Count)
                {
                    CurrentSlot  = slot;
                    PreviousSlot = CurrentSchedule.Schedule[i - 1];
                    nextSlot     = CurrentSchedule.Schedule[0];

                    if (PastSlot.Level != CurrentSlot.Level || PastSlot.Position != CurrentSlot.Position)
                    {
                        SlotChanged = true;
                    }

                    PastSlot = CurrentSlot;
                    return;
                }
                else
                {
                    nextSlot = CurrentSchedule.Schedule[i + 1];
                }
                int scheduleMinutes     = (slot.Hour * 60) + slot.Minute;
                int nextScheduleMinutes = (nextSlot.Hour * 60) + nextSlot.Minute;
                if (totalMinutes >= scheduleMinutes && totalMinutes < nextScheduleMinutes)
                {
                    CurrentSlot = slot;
                    if (i == 0)
                    {
                        PreviousSlot = CurrentSchedule.Schedule[CurrentSchedule.Schedule.Count - 1];
                    }
                    else
                    {
                        PreviousSlot = CurrentSchedule.Schedule[i - 1];
                    }
                    NextSlot = CurrentSchedule.Schedule[i + 1];

                    if (PastSlot.Level != CurrentSlot.Level || PastSlot.Position != CurrentSlot.Position)
                    {
                        SlotChanged = true;
                    }

                    PastSlot = CurrentSlot;
                    return;
                }
            }
        }