private void Move(Vector2 dir) { var startPos = _model.position; var endPos = startPos + dir; var hitInfo = Linecast(startPos, endPos); if (hitInfo.transform.IsNull()) { _model.DOMove(_model.position + dir, _moveTime, OnMoveComplete); } else if (hitInfo.transform.CompareTag("Player")) { var player = hitInfo.transform.GetComponent <Player>(); Debug.Assert(player.IsValid()); PlayerKill(player); } else if (hitInfo.transform.CompareTag("Wall")) { _model.SetDirection(-_model.dir); _model.DOMove(_model.position + _model.dir, _moveTime, OnMoveComplete); } }
private void SetReturnDirection() { var dirToReturn = (_model.originPos - _model.position).normalized; _model.SetDirection(dirToReturn); }