コード例 #1
0
        public void JumpRelative(byte value, ref ushort pc)
        {
            sbyte signed = unchecked ((sbyte)value);

            pc = (ushort)(pc + signed);
            TickEvent?.Invoke();
        }
コード例 #2
0
 void Handle(TickEvent e)
 {
     constraint.ForEachGameObject((egoComponent, commandManager) =>
     {
         List <ICommand> commandList;
         if (!e.reverse)
         {
             if (commandManager.commandDictionary.TryGetValue(e.tick, out commandList))
             {
                 foreach (ICommand command in commandList)
                 {
                     command.ExecuteIfValid();
                     //Debug.Log("executed command"+ command.ToString());;
                 }
             }
         }
         else
         {
             if (commandManager.commandDictionary.TryGetValue(e.tick + 1, out commandList))
             {
                 foreach (ICommand command in commandList)
                 {
                     command.UndoIfValid();
                     //Debug.Log("undid comamand");
                 }
             }
             commandList.Clear();
         }
     });
 }
コード例 #3
0
        static void Simulate(IDictionary <int, ITickObjectClient> dict, float normalizedTime, TickObjectEnumerator etor)
        {
            TickEvent ev         = InstancePool.Get <TickEvent>();
            uint      serverTick = SyncManagerClient.Instance.serverTick;

            while (etor.MoveNext())
            {
                TickObject        obj = etor.Current;
                ITickObjectClient tickObject;
                if (dict.TryGetValue(obj.Id, out tickObject))
                {
                    for (int i = 0; i < obj.EventsLength; ++i)
                    {
                        obj.GetEvents(ev, i);
                        if (serverTick == ev.Tick)
                        {
                            tickObject.EventUpdate(ev);
                            break;
                        }
                    }

                    if (!tickObject.predict)
                    {
                        tickObject.Lerping(normalizedTime, obj);
                    }

                    if (obj.TickObjectLength > 0 && null != tickObject.children)
                    {
                        Simulate(tickObject.children, normalizedTime, new TickObjectEnumerator(obj));
                    }
                }
            }
        }
コード例 #4
0
ファイル: TickObjectList.cs プロジェクト: blockspacer/iCarus
        static VectorOffset SampleEvents(ITickObject obj, FlatBufferBuilder fbb, bool full)
        {
            VectorOffset vecOffset = default(VectorOffset);

            if (!full && obj.eventType != TickEventType.NONE)
            {
                var eventVector = OffsetArrayPool.Alloc <TickEvent>((int)snapshotOverTick);
                for (uint i = 0; i < snapshotOverTick; ++i)
                {
                    int eventOffset = obj.SnapshotEvent(fbb, tickCount - snapshotOverTick + i);
                    if (eventOffset > 0)
                    {
                        eventVector.offsets[eventVector.position++] = TickEvent.CreateTickEvent(
                            fbb,
                            tickCount - snapshotOverTick + i,
                            obj.eventType,
                            eventOffset);
                    }
                }

                TickObject.StartEventsVector(fbb, eventVector.position);
                vecOffset = Helpers.SetVector(fbb, eventVector);
                OffsetArrayPool.Dealloc(ref eventVector);
            }
            return(vecOffset);
        }
コード例 #5
0
        private void RingHandler(bool state)
        {
            if (_snoozeHandel != null && !_snoozeHandel.IsDone)
            {
                return;
            }

            if (state)
            {
                _ui.ToggleAlarmHint(false);
                _ui.ToggleAlarmBar(true);

                _ringHandel = new TickEvent(
                    TickUtils.SecToTicks(_wakeUpSecs),
                    tick => {
                    _controller.AlarmPress -= RingHandler;
                    _ui.ToggleAlarmBar(false);
                    foreach (var animator in _hoomans)
                    {
                        animator.SetBool(Wake, true);
                    }
                },
                    tick => {
                    _ui.UpdateAlarmBar((float)tick / (_wakeUpSecs * 5));
                },
                    TickEvent.Type.MICRO);
            }
            else
            {
                _ui.ToggleAlarmHint(true);
                _ui.ToggleAlarmBar(false);
                _ringHandel?.Destroy();
            }
        }
コード例 #6
0
 // Use this for initialization
 protected override void Init()
 {
     span40 = new TickEvent(40);
     span40.SetFunction(Attack);
     span600 = new TickEvent(600);
     span600.SetFunction(ChangeAttack);
 }
コード例 #7
0
 void Handle(TickEvent e)
 {
     constraint.ForEachGameObject((egoComponent, transform, aimover, inputQueue, movement) =>
     {
         aimover.movementStrategy.Move(transform, inputQueue, movement);
     });
 }
