Ejemplo n.º 1
0
    // Displays the digital display, using parameters for format (e.g. 00:00, 00:00:00, etc), modeValue (time, timer or stopwatch as an integer), tempValue (whether the hour is at 0 or not)
    // and stopwatchIntDecimals (the decimal values as an int for the stopwatch)
    private void DisplayDigital(ClockView clockView, string format, int modeValue, bool tempVal = false, int stopwatchIntDecimals = 0)
    {
        int usedHourModeValue;

        if (tempVal)
        {
            usedHourModeValue = modeValue + ClockModel.TwelveHoursInSeconds;
        }
        else
        {
            usedHourModeValue = modeValue;
        }

        // Check the type of format used for this display and set appropriately
        switch (format)
        {
        case ClockModel.HourMinuteDisplay:
            clockView.numberText.text = string.Format(format, ((usedHourModeValue / ClockModel.SecondsInMinute) / ClockModel.MinutesInHour),
                                                      ((modeValue / ClockModel.SecondsInMinute) % ClockModel.MinutesInHour));
            break;

        case ClockModel.HourMinuteSecondDisplay:
            clockView.numberText.text = string.Format(format, ((usedHourModeValue / ClockModel.SecondsInMinute) / ClockModel.MinutesInHour),
                                                      ((modeValue / ClockModel.SecondsInMinute) % ClockModel.MinutesInHour), (modeValue % ClockModel.SecondsInMinute));
            break;

        case ClockModel.HourMinuteSecondMillisecondDisplay:
            clockView.numberText.text = string.Format(ClockModel.HourMinuteSecondMillisecondDisplay, ((modeValue / ClockModel.SecondsInMinute) / ClockModel.MinutesInHour),
                                                      ((modeValue / ClockModel.SecondsInMinute) % ClockModel.MinutesInHour), (modeValue % ClockModel.SecondsInMinute), (stopwatchIntDecimals % ClockModel.MillisecondsInSecond));
            break;
        }
    }
Ejemplo n.º 2
0
 public Clock(ClockView clockView, Point center, Grid MainGrid)
 {
     this.ClockView = clockView;
     this.Center    = center;
     this.ClockGrid = CreateGrid(center, 150);
     MainGrid.Children.Add(ClockGrid);
 }
Ejemplo n.º 3
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            var clockView      = new ClockView();
            var clockViewModel = new ClockViewModel();

            clockView.DataContext = clockViewModel;
            clockView.Show();
        }
Ejemplo n.º 4
0
    //	Changes whether the clock is a time display, countdown timer or stopwatch (hides/reveals appropriate objects).
    public void SetMode(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.modeDropdown.captionText.text)
        {
        case ClockModel.TimeDisplayMode:
            // Turn off Timer and Stopwatch objects
            clockView.analog_TimerStopwatch.SetActive(false);
            clockView.timerStopwatchFormat.SetActive(false);
            clockView.stopwatchSettings.SetActive(false);
            clockView.timerStopwatchHourValue.SetActive(false);

            // Turn on Time Display objects
            clockView.analog_Time.SetActive(true);
            clockView.timeFormat.SetActive(true);
            clockView.setValues.SetActive(true);

            SetTimeFormat(clockModel, clockView);
            break;

        case ClockModel.TimerMode:
            // Turn off Time Display and Stopwatch objects
            clockView.analog_Time.SetActive(false);
            clockView.timeFormat.SetActive(false);
            clockView.stopwatchSettings.SetActive(false);
            clockView.periodValue.SetActive(false);
            clockView.timeHour12.SetActive(false);
            clockView.timeHour24.SetActive(false);

            // Turn on Timer Display objects
            clockView.analog_TimerStopwatch.SetActive(true);
            clockView.timerStopwatchFormat.SetActive(true);
            clockView.timerStopwatchHourValue.SetActive(true);
            clockView.setValues.SetActive(true);

            SetTimerStopwatchFormat(clockModel, clockView);
            break;

        case ClockModel.StopwatchMode:
            // Turn off Time Display and Timer objects
            clockView.analog_Time.SetActive(false);
            clockView.timeFormat.SetActive(false);
            clockView.periodValue.SetActive(false);
            clockView.timeHour12.SetActive(false);
            clockView.timeHour24.SetActive(false);
            clockView.setValues.SetActive(false);

            // Turn on Stopwatch objects
            clockView.analog_TimerStopwatch.SetActive(true);
            clockView.timerStopwatchFormat.SetActive(true);
            clockView.stopwatchSettings.SetActive(true);
            clockView.timerStopwatchHourValue.SetActive(true);

            SetTimerStopwatchFormat(clockModel, clockView);
            break;
        }
        SetNumberDisplay(clockModel, clockView);
        SetClockHands(clockModel, clockView);
    }
