/////////////////////////////////////////////// //////////////////PROPERTIES/////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// ////////////////////METHODS//////////////////// /////////////////////////////////////////////// //////////////TRANSFORM_METHODS//////////////// public override void moveTo(float x, float y) { if (OnMoveStart != null) { if (!OnMoveStart.Invoke(this, this.x, this.y)) { return; } } if (OnMoving != null) { OnMoving.Invoke(this, this.x, this.y); } float oldX = this.x, oldy = this.y; this.X = x; this.Y = y; if (OnMoved != null) { OnMoved.Invoke(this, oldX, oldy); } }
/////////////////////////////////////////////// //////////////////PROPERTIES/////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// ////////////////////METHODS//////////////////// /////////////////////////////////////////////// //////////////TRANSFORM_METHODS//////////////// public override void moveTo(float x, float y) { float oldX = systemCenter.X, oldY = systemCenter.Y; if (OnMoveStart != null) { if (!OnMoveStart.Invoke(this, oldX, oldY)) { return; } } if (OnMoving != null) { OnMoving.Invoke(this, oldX, oldY); } GlVectorR2 moveVector = new GlVectorR2(x - this.systemCenter.X, y - this.systemCenter.Y); this.systemCenter = new GlPointR2(x, y); foreach (GlFigure F in this.figuresAmount) { GlPointR2 newCenter = moveVector.fromPointToPoint(F.Center); F.moveTo(newCenter.X, newCenter.Y); } if (OnMoved != null) { OnMoving.Invoke(this, oldX, oldY); } }
void Movement() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Vector3 mousePos = Input.mousePosition; if (Physics.Raycast(Camera.main.ScreenPointToRay(mousePos), out hit, Mathf.Infinity, ~IgnoreMe)) { hasAMoveCommand = true; playerNavMeshTarget = hit.point; playerNavMeshAgent.SetDestination(playerNavMeshTarget); OnMoveStart?.Invoke(playerNavMeshAgent.destination); if (hit.transform.gameObject.GetComponent <WorldInteractive>() != null) { interactedObject = hit.transform.gameObject.GetComponent <WorldInteractive>(); } } } if ((hasAMoveCommand == true) && (playerNavMeshAgent.velocity == Vector3.zero) && (!playerNavMeshAgent.pathPending)) { if (playerNavMeshAgent.remainingDistance < playerNavMeshAgent.stoppingDistance) { if ((interactedObject != null)) { //Debug.Log((playerNavMeshAgent.transform.position - interactedObject.transform.position).sqrMagnitude); interactedObject.OnInteract(); interactedObject = null; } hasAMoveCommand = false; OnMoveStopped?.Invoke(); } } }
/////////////////////////////////////////////// //////////////////PROPERTIES/////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// ////////////////////METHODS//////////////////// /////////////////////////////////////////////// //////////////TRANSFORM_METHODS//////////////// public override void moveTo(float x, float y) { float oldX = this.Center.X; float oldY = this.Center.Y; if (OnMoveStart != null) { if (!OnMoveStart.Invoke(this, oldX, oldY)) { return; } } if (OnMoving != null) { OnMoving.Invoke(this, oldX, oldY); } this.systemCenter = new GlPointR2(x, y); updatePointsPosition(); if (OnMoved != null) { OnMoved.Invoke(this, oldX, oldY); } }
/////////////////////////////////////////////// //////////////////PROPERTIES/////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// ////////////////////METHODS//////////////////// /////////////////////////////////////////////// //////////////TRANSFORM_METHODS//////////////// public override void moveTo(float x, float y) { if (OnMoveStart != null) { if (!OnMoveStart.Invoke(this, this.polyCenter.X, this.polyCenter.Y)) { return; } } if (OnMoving != null) { OnMoving.Invoke(this, this.polyCenter.X, this.polyCenter.Y); } GlVectorR2 delta = new GlVectorR2(x - polyCenter.X, y - polyCenter.Y); for (int i = 0; i < vertexes.Length; i++) { vertexes[i] = delta.fromPointToPoint(vertexes[i]); } GlPointR2 OP = new GlPointR2(this.polyCenter); this.polyCenter = new GlPointR2(x, y); if (OnMoved != null) { OnMoved.Invoke(this, OP.X, OP.Y); } }
/////////////////////////////////////////////// //////////////////PROPERTIES/////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// ////////////////////METHODS//////////////////// /////////////////////////////////////////////// //////////////TRANSFORM_METHODS//////////////// public void moveTo(GlPointR2 newBelongsPoint) { if (newBelongsPoint == null || newBelongsPoint.isNullPoint()) { return; } if (OnMoveStart != null) { if (!OnMoveStart.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y)) { return; } } if (OnMoving != null) { OnMoving.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y); } GlPointR2 OP = new GlPointR2(this.PointOfLine); this.pointOfLine = newBelongsPoint; if (OnMoved != null) { OnMoved.Invoke(this, OP.X, OP.Y); } }
private void OnMouseOver() { if (Input.GetMouseButtonDown(1)) { _isMoving = true; _initialPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); OnMoveStart?.Invoke(this, EventArgs.Empty); } }
public void NotifyMoveStart(Event eventArgs) { OnMoveStart?.Invoke(this, eventArgs); }
public void NotifyMoveStart(Event e) => OnMoveStart?.Invoke(this, e);
public virtual void Interact(Cell cell) { OnMoveStart?.Invoke(this); }