private void SetQuadrant() { if (deltaPos.x > 0 && deltaPos.y > 0) { currentQuadrant = mQuadrant.TOPRIGHT; } if (deltaPos.x < 0 && deltaPos.y > 0) { currentQuadrant = mQuadrant.TOPLEFT; } if (deltaPos.x < 0 && deltaPos.y < 0) { currentQuadrant = mQuadrant.BOTTOMLEFT; } if (deltaPos.x > 0 && deltaPos.y < 0) { currentQuadrant = mQuadrant.BOTTOMRIGHT; } switch (currentQuadrant) { case mQuadrant.TOPRIGHT: if (Vector2.Dot(Vector2.up, deltaPos) > dotProductConst) { currentDirection = mDirection.UP; currentDirectionVector = Vector2.up; } else { currentDirection = mDirection.RIGHT; currentDirectionVector = Vector2.right; } break; case mQuadrant.TOPLEFT: if (Vector2.Dot(Vector2.up, deltaPos) > dotProductConst) { currentDirection = mDirection.UP; currentDirectionVector = Vector2.up; } else { currentDirection = mDirection.LEFT; currentDirectionVector = Vector2.left; } break; case mQuadrant.BOTTOMLEFT: if (Vector2.Dot(Vector2.down, deltaPos) > dotProductConst) { currentDirection = mDirection.DOWN; currentDirectionVector = Vector2.down; } else { currentDirection = mDirection.LEFT; currentDirectionVector = Vector2.left; } break; case mQuadrant.BOTTOMRIGHT: if (Vector2.Dot(Vector2.down, deltaPos) > dotProductConst) { currentDirection = mDirection.DOWN; currentDirectionVector = Vector2.down; } else { currentDirection = mDirection.RIGHT; currentDirectionVector = Vector2.right; } break; } }
private void Start() { currentDirection = mDirection.UP; currentDirectionVector = Vector2.up; }