aa
This commit is contained in:
1 parent
661f99c595
commit
badede4b8f
222 files changed
+14221
-4877
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Time;
|
||||
import Toybox.Timer;
|
||||
import Toybox.System;
|
||||
|
||||
class Period{
|
||||
public var name as String?;
|
||||
public var type as enPeriod?;
|
||||
public var duration as Number?;
|
||||
public var remaining as Number?;
|
||||
public var elapsed as Number?;
|
||||
|
||||
public var play as Boolean = false;
|
||||
private var _dur as Number = 0;
|
||||
private var _acc as Number = 0;
|
||||
private var _start as Number = 0;
|
||||
|
||||
function initialize(Name as String, Type as enPeriod, Duration as Number){
|
||||
name = Name;
|
||||
type = Type;
|
||||
duration = Duration;
|
||||
remaining = Duration;
|
||||
elapsed = 0;
|
||||
}
|
||||
|
||||
function playPause() as Void{
|
||||
play = !play;
|
||||
if (play){
|
||||
$.gMatch.state = INGAME;
|
||||
_start = System.getTimer();
|
||||
}
|
||||
else{
|
||||
_acc += System.getTimer() - _start;
|
||||
}
|
||||
}
|
||||
|
||||
function update() as Void{
|
||||
if (play){
|
||||
_dur = System.getTimer() - _start + _acc;
|
||||
elapsed = _dur / 1000;
|
||||
remaining = duration - elapsed;
|
||||
|
||||
if (type == PLAY){
|
||||
$.gMatch.elapsed = $.gMatch.completed + elapsed;
|
||||
}
|
||||
|
||||
if (remaining <= 0) {
|
||||
play = false;
|
||||
$.gMatch.method(:nextPeriod).invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user