void Destroy() { if (EndChecker.EndLeft(transform.position.x + destroyWait)) { Destroy(gameObject); } if (!mirror && (EndChecker.EndRight(transform.position.x - destroyWait) || EndChecker.EndTop(transform.position.y - destroyWait) || EndChecker.EndBottom(transform.position.y + destroyWait))) { Destroy(gameObject); } }
void Move() { Vector2 afterPos = playerTouchState.beforePos + (playerTouchState.afterTouchPos - playerTouchState.beforeTouchPos); transform.position = afterPos; if (EndChecker.EndRight(transform.position.x + moveRestRight)) { transform.position = new Vector2(EndChecker.endRight - moveRestRight, transform.position.y); } else if (EndChecker.EndLeft(transform.position.x - moveRestOther)) { transform.position = new Vector2(EndChecker.endLeft + moveRestOther, transform.position.y); } if (EndChecker.EndTop(transform.position.y + moveRestOther)) { transform.position = new Vector2(transform.position.x, EndChecker.endTop - moveRestOther); } else if (EndChecker.EndBottom(transform.position.y - moveRestOther)) { transform.position = new Vector2(transform.position.x, EndChecker.endBottom + moveRestOther); } }