Ejemplo n.º 5
0
 public TimePage()
 {
     InitializeComponent();
     Device.StartTimer(TimeSpan.FromSeconds(1.0f / 60.0f), () =>
     {
         ClockView.InvalidateSurface();
         return(true);
     });
 }
Ejemplo n.º 6
0
    // Check if 0 hrs and convert display to 12 instead
    private void Adjust12HourTime(ClockView clockView, int timeInt, string format)
    {
        // Uses tempTime (additional 12hrs added to time) while the hour is 0 to display 12:00
        if (((timeInt / ClockModel.SecondsInMinute) / ClockModel.MinutesInHour) == 0)
        {
            DisplayDigital(clockView, format, timeInt, true);
        }

        // Displays the actual time while the hour is not 0
        else
        {
            DisplayDigital(clockView, format, timeInt);
        }
    }
Ejemplo n.º 7
0
    // Add the selected value to either time or timer
    public void SetValues(ClockModel clockModel, ClockView clockView, int newValueToAdd, string modeSpecificValue)
    {
        if (modeSpecificValue == ClockModel.TimeDisplayMode)
        {
            clockModel.time += newValueToAdd;
        }
        else
        {
            clockModel.timer += newValueToAdd;
        }

        SetNumberDisplay(clockModel, clockView);
        SetClockHands(clockModel, clockView);
    }
Ejemplo n.º 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            _view = new ClockView (this);
            SetContentView (_view);

            var timer = new Timer (1);
            timer.Elapsed += delegate {
                RunOnUiThread (delegate {
                    _view.Invalidate ();
                });
            };
            timer.Start ();
        }
Ejemplo n.º 9
0
    // Adds clock to spawnedClocks list and creates/adds ClockView and ClockModel to respective lists, generates a position for the clock, resets clock index and initialises Clock values
    public void OnClockEnable(GameObject clock)
    {
        app.view.clockManager.spawnedClocks.Add(clock);

        ClockView clockView = clock.GetComponent <ClockView>();

        app.view.clockManager.spawnedClockViews.Add(clockView);

        app.Notify(InteractableClockNotification.GeneratePosition, clock);

        ClockModel clockModel = clock.GetComponent <ClockModel>();

        clockModel.timerSound = app.model.clockTemplate.timerSound;

        app.model.clockManager.spawnedClockModels.Add(clockModel);

        ResetClockIndexes();

        // Set default values
        clockModel.timeRunning      = true;
        clockModel.timerRunning     = false;
        clockModel.stopwatchRunning = false;

        clockModel.time      = 0;
        clockModel.timer     = 0;
        clockModel.stopwatch = 0;

        clockModel.period = TimePeriod.AM;

        // Set up the clock
        app.SetUpClock(clockModel, clockView);

        // Finding/using width of rect transform reference: https://answers.unity.com/questions/970545/how-do-i-set-the-widthheight-of-a-ui-element.html
        clockView.numberTransform.sizeDelta = new Vector2(ClockModel.MediumWidth, clockView.numberTransform.sizeDelta.y);

        // Setup for a default format Analog and mode Time Display
        clockView.analog.SetActive(true);
        clockView.analog_Time.SetActive(true);

        clockView.analog_TimerStopwatch.SetActive(false);
        clockView.digital.SetActive(false);
        clockView.hideableSettings.SetActive(false);
        clockView.timerStopwatchFormat.SetActive(false);
        clockView.stopwatchSettings.SetActive(false);
        clockView.timerStopwatchHourValue.SetActive(false);
        clockView.periodValue.SetActive(false);
        clockView.timeHour24.SetActive(false);
    }
