예제 #1
0
    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]);
    }
예제 #2
0
 public void Init()
 {
     for (int i = 0; i < TimerList.Length; i++)
     {
         TimerList[i] = new SingleTimer();
     }
 }
예제 #3
0
    /// <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);
    }
예제 #4
0
        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;
                }
            }
        }
예제 #5
0
        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
            };
        }
예제 #6
0
 /// <summary>
 /// 新的或旧的计时器的启用
 /// </summary>
 public void StartTimer(SingleTimer timer)
 {
     timer.StartTime = Time.time;
     timer.IsActive  = true;
     if (!m_Timers.Contains(timer))
     {
         m_Timers.Add(timer);
     }
 }
예제 #7
0
    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;
    }
예제 #8
0
        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));
        }
예제 #9
0
 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;
 }
예제 #10
0
        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");
        }
예제 #11
0
        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));
        }
예제 #12
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();
        }
예제 #13
0
    //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);
        //}
    }
예제 #14
0
        // 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");
        }
예제 #15
0
 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);
 }
예제 #16
0
        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));
        }
예제 #17
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;
        }
예제 #18
0
        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);
        }
예제 #19
0
        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];
        }
예제 #20
0
 public PanView3D()
 {
     timer = new SingleTimer();
 }
예제 #21
0
 public PanView(Camera3D camera) : base(camera)
 {
     timer = new SingleTimer();
 }
예제 #22
0
 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;
 }
예제 #23
0
 // Use this for initialization
 void Start()
 {
     timerObject       = GameObject.Find("SingleTimer");
     singleTimerScript = timerObject.GetComponent <SingleTimer>();
 }
예제 #24
0
 private void NewTimerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SingleTimer _t = StartNewTimer;
 }
예제 #25
0
 private void MessagesReadingTimer()
 {
     if (_friendId != 0)
         _timer = new SingleTimer<int>(MarkAsReaded, _friendId, 2000);
 }
예제 #26
0
 public void Stop(SingleTimer timer)
 {
     timer.IsActive = false;
 }