private void Update() { //Calcoli matematici per spostarsi dalla propria cella a quella voluta, sempre se sussista quella voluta if (isMoving) { this.distance = this.newCellReference.transform.position - this.transform.position; this.direction = this.distance.normalized; this.transform.position = (Vector2)this.transform.position + this.direction * Time.deltaTime; if (this.distance.magnitude < 0.1f) { this.transform.position = new Vector3(this.newCellReference.transform.position.x, this.newCellReference.transform.position.y, 0); this.AssignCellReference(this.newCellReference); this.newCellReference = null; isMoving = false; } } //Valutazione delle fasi del giocatore if (this.actualPlayerPhase == PLAYER_PHASE.MOVING && !isMoving) { //A seconda del comando desiderato, il giocatore si sposterà sulla griglia nella direzione desiderata if (Input.GetKey(this.playerInputKey[(int)BUTTON.UP])) { this.newCellReference = gridManagerLinking.CheckingUpCell(this.cellReference); if (this.newCellReference != null) { isMoving = true; } else { Debug.Log("Cannot Move there"); } } if (Input.GetKey(this.playerInputKey[(int)BUTTON.DOWN])) { this.newCellReference = gridManagerLinking.CheckingDownCell(this.cellReference); if (this.newCellReference != null) { isMoving = true; } else { Debug.Log("Cannot Move there"); } } if (Input.GetKey(this.playerInputKey[(int)BUTTON.LEFT])) { this.newCellReference = gridManagerLinking.CheckingLeftCell(this.cellReference); if (this.newCellReference != null) { isMoving = true; } else { Debug.Log("Cannot Move there"); } } if (Input.GetKey(this.playerInputKey[(int)BUTTON.RIGHT])) { this.newCellReference = gridManagerLinking.CheckingRightCell(this.cellReference); if (this.newCellReference != null) { isMoving = true; } else { Debug.Log("Cannot Move there"); } } } }