Ejemplo n.º 10
0
    // Reduce time passed to timer value and display it on UI
    private void RunTimer(ClockModel clockModel, ClockView clockView)
    {
        clockModel.timer -= Time.deltaTime;

        // If the time has reached 0 and the alert has not already started playing, call TimerFinish to play alert
        if (clockModel.timer <= 0)
        {
            if (!clockView.source.isPlaying)
            {
                TimerFinish(clockModel, clockView);
            }
        }

        SetClockHands(clockModel, clockView);
        SetNumberDisplay(clockModel, clockView);
    }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _view = new ClockView(this);
            SetContentView(_view);

            var timer = new Timer(1);

            timer.Elapsed += delegate {
                RunOnUiThread(delegate {
                    _view.Invalidate();
                });
            };
            timer.Start();
        }
Ejemplo n.º 12
0
        public TVDemo(params string[] args)
            : base()
        {
            Rect R = GetExtent();

            R.A.X = R.B.X - 9;
            R.B.Y = R.A.Y + 1;

            Clock = new ClockView(R);
            Insert(Clock);

            R = GetExtent();
            R.B.X--;
            R.A.X = R.B.X - 9; R.A.Y = R.B.Y - 1;

            Heap = new HeapView(R);
            Insert(Heap);

            DisableCommands(cmSave, cmSaveAs, cmCut, cmCopy, cmPaste, cmClear,
                            cmUndo, Editor.cmFind, Editor.cmReplace, Editor.cmSearchAgain, cmCloseAll);

            if (ClipWindow != null)
            {
                Editor.Clipboard         = ClipWindow.Editor;
                Editor.Clipboard.CanUndo = false;
            }

            if (args != null)
            {
                foreach (string s in args)
                {
                    string FileName = s;
                    if (FileName[FileName.Length - 1] == '\\')
                    {
                        FileName = FileName + "*.*";
                    }
                    if ((FileName.IndexOf('?') == -1) && (FileName.IndexOf('*') == -1))
                    {
                        OpenEditor(System.IO.Path.GetFullPath(FileName), true);
                    }
                    else
                    {
                        FileOpen(FileName);
                    }
                }
            }
        }
Ejemplo n.º 13
0
    // Update is called once per frame, calls RunClock(), RunTimer() and RunStopwatch() if these functionalities are set to run
    public void UpdateClock(ClockModel clockModel, ClockView clockView)
    {
        if (clockModel.timeRunning)
        {
            RunClock(clockModel, clockView);
        }

        if (clockModel.timerRunning)
        {
            RunTimer(clockModel, clockView);
        }

        if (clockModel.stopwatchRunning)
        {
            RunStopwatch(clockModel, clockView);
        }
    }
Ejemplo n.º 14
0
    // Sets the the bool controlling the current mode type's activity to true.
    public void Run(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.modeDropdown.captionText.text)
        {
        case ClockModel.TimeDisplayMode:
            clockModel.timeRunning = true;
            break;

        case ClockModel.TimerMode:
            clockModel.timerRunning = true;
            break;

        case ClockModel.StopwatchMode:
            clockModel.stopwatchRunning = true;
            break;
        }
    }
Ejemplo n.º 15
0
    // Calculates the new seconds and current hours and minutes values to seconds and sets either the time or timer value to this
    public void SetSeconds(ClockModel clockModel, ClockView clockView)
    {
        int newSeconds = 0;

        if (clockView.modeDropdown.captionText.text == ClockModel.TimeDisplayMode)
        {
            clockModel.time = RemoveCurrentSecond(clockModel.time);
        }

        else if (clockView.modeDropdown.captionText.text == ClockModel.TimerMode)
        {
            clockModel.timer = RemoveCurrentSecond(clockModel.timer);
        }

        newSeconds = clockView.secondDropdown.value;

        SetValues(clockModel, clockView, newSeconds, clockView.modeDropdown.captionText.text);
    }
Ejemplo n.º 16
0
    // Calculates the new minute and current hours and seconds values to seconds and sets either the time or timer value to this
    public void SetMinute(ClockModel clockModel, ClockView clockView)
    {
        int newMinute = 0;

        if (clockView.modeDropdown.captionText.text == ClockModel.TimeDisplayMode)
        {
            clockModel.time = RemoveCurrentMinute(clockModel.time);
        }

        else if (clockView.modeDropdown.captionText.text == ClockModel.TimerMode)
        {
            clockModel.timer = RemoveCurrentMinute(clockModel.timer);
        }

        newMinute = clockView.minuteDropdown.value * ClockModel.SecondsInMinute;

        SetValues(clockModel, clockView, newMinute, clockView.modeDropdown.captionText.text);
    }
