private void Timer_Tick(object sender, EventArgs e) { Timer.Tick -= OnTime; Timer.Enabled = false; HandledMouseEventArgs E = new HandledMouseEventArgs(eSave); EventServer.LongClick(E); LongClick?.Invoke(this, eSave); }
public static void Attach(Control Control, EventHandler Handler) { var LC = new LongClick { Control = Control, Handler = Handler }; Control.MouseDown += LC.ControlOnMouseDown; Control.MouseMove += LC.ControlOnMouseMove; Control.MouseUp += LC.ControlOnMouseUp; }
public static void Attach(Button Button, EventHandler Handler) { var LC = new LongClick { Button = Button, Handler = Handler }; Button.MouseDown += LC.ButtonOnMouseDown; Button.MouseMove += LC.ButtonOnMouseMove; Button.MouseUp += LC.ButtonOnMouseUp; }
private void Awake() { canvas = GetComponentInParent <Canvas>(); rectTransform = GetComponent <RectTransform>(); canvasGroup = GetComponent <CanvasGroup>(); po = GetComponent <PanelOpener>(); // asignare my_long_click = GetComponent <LongClick>(); zoom_plus = GetComponent <ZoomIn>(); zoom_minus = GetComponent <ZoomOut>(); SubMenu = transform.parent.transform.Find("Sub menu").gameObject; }
protected virtual void OnItemViewLongClick(object sender, EventArgs e) { LongClick?.Invoke(this, e); }
public virtual void OnLongClick() { LongClick?.Invoke(this, EventArgs.Empty); }
void Start() { manager = GameObject.Find("Manager"); lc = manager.GetComponent <LongClick>(); }
void HandleHostControls() { if (hasAuthority) { //Create a wall if in Wall mode if (Input.touchCount < 2 && Input.GetMouseButtonDown(0) && state == Mode.Walls && isServer) { cmdQuad(); } //Create a rough-terrain if in rough-terrain mode if (Input.touchCount < 2 && Input.GetMouseButtonDown(0) && state == Mode.RoughTerrain && isServer) { cmdRoughTerrain(); } //Select a monster using raycast2D if (Input.touchCount < 2 && Input.GetMouseButtonDown(0) && isServer && !walking) { var hit = Physics2D.Raycast(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f); if (hit) { if (hit.transform.gameObject.GetComponent <NetworkIdentity>().connectionToClient != connectionToClient) { return; } if (selectedMonster != null && selectedMonster != hit.transform.gameObject) { selectedMonster.GetComponent <SpriteRenderer>().color = Color.white; } selectedMonster = hit.transform.gameObject; selectedMonster.GetComponent <SpriteRenderer>().color = Color.green; state = Mode.Movement; if (movementPath != null) { movementPath.Clear(); cmdDestroyPath(); movementSpeed = maxSpeed; } } } if (LongClick.IsLongClick(0)) { var hit = Physics2D.Raycast(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f); if (hit) { if (hit.transform.gameObject.GetComponent <NetworkIdentity>().connectionToClient != connectionToClient) { return; } if (selectedMonster != null && selectedMonster != hit.transform.gameObject) { selectedMonster.GetComponent <SpriteRenderer>().color = Color.white; } foreach (var item in initiatives) { if (item.obj == hit.transform.gameObject) { CmdRemoveFromInitList(hit.transform.gameObject); break; } } } } //create a movement path for a selected monster if (Input.touchCount < 2 && Input.GetMouseButtonDown(0) && state == Mode.Movement && selectedMonster != null && !walking && movementSpeed > 0) { //Get the coordinates of the mouse and the dwarf Vector3 mouseWorldPosition = Utils.GetMouseWorldPosition(); Grid <PathNode> test = pathfinding.GetGrid(); test.GetXY(mouseWorldPosition, out int x, out int y); //pathfinding.GetGrid().GetXY(mouseWorldPosition, out int x, out int y); pathfinding.GetGrid().GetXY(selectedMonster.transform.position, out int originX, out int originY); //if movementPath list contains any Vector3's, get Pathnode object from latest position in the list. Else, get Pathnode object from origin position of dwarf. PathNode cell; if (movementPath.Count > 0) { Vector3 lastItem = movementPath[movementPath.Count - 1]; pathfinding.GetGrid().GetXY(lastItem, out int newX, out int newY); cell = pathfinding.GetGrid().GetGridObject(newX, newY); } else { cell = pathfinding.GetGrid().GetGridObject(originX, originY); Vector3 originCell = new Vector3(originX, originY) * pathfinding.GetGrid().GetCellSize() + Vector3.one * pathfinding.GetGrid().GetCellSize() * .5f; originCell.z = -1; movementPath.Add(originCell); } //generate list of available neighbouring nodes/cells List <PathNode> availableMovement = pathfinding.GetNeighbourList(cell); //get Pathnode object from the mouse position PathNode movement = new PathNode(pathfinding.GetGrid(), x, y); //loop through the list of availableMovements to see if the selected cell is within the list //Couldnt use .Contains and had to loop through the list, this could be a problem if the list was LARGE. Should be okay. foreach (PathNode node in availableMovement) { if ((node.x == movement.x && node.y == movement.y) && node.isWalkable) { //add the given movement to the list of Vector3 objects Vector3 cellPos = new Vector3(x, y) * pathfinding.GetGrid().GetCellSize() + Vector3.one * pathfinding.GetGrid().GetCellSize() * .5f; cellPos.z = -1; movementPath.Add(cellPos); cmdCreatePath(cellPos); if (node.isRoughTerrain) { movementSpeed -= 2; } else { movementSpeed--; } } } } //Create a monster if in spawn mode if (Input.touchCount < 2 && Input.GetMouseButtonDown(0) && state == Mode.Spawn) { cmdSpawnNPC(); state = Mode.Idle; } } }
/// <summary> /// is called when a click is longer than 500 millisecond. See also <see cref="LongClick"/> /// </summary> /// <param name="e"></param> /// <returns><b>true</b> interupt the <see cref="OpenGlDevice.EventServer"/> in the sense of "handled". </returns> public virtual void OnLongClick(HandledMouseEventArgs e) { LongClick?.Invoke(this, e); }