/// <summary> /// Returns true if this GlobalTime matches the passed GlobalTime /// </summary> /// <param name="toMatch">The GlobalTime to check</param> /// <returns>Returns true if this GlobalTime matches the passed GlobalTime, false otherwise</returns> public bool IsMatch(GlobalTime toMatch) { bool matches = true; if (toMatch.minutesInAnHour != minutesInAnHour) { matches = false; } if (toMatch.hoursInADay != hoursInADay) { matches = false; } if (toMatch.daysInAMonth != daysInAMonth) { matches = false; } if (toMatch.monthsInAYear != monthsInAYear) { matches = false; } if (toMatch.WorldClockMinutesPerTick != WorldClockMinutesPerTick) { matches = false; } return(matches); }
public Timer(int time, bool singleUse, Observer observer) { GlobalTime.RegisterTimeObserver(this); observable.RegisterObserver(observer); this.time = time; this.startTime = time; this.singleUse = singleUse; }
private void Awake() { Instance = this; TimeScale = 1; GlobalTime = StartTime; StartCoroutine(IncreaseTime()); }
public void SetUp() { testGlobal = new GlobalTime(); testGlobal.minutesInAnHour = 60; testGlobal.hoursInADay = 6; testGlobal.daysInAMonth = 10; testGlobal.monthsInAYear = 3; testData = new TimeData(5, 1, 1, 1, 1, testGlobal); tickValue = 5; }
void Awake() { if (!reference) { reference = this; } else if (reference != this) { Debug.LogError("There were two GlobalTime components in the scene. This is not allowed so one was destroyed"); Destroy(gameObject); } }
protected override void Initialize() { InputManager.Initialize(); GlobalTime.Initialize(); string scale = ConfigManager.GetValue("canvas_scale"); if (scale == null || Convert.ToInt32(scale) < 2 || !int.TryParse(scale, out _)) { ConfigManager.SetValue("canvas_scale", "2"); ConfigManager.SaveJson(); scale = "2"; } UpdateCanvasScale(Convert.ToInt32(scale)); if (ConfigManager.GetValue("enable_sky") == null) { ConfigManager.SetValue("enable_sky", true.ToString()); ConfigManager.SaveJson(); } else if (!bool.TryParse(ConfigManager.GetValue("enable_sky"), out _)) { ConfigManager.SetValue("enable_sky", true.ToString()); ConfigManager.SaveJson(); } if (ConfigManager.GetValue("audio_volume") == null) { ConfigManager.SetValue("audio_volume", "10"); ConfigManager.SaveJson(); } else if (!double.TryParse(ConfigManager.GetValue("audio_volume"), out _)) { ConfigManager.SetValue("audio_volume", "10"); ConfigManager.SaveJson(); } if (SaveManager.GetValue("highscore") == null) { SaveManager.SetValue("highscore", "0"); SaveManager.SaveJson(); } else if (!int.TryParse(SaveManager.GetValue("highscore"), out _)) { SaveManager.SetValue("highscore", "0"); SaveManager.SaveJson(); } int.TryParse(ConfigManager.GetValue("audio_volume"), out int volume); AudioPlayer.Volume = volume; base.Initialize(); }
public void CalculateFpsWithStopwatch() { time = new StopwatchTime(); const int TargetFps = 30; do { Thread.Sleep(1000 / TargetFps); time.Update(); } while (time.Milliseconds < 1000); Assert.IsTrue(Math.Abs(time.Fps - TargetFps) <= 5, "Fps=" + time.Fps); }
public void Refresh() { addonDataProvider.Update(); Sequence++; if (GlobalTime.Updated(squareReader) && (GlobalTime.Value <= 3 || !Initialized)) { Reset(); } PlayerReader.Updated(); UIMapId.Update(squareReader); }
public Timer(int time, bool singleUse, List <Observer> observers) { if (observers.Count < 1) { throw new System.Exception(); } GlobalTime.RegisterTimeObserver(this); foreach (Observer obs in observers) { observable.RegisterObserver(obs); } this.time = time; this.startTime = time; this.singleUse = singleUse; }
protected override void Update(GameTime gameTime) { if (stop) { Exit(); } InputManager.Update(CanvasScale); GlobalTime.Update(gameTime); GlobalTime.ChangeSpeed(GameSpeed); SceneManager.UpdateScenes(); ParticleManager.UpdateParticles(); if (Convert.ToBoolean(ConfigManager.GetValue("enable_sky"))) { sky.Update(); } base.Update(gameTime); }
public void UpdateObserver() { time--; if (time <= 0) { observable.NotifyObservers(); if (singleUse) { observable.UnregisterAllObservers(); GlobalTime.UnregisterTimeObserver(this); } else { time = startTime; } } }
void Start() { GlobalTime = GlobalTime.Instance; Transform BtnPanel = this.transform.Find("PersonCardsPanel/ButtonPanel"); Debug.Log(BtnPanel); for (int i = 0; i < 5; i++) { string BtnName = "Player" + i.ToString() + "Btn"; Transform BtnTrans = BtnPanel.Find(BtnName); Button Btn = BtnTrans.GetComponent <Button>(); Player ToAdd = BtnTrans.gameObject.AddComponent <Player>(); Players.Add(ToAdd); Btn.onClick.AddListener(delegate { CurrentPlayer = ToAdd; PersonCardUpdate(); }); } CurrentPlayer = Players[0]; Debug.Log(CurrentPlayer); PersonCardUpdate(); Transform InvTrans = transform.Find("InventoryPanel").GetChild(0); Inventory = InvTrans.GetComponent <Inventory>(); }
private void OnGUI() { GUI.skin = _guiSkin; _offsetX = 10; if (GUI.Button(new Rect(_offsetX, Y1, _playIcon.width, Y2), _playIcon)) { GlobalTime.Running = true; } _offsetX += _playIcon.width; if (GUI.Button(new Rect(_offsetX, Y1, _stopIcon.width, Y2), _stopIcon)) { GlobalTime.Running = false; } _offsetX += _stopIcon.width + 10f; if (GUI.Button(new Rect(_offsetX, Y1, _plusIcon.width, Y2), _plusIcon)) { GlobalTime.IncreaseTimeScale(); } _offsetX += _plusIcon.width; if (GUI.Button(new Rect(_offsetX, Y1, _minusIcon.width, Y2), _minusIcon)) { GlobalTime.DecreaseTimeScale(); } _offsetX += _minusIcon.width; GUI.Label( new Rect(_offsetX, Y1, Screen.width, Screen.height), GlobalTime.Running ? $"x{GlobalTime.CurrentTimeScale}" : "paused" ); }
public static void Init() { GlobalTime.SetDefaultTimeScale(); }
public GlobalTimeProxy(ICassandraCluster cassandraCluster, IRtqSettings rtqSettings) { var maxTicksCfConnection = cassandraCluster.RetrieveColumnFamilyConnection(rtqSettings.QueueKeyspace, ColumnFamilyName); globalTime = new GlobalTime(maxTicksCfConnection); }
void IRtqInternals.ResetTicksHolderInMemoryState() { GlobalTime.ResetInMemoryState(); minTicksHolder.ResetInMemoryState(); }
public void RunTimeWithStopwatch() { time = new StopwatchTime(); time.Update(); Assert.IsTrue(time.Milliseconds < 2, "Milliseconds=" + time.Milliseconds); }
public void OneTimeSetUp() { globalTime = new GlobalTime(SetUpFixture.GetMaxTicksConnection()); }
void Start() { GlobalTime.RegisterTimeObserver(this); }
public override void Update() { float time = (float)GlobalTime.ElapsedGameMilliseconds / 1000; if (GameInput.IsButtonDown(NESInput.Up)) { pos.Y -= VELOCITY * time; if (pos.Y < 0) { pos.Y = 0; } } if (GameInput.IsButtonDown(NESInput.Down)) { pos.Y += VELOCITY * time; if (pos.Y + sprite.rectangle.Height > 240) { pos.Y = 240 - sprite.rectangle.Height; } } if (GameInput.IsButtonDown(NESInput.Left)) { pos.X -= VELOCITY * time; if (pos.X < 0) { pos.X = 0; } } if (GameInput.IsButtonDown(NESInput.Right)) { pos.X += VELOCITY * time; if (pos.X + sprite.rectangle.Width > 256) { pos.X = 256 - sprite.rectangle.Width; } } if (GameInput.IsButtonDown(NESInput.A)) { if (shootDelay >= BULLET_SHOOT_DELAY) { ShootBullet(); } } if (particleDelay >= PARTICLE_SPAWN_DELAY) { ParticleManager.CreateParticles(ContentIndex.Pixel, new Vector2(pos.X + random.Next(6, 10), pos.Y + 14), PARTICLE_AMOUNT, new Vector2(0, 1), spread: 0, minSpeed: 10, maxSpeed: 20, Color.CornflowerBlue, colorHueShift: 1, 1); particleDelay -= PARTICLE_SPAWN_DELAY; } if (speed > 0) { GlobalTime.ChangeSpeed(Easing.ApplyEasingFromOne(1 - speed, EasingMode.CubicIn)); speed -= (time * 5); } else { speed = 0; } if (shootDelay < BULLET_SHOOT_DELAY) { shootDelay += time; } if (particleDelay < PARTICLE_SPAWN_DELAY) { particleDelay += time; } bbox.X = (int)pos.X; bbox.Y = (int)pos.Y; base.Update(); }