Ejemplo n.º 17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            System.Diagnostics.Debug.WriteLine("Density: " + Resources.DisplayMetrics.Density + ", DensityDpi: " + Resources.DisplayMetrics.DensityDpi + ", HeightPixels: " + Resources.DisplayMetrics.HeightPixels + ", ScaledDensity: " + Resources.DisplayMetrics.ScaledDensity + ", WidthPixels: " + Resources.DisplayMetrics.WidthPixels + ", Xdpi: " + Resources.DisplayMetrics.Xdpi + ", Ydpi: " + Resources.DisplayMetrics.Ydpi);

            _view = new ClockView(this, 2.5f);
            SetContentView(_view);

            var timer = new Timer(1);

            timer.Elapsed += delegate {
                RunOnUiThread(delegate {
                    _view.Invalidate();
                });
            };
            timer.Start();
        }
Ejemplo n.º 18
0
        private void SetupControls()
        {
            contentContainer = new AbsoluteLayout();

            clockView = new ClockView(settingsProvider);

            backgroundImage = new Image {
                Aspect = Aspect.AspectFill
            };

            dateLabel = new DateLabel {
                FontSize = 24,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };
            dateNameLabel = new DateLabel {
                FontSize = 24,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };

            settingsButton = new SettingsButton {
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Transparent,
                ImageSource     = AppAssets.settingsIco
            };

            contentContainer.Children.Add(backgroundImage);
            contentContainer.Children.Add(clockView);
            contentContainer.Children.Add(dateNameLabel);
            contentContainer.Children.Add(dateLabel);
            contentContainer.Children.Add(settingsButton);

            if (this.IsSquare())
            {
                dateNameLabel.IsVisible = false;
                dateLabel.IsVisible     = false;
            }

            this.Content = contentContainer;
        }
Ejemplo n.º 19
0
    // Displays the time, timer or stopwatch value as speficied format (analog)
    private void SetClockHands(ClockModel clockModel, ClockView clockView)
    {
        Quaternion hourRotation   = Quaternion.identity;
        Quaternion minuteRotation = Quaternion.identity;
        Quaternion secondRotation = Quaternion.identity;

        float modeValue    = 0;
        float segmentValue = 0;

        switch (clockView.modeDropdown.captionText.text)
        {
        case ClockModel.TimeDisplayMode:
            modeValue    = clockModel.time;
            segmentValue = ClockModel.HoursOnClock;
            break;

        case ClockModel.TimerMode:
            modeValue    = clockModel.timer;
            segmentValue = ClockModel.HoursOnTimerStopwatch;
            break;

        case ClockModel.StopwatchMode:
            modeValue    = clockModel.stopwatch;
            segmentValue = ClockModel.HoursOnTimerStopwatch;
            break;
        }

        // Use of euler angles for clock hands reference: https://www.youtube.com/watch?v=pbTysQw-WNs
        // Hour hand
        clockView.analog_HourHand.transform.eulerAngles = new Vector3(0, 0, -(((modeValue / (ClockModel.ClockMultiplier * ClockModel.MinutesInHour)) / segmentValue)
                                                                              / ClockModel.FullRotationDegrees) * ClockModel.TwelveHoursInSeconds);
        // Minute hand
        clockView.analog_MinuteHand.transform.eulerAngles = new Vector3(0, 0, -((modeValue / (ClockModel.ClockMultiplier * ClockModel.SecondsInMinute))
                                                                                / ClockModel.FullRotationDegrees) * ClockModel.TwelveHoursInSeconds);
        // Second hand
        clockView.analog_SecondHand.transform.eulerAngles = new Vector3(0, 0, -((modeValue / ClockModel.ClockMultiplier) / ClockModel.FullRotationDegrees)
                                                                        * ClockModel.TwelveHoursInSeconds);
    }
