示例#1
0
 private void Update()
 {
     foreach (var command in _toRemove)
     {
         _commands.Remove(command);
         _isPressed.Remove(command);
         _wasPressed.Remove(command);
     }
     _toRemove.Clear();
     foreach (var command in _commands)
     {
         if (_toRemove.Contains(command))
         {
             continue;
         }
         var blockFlag = command.GetValue <bool>("_blockNextRelease");
         if (command.IsNewlyPressed())
         {
             OnNewlyPressed?.Invoke(command);
         }
         if (command.IsNewlyHeld(MinimalPressDuration))
         {
             OnNewlyHeld?.Invoke(command);
         }
         if (command.IsPressed())
         {
             OnPressed?.Invoke(command);
             _isPressed[command] = true;
         }
         else
         {
             _wasPressed[command] = _isPressed[command];
             _isPressed[command]  = false;
         }
         if (command.IsNewlyReleased())
         {
             OnNewlyReleased?.Invoke(command);
         }
         if (command.IsHeld(MinimalPressDuration))
         {
             OnHeld?.Invoke(command);
         }
         if (command.IsTapped(MaximalTapDuration))
         {
             OnTapped?.Invoke(command);
         }
         if (blockFlag)//damn you, Mobius Digital
         {
             var toReblock = _wasPressed[command] || _isPressed[command];
             command.SetValue("_blockNextRelease", toReblock);
         }
     }
 }
示例#2
0
 private void Update()
 {
     if (_isheld)
     {
         transform.position = Input.mousePosition;
         if (Input.GetMouseButtonDown(1))
         {
             TankSelected();
             OnHeld?.Invoke(false);
         }
         //check if over place zone
         //if so change color to reflect placeable
     }
 }