public void DrawLine(LineRenderer line, Vector3[] screenPositions, Color?color = null, float lifeTime = 5000) { for (int k = 0; k < screenPositions.Length; k++) { screenPositions[k] = MTool.ScreenToWorld(screenPositions[k]); } //绘制 line.positionCount = screenPositions.Length; line.SetPositions(screenPositions); line.enabled = true; if (color == null) { color = Color.red; } line.startColor = (Color)color; line.endColor = (Color)color; line.startWidth = 0.14f; //设置倒计时关闭 if (!TimerForLines.ContainsKey(line)) { SingleTimer timer = new SingleTimer(lifeTime, DisableLine, false, false, line); TimerForLines.Add(line, timer); } TimerForLines[line].Interval = lifeTime; TimerManager.Instance.StartTimer(TimerForLines[line]); }
public void Init() { for (int i = 0; i < TimerList.Length; i++) { TimerList[i] = new SingleTimer(); } }
/// <summary> /// 启用一个临时的计时器,返回一个SingleTimer作为句柄 /// </summary> public SingleTimer SetNewTimer(float Interval, SingleTimer.TimerDelegate Event, bool IsLoop = false, bool DoExecuteImmediately = false, params object[] Params) { SingleTimer t = new SingleTimer(Interval, Event, IsLoop, DoExecuteImmediately, Params); StartTimer(t); return(t); }
private void QueryStartOrStopTimer(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { if (AnswerYesNo("Create new timer?", "New Timer Inquiry") == DialogResult.Yes) { SingleTimer _t = StartNewTimer; } } else { DataGridViewRow _r = (DataGridViewRow)Rows[e.RowIndex]; string name = _r.TimerCanonicalName(); if (TimersList[name].TimerIsRunning) { TimersList[name].StopTimer(); DebugPrint(string.Format("{0}: {1} is no longer running!", "timersDataGridView_RowHeaderMouseClick", name)); return; } if (!TimersList[name].TimerIsRunning) { TimersList[name].StartTimer(); DebugPrint(string.Format("{0}: {1} is now running!", "timersDataGridView_RowHeaderMouseClick", name)); return; } } }
protected Attack(AttackData data, T parent) { this.data = data; Parent = parent; timer = new SingleTimer(t => { if (ShouldAdvance(phase)) { AdvancePhase(); } else { isWaitingOnPhase = true; } }); phase = AttackPhases.Idle; phaseTicks = new Action <float>[] { WhilePreparing, WhileExecuting, WhileCooling, WhileResetting }; }
/// <summary> /// 新的或旧的计时器的启用 /// </summary> public void StartTimer(SingleTimer timer) { timer.StartTime = Time.time; timer.IsActive = true; if (!m_Timers.Contains(timer)) { m_Timers.Add(timer); } }
public TimerDescription(SingleTimer tmr) { Index = tmr.Index; Message = tmr.Message; Duration = tmr.Duration; var now = DateTimeOffset.Now; Elapsed = now - tmr.StartTime; Remaining = now - tmr.StopTime; }
public Task UpdateTimerAsync(TimerInfo info, CancellationToken cancellationToken) { int index = timers.FindIndex(r => r.Id == info.Id); if (index >= 0) { timers[index] = new SingleTimer(info); } UpdateTimerData(); return(Task.FromResult(true)); }
private void ThreadSafeUpdateTimerNamee(SingleTimer t) { if (timersDataGridView.InvokeRequired) { DebugPrint("[Rename Timer]=>Running on non GUI Thread=>calling method on GUI Thread!"); timersDataGridView.Invoke(new Action <SingleTimer>(ThreadSafeUpdateTimerNamee), t); return; } DebugPrint("[Rename Timer]=>Running on GUI Thread!"); Rows[t.RowIndex].Cells[0].Value = t.Name; }
public async Task RecordStream(SingleTimer timer) { var mediaStreamInfo = await GetChannelStream(timer.ChannelId, "none", CancellationToken.None); HttpRequestOptions options = new HttpRequestOptionsMod() { Url = mediaStreamInfo.Path + "?duration=" + timer.Duration() }; await RecordingHelper.DownloadVideo(_httpClient, options, _logger, Path.Combine(RecordingPath, timer.GetRecordingName()), timer.Cts.Token); _logger.Info("Recording was a success"); }
public Task RecordLiveStream(string id, CancellationToken cancellationToken) { var timer = new SingleTimer() { Name = DateTime.UtcNow.ToString(), StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddHours(5), PostPaddingSeconds = 0, PrePaddingSeconds = 0, }; // RecordStream(timer); return(Task.FromResult(0)); }
public Guid AddTimer(TimerCallback argMethod, object arg, int period) { IEnumerable <SingleTimer> freeTimers = from singleTimer in TimerList where singleTimer.SignOccupy == false select singleTimer; foreach (var tempTimer in freeTimers) { SingleTimer freeTimer = tempTimer; freeTimer.TimerTarget = new Timer(argMethod, arg, 0, period); freeTimer.SignOccupy = true; freeTimer.TimerGuid = Guid.NewGuid(); return(freeTimer.TimerGuid); } throw new TimerStackException(); }
//private Transform chilledObject; //private Transform child; // Start is called before the first frame update void Start() { audioSource = GetComponent <AudioSource>(); rb2 = GetComponent <Rigidbody2D>(); fall.enabled = false; ctrl.enabled = false; timerObject = GameObject.Find("SingleTimer"); timerScript = timerObject.GetComponent <SingleTimer>(); countdownObject = GameObject.Find("Countdown"); countdownScript = countdownObject.GetComponent <TimerControl>(); createObject = GameObject.Find("SingleCreateBlock"); createScript = createObject.GetComponent <SingleCreateBlock>(); timerCheck = timerScript.TimerCount; if (timerCheck >= 0) { start = true; } else { fallBlock = GameObject.Find("FallBlock"); blockMgr = fallBlock.GetComponent <BlockMgr>(); standBy = true; start = false; } blockWaiver = false; //chilledObject = transform.FindChild("RotationCenter"); //foreach (Transform child in chilledObject) //{ // Debug.Log(child.name); //} }
// For the time being, only the player is capable of traversing walls. public WallController(PlayerCharacter player, SingleTimer wallStickTimer) : base(player) { this.wallStickTimer = wallStickTimer; // TODO: Make this reloadable. var accessor = Properties.Access(); // Simpler (for the time being, anyway) to just load properties here. acceleration = accessor.GetFloat("player.wall.acceleration"); deceleration = accessor.GetFloat("player.wall.deceleration"); maxSpeed = accessor.GetFloat("player.wall.max.speed"); wallGravity = accessor.GetFloat("player.wall.gravity"); wallTerminalSpeed = accessor.GetFloat("player.wall.terminal.speed"); stickForgiveness = accessor.GetFloat("player.wall.stick.forgiveness"); }
public int Enqueue(TimeSpan duration, ITriggerMsg msg, string message) { lock (_locker) { for (int i = 0; i < timers.Length; i++) { // Null indicates a vacancy. if (timers[i] == null) { timers[i] = new SingleTimer(i, Remove, msg); timers[i].Start(duration); timers[i].Message = message; return(i); } } } return(-1); }
public Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken) { var lastTimer = new SingleTimer(info); if (lastTimer.Duration() > 5) { timers.Add(lastTimer); UpdateTimerData(); timers.Last().StartRecording += (sender, args) => { RecordStream(lastTimer); }; timers.Last().GenerateEvent(); _logger.Info("Added timer for: " + info.ProgramId); } else { _logger.Error("Timer not created the show is about to end or has already ended"); } return(Task.FromResult(0)); }
public TextProcessor() { builder = new StringBuilder(); repeatDelay = new SingleTimer(t => repeatTimer.IsPaused = false); repeatTimer = new RepeatingTimer(t => { switch (repeatType) { case TextRepeatTypes.Left: cursor--; if (cursor == 0) { return(false); } break; case TextRepeatTypes.Right: cursor++; if (cursor == builder.Length) { return(false); } break; case TextRepeatTypes.Backspace: return(Backspace()); case TextRepeatTypes.Delete: return(Delete()); } return(true); }); repeatType = TextRepeatTypes.None; }
public SplashLogo() { IsCentered = true; spriteText = new SpriteText("Debug", "[Grimgaming]", Alignments.Center); spriteText.UseLiteralMeasuring = true; // TODO: Pull properties. //fadeTime = Properties.GetFloat("splash.fade.time"); //lifetime = Properties.GetFloat("splash.lifetime"); timer = new SingleTimer(t => { state++; if (state < 3) { timer.Duration = state == 1 ? lifetime : fadeTime; } else { // TODO: Transition game states once the logo has fully faded out. } }, fadeTime, TimerFlags.None); timer.IsRepeatable = true; timer.Tick = t => { // Holding between fades. if (state == 1) { return; } spriteText.Color = Color.Lerp(Color.Transparent, Color.White, state == 0 ? t : 1 - t); }; Components.Add(timer); }
public PlayerCharacter(ControlSettings settings) : base(EntityGroups.Player) { // TODO: Find a better way to retrieve settings. this.settings = settings; controls = new PlayerControls(); playerData = new PlayerData(); state = PlayerStates.Airborne; // TODO: Make this class reloadable. var accessor = Properties.Access(); var coyoteTime = accessor.GetFloat("player.coyote.time"); var coyoteWallTime = accessor.GetFloat("player.coyote.wall.time"); var platformTime = accessor.GetFloat("player.platform.ignore.time"); var wallStickTime = accessor.GetFloat("player.wall.stick.time"); // Flags coyoteFlag = Components.Add(new TimedFlag(coyoteTime)); coyoteFlag.OnExpiration = () => { jumpsRemaining--; }; coyoteWallFlag = Components.Add(new TimedFlag(coyoteWallTime)); coyoteWallFlag.OnExpiration = () => { wallController.Reset(); }; platformFlag = new TimedFlag(platformTime); platformFlag.OnExpiration = () => { platformFlag.Tag = null; }; wallStickTimer = new SingleTimer(time => { UnstickFromWall(); }, wallStickTime); int skillCount = Utilities.EnumCount <PlayerSkills>(); int upgradeCount = Utilities.EnumCount <PlayerUpgrades>(); skillsUnlocked = new bool[skillCount]; upgradesUnlocked = new bool[upgradeCount]; }
public PanView3D() { timer = new SingleTimer(); }
public PanView(Camera3D camera) : base(camera) { timer = new SingleTimer(); }
private void BindingNavigatorAddNewItem_Click(object sender, EventArgs e) { DebugPrint("bindingNavigatorAddNewItem_Click: Adding a Row to DataGridView!"); ToolStripButton addButton = (ToolStripButton)sender; // maybe future need SingleTimer _t = StartNewTimer; }
// Use this for initialization void Start() { timerObject = GameObject.Find("SingleTimer"); singleTimerScript = timerObject.GetComponent <SingleTimer>(); }
private void NewTimerToolStripMenuItem_Click(object sender, EventArgs e) { SingleTimer _t = StartNewTimer; }
private void MessagesReadingTimer() { if (_friendId != 0) _timer = new SingleTimer<int>(MarkAsReaded, _friendId, 2000); }
public void Stop(SingleTimer timer) { timer.IsActive = false; }