Ejemplo n.º 20
0
    // Calculates the new hour and current minutes and seconds values to seconds and sets either the time or timer value to this
    public void SetHour(ClockModel clockModel, ClockView clockView)
    {
        int newHour = 0;

        if (clockView.modeDropdown.captionText.text == ClockModel.TimeDisplayMode)
        {
            clockModel.time = RemoveCurrentHour(clockModel.time);

            // If the user is using the 12hr digital format for the Time Display
            if (clockView.timeHour12.activeSelf)
            {
                // If the time period is AM, then set new hour normally using dropdown value
                if (clockModel.period == TimePeriod.AM)
                {
                    newHour = (clockView.timeHour12Dropdown.value * ClockModel.MinutesInHour * ClockModel.SecondsInMinute);
                }
                // If the time period is PM, then set new hour accounting for the additional 12 hours (being after midday) using dropdown value
                else
                {
                    newHour = ((clockView.timeHour12Dropdown.value + ClockModel.HoursOnClock) * ClockModel.MinutesInHour * ClockModel.SecondsInMinute);
                }
            }
            // Setup normally for 24hrs
            else
            {
                newHour = clockView.timeHour24Dropdown.value * ClockModel.MinutesInHour * ClockModel.SecondsInMinute;
            }
        }

        // Setup normally for timer, using dropdown value
        else if (clockView.modeDropdown.captionText.text == ClockModel.TimerMode)
        {
            clockModel.timer = RemoveCurrentHour(clockModel.timer);
            newHour          = clockView.timerStopwatchHourDropdown.value * ClockModel.MinutesInHour * ClockModel.SecondsInMinute;
        }

        SetValues(clockModel, clockView, newHour, clockView.modeDropdown.captionText.text);
    }
Ejemplo n.º 21
0
    // Allows for the user to set whether the time period is AM or PM and displays the chosen option.
    public void SetPeriod(ClockModel clockModel, ClockView clockView)
    {
        clockView.periodText.text = clockView.periodDropdown.captionText.text;

        if (clockView.periodText.text == "AM")
        {
            // Don't make changes if time is already an AM value
            if (clockModel.period == TimePeriod.PM)
            {
                clockModel.period = TimePeriod.AM;
                clockModel.time  -= ClockModel.TwelveHoursInSeconds;
            }
        }
        else
        {
            // Don't make changes if time is already a PM value
            if (clockModel.period == TimePeriod.AM)
            {
                clockModel.period = TimePeriod.PM;
                clockModel.time  += ClockModel.TwelveHoursInSeconds;
            }
        }
    }
Ejemplo n.º 22
0
    //	Changes whether the clock is analog or digital (hides/reveals appropriate objects).
    public void SetTimerStopwatchFormat(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.timerStopwatchDropdown.captionText.text)
        {
        case ClockModel.AnalogFormat:
            // Turn off digital objects
            clockView.digital.SetActive(false);
            clockView.digital_Period.SetActive(false);
            // Turn on analog objects
            clockView.analog.SetActive(true);
            clockView.secondValue.SetActive(true);
            break;

        case ClockModel.DigitalFormat:
            // Turn off analog and uneeded digital objects
            clockView.analog.SetActive(false);
            clockView.digital_Period.SetActive(false);
            // Turn on digital objects
            clockView.digital.SetActive(true);
            clockView.secondValue.SetActive(true);

            // Adjust number text and its width depending on the relevent mode's format
            if (clockView.modeDropdown.captionText.text == ClockModel.TimerMode)
            {
                clockView.numberText.text           = ClockModel.ZeroTimer;
                clockView.numberTransform.sizeDelta = new Vector2(ClockModel.MediumWidth, clockView.numberTransform.sizeDelta.y);
            }
            else if (clockView.modeDropdown.captionText.text == ClockModel.StopwatchMode)
            {
                clockView.numberText.text           = ClockModel.ZeroStopwatch;
                clockView.numberTransform.sizeDelta = new Vector2(ClockModel.LongWidth, clockView.numberTransform.sizeDelta.y);
            }
            break;
        }
        SetNumberDisplay(clockModel, clockView);
        SetClockHands(clockModel, clockView);
    }
