private void OnTriggerExit(Collider other) { if (mask.Contains(other.gameObject)) { collidingWith.Remove(other.gameObject); } if (collidingWith.Count == 0) { BlockedEvent?.Invoke(); OnBlocked?.Invoke(); } }
private void OnTriggerEnter(Collider other) { if (mask.Contains(other.gameObject)) { collidingWith.Add(other.gameObject); } if (collidingWith.Count == 1) { OnBlocked?.Invoke(); BlockedEvent?.Invoke(); } }
public static bool IsAttacking(IPAddress address) { if (Connections.TryGetValue(address, out var value) && value >= Rate) { if (!Blocked.ContainsKey(address)) { Blocked.TryAdd(address, 0); OnBlocked?.Invoke(address); } return(true); } Connections.AddOrUpdate(address, _ => 1, (_, i) => i + 1); return(false); }
private void HandleMoving() { Vector2 dir = TileDirectionVec2.Get_V2F(currentDirection); transform.position = (Vector2)transform.position + (dir * speed * Time.deltaTime); // check if we can go further Tile nextTile = levelManager.GetTile(coordinate, currentDirection); if (!MoveableTile(nextTile)) { float distToNexTile = Vector2.Distance(transform.position, nextTile.coordinate); if (distToNexTile < 1f) { transform.position = new Vector3(coordinate.x, coordinate.y); OnBlocked?.Invoke(levelManager.GetTile(coordinate)); } } }