コード例 #8
0
        private void OnTick(object?state)
        {
            var tickevent = new TickEvent();

            _logger.LogTrace("Publishing {tickevent} at {now}", nameof(TickEvent), tickevent.Time);
            _eventAggregator.Publish(tickevent);
        }
コード例 #9
0
    protected override void Init()
    {
        int moveBlank = (ParamMax + 5 - Param.Agility) * 6;

        _onMove = new TickEvent(moveBlank);
        _onMove.AddListener(TimingMovement);
    }
コード例 #10
0
    void Handle(TickEvent e)
    {
        if (!e.reverse)
        {
            constraint.ForEachGameObject((egoComponent, inputQueueC) =>
            {
                switch (e.tick % 80)
                {
                case 1:
                    //Debug.Break();
                    SetMovementDirection(Vector3.forward, inputQueueC);
                    break;

                case 20:
                    SetMovementDirection(Vector3.left, inputQueueC);
                    break;

                case 37:
                    SetMovementDirection(Vector3.back, inputQueueC);
                    break;

                case 59:
                    SetMovementDirection(Vector3.right, inputQueueC);
                    break;
                }
            });
        }
    }
コード例 #11
0
 public void RaiseTickEvent()
 {
     if (TickEvent != null)
     {
         TickEvent.Invoke(this, e);
     }
 }
コード例 #12
0
        public SimpleEngine()
        {
            _enabled = false;
            Interval = 1;
            thread   = new Thread(delegate()
            {
                while (true)
                {
                    if (_enabled)
                    {
                        TickEvent.Invoke(this, 0);
                    }
                    Thread.Sleep((int)(Interval * 1000)); // 至少等待Interval秒
                }
            });
            var time = DateTime.Now;

            TickEvent += (sender, tick) =>
            {
                var newtime = DateTime.Now;
                //Trace.WriteLine(newtime-time); // 测试函数,显示间隔
#if DEBUG
                Fps = (int)(1000 / (newtime - time).TotalMilliseconds);
                Notify("Fps");
#endif
                time = newtime;
                Trace.Flush();
            };
        }
コード例 #13
0
ファイル: LoadUnit.cs プロジェクト: jarkkopa/GeemuBoy
 public void Push(ref ushort pointer, byte valueHigh, byte valueLow)
 {
     pointer -= 2;
     TickEvent?.Invoke();
     memory.WriteWord(pointer, BitUtils.BytesToUshort(valueHigh, valueLow));
     TickEvent?.Invoke();
     TickEvent?.Invoke();
 }
コード例 #14
0
 public void ReturnConditional(ref ushort sp, ref ushort pc, Flag flag, bool condition, byte flags)
 {
     TickEvent?.Invoke();
     if (FlagUtils.GetFlag(flag, flags) == condition)
     {
         Return(ref sp, ref pc);
     }
 }
コード例 #15
0
 public void Return(ref ushort sp, ref ushort pc)
 {
     pc = memory.ReadWord(sp);
     TickEvent?.Invoke();
     TickEvent?.Invoke();
     sp = (ushort)(sp + 2);
     TickEvent?.Invoke();
 }
コード例 #16
0
ファイル: ALU.cs プロジェクト: jarkkopa/GeemuBoy
        public void DecrementWord(ref byte targetHigh, ref byte targetLow)
        {
            ushort target = BitUtils.BytesToUshort(targetHigh, targetLow);

            target     = (ushort)(target - 1);
            targetHigh = BitUtils.MostSignificantByte(target);
            targetLow  = BitUtils.LeastSignificantByte(target);
            TickEvent?.Invoke();
        }
コード例 #17
0
 public void Call(ushort address, ref ushort sp, ref ushort pc)
 {
     sp = (ushort)(sp - 2);
     memory.WriteWord(sp, pc);
     TickEvent?.Invoke();
     TickEvent?.Invoke();
     pc = address;
     TickEvent?.Invoke();
 }
コード例 #18
0
ファイル: ShootingEnemy03.cs プロジェクト: TBTBTBT/Poncho
 // Use this for initialization
 protected override void Init()
 {
     spanEv = new TickEvent(span);
     spanEv.SetFunction(Shot);
     if (GameObject.FindGameObjectWithTag("Player"))
     {
         player = GameObject.FindGameObjectWithTag("Player").GetComponent <ShootingPlayerBase>();
     }
 }
コード例 #19
0
ファイル: LoadUnit.cs プロジェクト: jarkkopa/GeemuBoy
        public void Pop(ref byte valueHigh, ref byte valueLow, ref ushort pointer)
        {
            ushort value = memory.ReadWord(pointer);

            pointer += 2;
            TickEvent?.Invoke();
            TickEvent?.Invoke();
            valueHigh = BitUtils.MostSignificantByte(value);
            valueLow  = BitUtils.LeastSignificantByte(value);
        }