Ejemplo n.º 23
0
    // Sets the the bool controlling the current mode type's activity to false.
    public void Stop(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.modeDropdown.captionText.text)
        {
        case ClockModel.TimeDisplayMode:
            clockModel.timeRunning = false;
            break;

        case ClockModel.TimerMode:
            // If user clicks the stop button twice in a row, it will reset the timer
            if (!clockModel.timerRunning)
            {
                clockModel.timer          = 0;
                clockView.numberText.text = ClockModel.ZeroTimer;
            }
            clockView.source.Stop();
            clockModel.timerRunning = false;
            break;

        case ClockModel.StopwatchMode:
            clockModel.stopwatchRunning = false;
            break;
        }
    }
Ejemplo n.º 24
0
 // Either hides or shows the additional settings options on button click.
 public void ToggleSettings(ClockView clockView)
 {
     clockView.hideableSettings.SetActive(!clockView.hideableSettings.activeSelf);
 }
Ejemplo n.º 25
0
    // Displays the time, timer or stopwatch value as speficied format (digital)
    private void SetNumberDisplay(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.modeDropdown.captionText.text)
        {
        case ClockModel.TimeDisplayMode:
            int timeInt   = (int)clockModel.time;
            int timeIntPM = (int)(clockModel.time - ClockModel.TwelveHoursInSeconds);

            // If time is less than or equal to 12 hours in seconds, change the time period
            if (clockModel.time >= 0 && clockModel.time < ClockModel.TwelveHoursInSeconds && clockModel.period == TimePeriod.PM)
            {
                clockModel.period         = TimePeriod.AM;
                clockView.periodText.text = ClockModel.AM;
            }

            // If time is greater than than or equal to 24 hours in seconds, change the time period
            else if (clockModel.time >= ClockModel.TwelveHoursInSeconds && clockModel.time < (ClockModel.TwelveHoursInSeconds * 2) && clockModel.period == TimePeriod.AM)
            {
                clockModel.period         = TimePeriod.PM;
                clockView.periodText.text = ClockModel.PM;
            }

            // If time pasts 24hr, refresh to 0
            if (clockModel.time >= ClockModel.TwentyFourHoursInSeconds)
            {
                clockModel.time -= ClockModel.TwentyFourHoursInSeconds;
            }

            switch (clockView.timeDropdown.captionText.text)
            {
            case ClockModel.TwentyFour_HourMinuteFormat:
                DisplayDigital(clockView, ClockModel.HourMinuteDisplay, timeInt);
                break;

            case ClockModel.Twelve_HourMinuteFormat:
                // Check time period to see if hour values need to be reduced for 12hr time
                if (clockModel.period == TimePeriod.PM)
                {
                    Adjust12HourTime(clockView, timeIntPM, ClockModel.HourMinuteDisplay);
                }
                else
                {
                    Adjust12HourTime(clockView, timeInt, ClockModel.HourMinuteDisplay);
                }
                break;

            case ClockModel.TwentyFour_HourMinuteSecondsFormat:
                DisplayDigital(clockView, ClockModel.HourMinuteSecondDisplay, timeInt);
                break;

            case ClockModel.Twelve_HourMinuteSecondsFormat:
                // Check time period to see if hour values need to be reduced for 12hr time
                if (clockModel.period == TimePeriod.PM)
                {
                    Adjust12HourTime(clockView, timeIntPM, ClockModel.HourMinuteSecondDisplay);
                }
                else
                {
                    Adjust12HourTime(clockView, timeInt, ClockModel.HourMinuteSecondDisplay);
                }
                break;
            }

            break;

        case ClockModel.TimerMode:
            int timerInt = (int)clockModel.timer;

            // Displays the timer value in 00:00:00 format if timer value is 0 or greater
            if (timerInt >= 0)
            {
                DisplayDigital(clockView, ClockModel.HourMinuteSecondDisplay, timerInt);
            }

            break;

        case ClockModel.StopwatchMode:
            int stopwatchInt = (int)clockModel.stopwatch;

            // Creating a variable where the decimal values of stopwatch can be used as an integer (needed for display code)
            float stopwatchDecimals    = (clockModel.stopwatch - stopwatchInt) * 100;
            int   stopwatchIntDecimals = (int)stopwatchDecimals;

            // Displays the stopwatch value in 00:00:00.00 format
            DisplayDigital(clockView, ClockModel.HourMinuteSecondMillisecondDisplay, stopwatchInt, false, stopwatchIntDecimals);

            break;
        }
    }
Ejemplo n.º 26
0
 // Plays the AudioClip passed into this script (used for timer reaching 0)
 private void TimerFinish(ClockModel clockModel, ClockView clockView)
 {
     clockModel.timer        = 0;
     clockModel.timerRunning = false;
     clockView.source.Play();
 }
Ejemplo n.º 27
0
 // Add time passed to time value and display it on UI
 private void RunClock(ClockModel clockModel, ClockView clockView)
 {
     clockModel.time += Time.deltaTime;
     SetClockHands(clockModel, clockView);
     SetNumberDisplay(clockModel, clockView);
 }
    // Setup and intialise Clock
    public void SetUpClock(ClockModel clockModel, ClockView clockView)
    {
        clockView.source      = clockView.GetComponent <AudioSource>();
        clockView.source.clip = clockModel.timerSound;

        // Organises and sets up all variables of the clock (saving the user from having to pass them in manually)
        Transform[] childTransforms = clockView.GetComponentsInChildren <Transform>();

        foreach (Transform t in childTransforms)
        {
            switch (t.tag)
            {
            // ANALOG
            case "Analog":
                clockView.analog = t.gameObject;
                break;

            case "Analog Time":
                clockView.analog_Time = t.gameObject;
                break;

            case "Analog Timer":
                clockView.analog_TimerStopwatch = t.gameObject;
                break;

            case "Hour":
                clockView.analog_HourHand = t.gameObject;
                break;

            case "Minute":
                clockView.analog_MinuteHand = t.gameObject;
                break;

            case "Second":
                clockView.analog_SecondHand = t.gameObject;
                break;

            // DIGITAL
            case "Digital":
                clockView.digital = t.gameObject;
                break;

            case "Digital Numbers":
                clockView.digital_Numbers = t.gameObject;
                break;

            case "Digital Period":
                clockView.digital_Period = t.gameObject;
                break;

            // SETTINGS
            case "Hideable Settings":
                clockView.hideableSettings = t.gameObject;
                break;

            case "Mode":
                clockView.mode = t.gameObject;
                break;

            case "Time Format":
                clockView.timeFormat = t.gameObject;
                break;

            case "Timer Format":
                clockView.timerStopwatchFormat = t.gameObject;
                break;

            case "Set Values":
                clockView.setValues = t.gameObject;
                break;

            case "Time Hour 12":
                clockView.timeHour12 = t.gameObject;
                break;

            case "Time Hour 24":
                clockView.timeHour24 = t.gameObject;
                break;

            case "Timer Hour Value":
                clockView.timerStopwatchHourValue = t.gameObject;
                break;

            case "Minute Value":
                clockView.minuteValue = t.gameObject;
                break;

            case "Second Value":
                clockView.secondValue = t.gameObject;
                break;

            case "Period Value":
                clockView.periodValue = t.gameObject;
                break;

            case "Stopwatch Settings":
                clockView.stopwatchSettings = t.gameObject;
                break;

            case "Start and Stop":
                clockView.startAndStop = t.gameObject;
                break;
            }
        }

        clockView.numberTransform = clockView.digital_Numbers.GetComponent <RectTransform>();

        clockView.modeDropdown           = clockView.mode.GetComponent <TMP_Dropdown>();
        clockView.timeDropdown           = clockView.timeFormat.GetComponent <TMP_Dropdown>();
        clockView.timerStopwatchDropdown = clockView.timerStopwatchFormat.GetComponent <TMP_Dropdown>();

        clockView.timeHour24Dropdown         = clockView.timeHour24.GetComponent <TMP_Dropdown>();
        clockView.timeHour12Dropdown         = clockView.timeHour12.GetComponent <TMP_Dropdown>();
        clockView.timerStopwatchHourDropdown = clockView.timerStopwatchHourValue.GetComponent <TMP_Dropdown>();
        clockView.minuteDropdown             = clockView.minuteValue.GetComponent <TMP_Dropdown>();
        clockView.secondDropdown             = clockView.secondValue.GetComponent <TMP_Dropdown>();
        clockView.periodDropdown             = clockView.periodValue.GetComponent <TMP_Dropdown>();

        clockView.numberText      = clockView.digital_Numbers.GetComponent <TextMeshProUGUI>();
        clockView.numberTransform = clockView.numberText.GetComponent <RectTransform>();
        clockView.periodText      = clockView.digital_Period.GetComponent <TextMeshProUGUI>();
    }