コード例 #20
0
 void Handle(TickEvent e)
 {
     if (e.reverse)
     {
         constraint.ForEachGameObject((egoComponent, input, inputQueueC) =>
         {
             inputQueueC.inputQueue.Clear();
         });
     }
 }
コード例 #21
0
    public TickEvent newTickEvent(float secondsPerTick)
    {
        GameObject g = UnityEngine.Object.Instantiate(this.tickEventPrefab);

        g.transform.SetParent(this.transform);
        TickEvent te = g.GetComponent <TickEvent>();

        te.init(secondsPerTick);
        return(te);
    }
コード例 #22
0
ファイル: LoadUnit.cs プロジェクト: jarkkopa/GeemuBoy
        public void WriteToAddressAndIncrement(ref byte addrHigh, ref byte addrLow, byte value, short addValue)
        {
            ushort address = BitUtils.BytesToUshort(addrHigh, addrLow);

            memory.WriteByte(address, value);
            TickEvent?.Invoke();
            address  = (ushort)(address + addValue);
            addrHigh = BitUtils.MostSignificantByte(address);
            addrLow  = BitUtils.LeastSignificantByte(address);
        }
コード例 #23
0
        public void SetBit(byte addrHigh, byte addrLow, int index, bool bit)
        {
            ushort address = BitUtils.BytesToUshort(addrHigh, addrLow);
            byte   data    = memory.ReadByte(address);

            TickEvent?.Invoke();
            SetBit(ref data, index, bit);
            memory.WriteByte(address, data);
            TickEvent?.Invoke();
        }
コード例 #24
0
        public void RotateLeftThroughCarry(byte addrHigh, byte addrLow, ref byte flags)
        {
            ushort address = BitUtils.BytesToUshort(addrHigh, addrLow);
            byte   data    = memory.ReadByte(address);

            TickEvent?.Invoke();
            RotateLeftThroughCarry(ref data, ref flags, false);
            memory.WriteByte(address, data);
            TickEvent?.Invoke();
        }
コード例 #25
0
ファイル: LoadUnit.cs プロジェクト: jarkkopa/GeemuBoy
        public void LoadFromAddressAndIncrement(ref byte dest, ref byte addrHigh, ref byte addrLow, short value)
        {
            ushort address = BitUtils.BytesToUshort(addrHigh, addrLow);

            dest = memory.ReadByte(address);
            TickEvent?.Invoke();
            address  = (ushort)(address + value);
            addrHigh = BitUtils.MostSignificantByte(address);
            addrLow  = BitUtils.LeastSignificantByte(address);
        }
コード例 #26
0
        public void Swap(byte addrHigh, byte addrLow, ref byte flags)
        {
            ushort address = BitUtils.BytesToUshort(addrHigh, addrLow);
            byte   data    = memory.ReadByte(address);

            TickEvent?.Invoke();
            Swap(ref data, ref flags);
            memory.WriteByte(address, data);
            TickEvent?.Invoke();
        }
コード例 #27
0
        private void OnTimerEvent(object sender, ElapsedEventArgs args)
        {
            _timeRemainingInSeconds -= 1;
            TickEvent?.Invoke(this, EventArgs.Empty);

            if (_timeRemainingInSeconds <= 0)
            {
                Expire();
            }
        }
コード例 #28
0
ファイル: TimerEngine.cs プロジェクト: xvblack/Tetris-se2013
 public TimerEngine()
 {
     _tick    = 0;
     Elapsed += delegate(object sender, ElapsedEventArgs e)
     {
         lock (this)
         {
             TickEvent.Invoke(this, _tick++);
         }
     };
 }
コード例 #29
0
        void ICountdownService.Reset()
        {
            if (-1 == infoPtr)
            {
                return;
            }
            base.Stop();

            CurrentInfo = countdownInfos[infoPtr];
            TickEvent?.Invoke(CurrentInfo);
        }
コード例 #30
0
        private static void TickLoop(UInt64 times)
        {
            UInt64 i = 0;

            while (i != times)
            {
                GameTick++;

                TickEvent?.Invoke(null, GameTick);
                i++;
            }
        }
コード例 #31
0
 public Timer(int ticks, int interval, TickEvent tickEvent)
 {
     this.Ticks = ticks;
     this.Interval = interval;
     this.Event = tickEvent;
 }
コード例 #32
0
 public virtual void Tick(TickEvent e) { }
コード例 #33
0
 public override void Tick(TickEvent e)
 {
     GénererBonus(random.Next(0, 3));
     SeDeplacer();
 }