Ejemplo n.º 29
0
 // Set the stopwatch value to 0 and display it on UI
 public void ResetStopwatch(ClockModel clockModel, ClockView clockView)
 {
     clockModel.stopwatch = 0;
     SetNumberDisplay(clockModel, clockView);
 }
Ejemplo n.º 30
0
 // Add time passed to stopwatch value and display it on UI
 private void RunStopwatch(ClockModel clockModel, ClockView clockView)
 {
     clockModel.stopwatch += Time.deltaTime;
     SetClockHands(clockModel, clockView);
     SetNumberDisplay(clockModel, clockView);
 }
Ejemplo n.º 31
0
    //	Changes whether the clock is analog or digital in a variety of time formats (hides/reveals appropriate objects).
    public void SetTimeFormat(ClockModel clockModel, ClockView clockView)
    {
        switch (clockView.timeDropdown.captionText.text)
        {
        case ClockModel.AnalogFormat:
            // Turn off Digital objects
            clockView.digital.SetActive(false);
            clockView.timeHour24.SetActive(false);
            clockView.periodValue.SetActive(false);
            // Turn on Analog objects
            clockView.analog.SetActive(true);
            clockView.timeHour12.SetActive(true);
            clockView.secondValue.SetActive(true);
            break;

        case ClockModel.TwentyFour_HourMinuteFormat:
            // Turn off Analog objects
            clockView.analog.SetActive(false);
            // Turn off unnecessary digital objects
            clockView.digital_Period.SetActive(false);
            clockView.periodValue.SetActive(false);
            clockView.secondValue.SetActive(false);
            clockView.timeHour12.SetActive(false);
            // Turn on format appropriate objects for digital clock
            clockView.digital.SetActive(true);
            clockView.timeHour24.SetActive(true);
            clockView.numberTransform.sizeDelta = new Vector2(ClockModel.ShortWidth, clockView.numberTransform.sizeDelta.y);      // Resize digital number text width
            break;

        case ClockModel.Twelve_HourMinuteFormat:
            // Turn off Analog objects
            clockView.analog.SetActive(false);
            // Turn off unnecessary digital objects
            clockView.secondValue.SetActive(false);
            clockView.timeHour24.SetActive(false);
            // Turn on format appropriate objects for digital clock
            clockView.digital_Period.SetActive(true);
            clockView.periodValue.SetActive(true);
            clockView.digital.SetActive(true);
            clockView.timeHour12.SetActive(true);
            clockView.numberTransform.sizeDelta = new Vector2(ClockModel.ShortWidth, clockView.numberTransform.sizeDelta.y);      // Resize digital number text width
            break;

        case ClockModel.TwentyFour_HourMinuteSecondsFormat:
            // Turn off Analog objects
            clockView.analog.SetActive(false);
            // Turn off unnecessary digital objects
            clockView.digital_Period.SetActive(false);
            clockView.periodValue.SetActive(false);
            clockView.timeHour12.SetActive(false);
            // Turn on format appropriate objects for digital clock
            clockView.secondValue.SetActive(true);
            clockView.digital.SetActive(true);
            clockView.timeHour24.SetActive(true);
            clockView.numberTransform.sizeDelta = new Vector2(ClockModel.MediumWidth, clockView.numberTransform.sizeDelta.y);      // Resize digital number text width
            break;

        case ClockModel.Twelve_HourMinuteSecondsFormat:
            // Turn off Analog objects
            clockView.analog.SetActive(false);
            // Turn off unnecessary digital objects
            clockView.timeHour24.SetActive(false);
            // Turn on format appropriate objects for digital clock
            clockView.digital_Period.SetActive(true);
            clockView.periodValue.SetActive(true);
            clockView.secondValue.SetActive(true);
            clockView.digital.SetActive(true);
            clockView.timeHour12.SetActive(true);
            clockView.numberTransform.sizeDelta = new Vector2(ClockModel.MediumWidth, clockView.numberTransform.sizeDelta.y);      // Resize digital number text width
            break;
        }
        SetNumberDisplay(clockModel, clockView);
        SetClockHands(clockModel, clockView);
    }