JOSEPH SIEREJKO
GAME DEVELOPER : PROGRAMMER : DESIGNER
| roles | Programmer • Graphic Designer • UI |
| software | Unity Engine • Adobe Photoshop • Visual Studio • Vuforia |
| languages | C# |
| team size | |
| platforms | iPhone • iPad • Android |
void Swipe()
{
//Move forward if swiping left and not at end of PDF
if (previousPosition.x < startPosition.x & currentPage < pageList.Count)
image.sprite = pageList[++currentPage];
//Move Backward if swiping right and not at beginning of PDF
else if (previousPosition.x > startPosition.x & currentPage > 0)
image.sprite = pageList[--currentPage];
//Move image to center position
currentRect.localPosition = Vector3.zero;
//Fit image within screenspace
ScaleToFit();
}
void ScaleToFit()
{
//image.SetNativeSize(); //Reset scale
//Check PFD Ratio for the bigger ratio
if (currentRect.rect.width > currentRect.rect.height)
{
//Adjust the scale relative to the difference between the rect's width and screen width
currentRect.localScale = Vector3.one * (Screen.width / currentRect.rect.width);
//The image's top and bottom are outside of the screen height
if(currentRect.rect.height * currentRect.localScale.y > Screen.height)
{
//Set the adjusted height percentage
float scaleHeight = Screen.height / currentRect.rect.height;
currentRect.localScale -= Vector3.one * (currentRect.localScale.y - scaleHeight);
}
}
else
{
currentRect.localScale = Vector3.one * (Screen.height / currentRect.rect.height);
if (currentRect.rect.width * currentRect.localScale.x > Screen.width)
{
float scaleWidth = Screen.width / currentRect.rect.width;
currentRect.localScale -= Vector3.one * (currentRect.localScale.x - scaleWidth);
}
}
}
//Changed screen orientation
void CheckForNewOrientation()
{
if(Screen.orientation != orientation) //Current Orientation has updated
{
ScaleToFit();
orientation = Screen.orientation;
}
}
//When one of the bounds is at its end, stop moving in that axis
Vector2 GetBoundedMovement(Vector2 direction)
{
if (StopMovementOnXAxis(direction.x))
direction = new Vector2(0, direction.y);
if (StopMovementOnYAxis(direction.y))
direction = new Vector2(direction.x, 0);
return direction;
}
//Pinch Zoom Scaling
void Zoom()
{
Touch first = Input.GetTouch(0);
Touch second = Input.GetTouch(1);
Vector2 firstPrev = first.position - first.deltaPosition; //Last position of first finger
Vector2 secondPrev = second.position - second.deltaPosition; //Last position of second finger
//The comparers in the amount of movement in magnitude
float currentTouchMagnitude = (first.position - second.position).magnitude;
float previousTouchMagnitude = (firstPrev - secondPrev).magnitude;
//Get the movement magnidude's difference
float difference = currentTouchMagnitude - previousTouchMagnitude;
//Scale up/down image
currentRect.localScale += (Vector3.one * difference) * zoomSpeed;
//Maximum Scale
if (currentRect.localScale.x > 2)
currentRect.localScale = Vector3.one * 2;
//Scale to ensure that scaling stays at least the size of screen
if (currentRect.localScale.x * currentRect.rect.width < Screen.width &
currentRect.localScale.y * currentRect.rect.height < Screen.height)
ScaleToFit();
}
Portrait
LandScape
void TrackOrientation()
{
//Set new Starting Position
closedPosition = Screen.width;
//Set New End Position
openedPosition = (closedPosition + ((buttonRect.rect.width * buttonRect.localScale.x) * 2)) - Screen.width;
menu.transform.position = new Vector3(closedPosition,
menu.transform.position.y, 0);
orientation = Screen.orientation;
}
public void OpenCloseHamburger()
{
if (hamburgerIsOpen)
StartCoroutine(closeHamburger);
else
StartCoroutine(openHamburger);
}
IEnumerator OpenHamburger()
{
StopCoroutine(closeHamburger); //So Open and close threads don't overlap
closeHamburger = CloseHamburger(); //Set new routine for new function call
RectTransform menuRect = menu.GetComponent<RectTransform>();
//Set Destination to End Position
Vector2 destination = new Vector2(openedPosition, menuRect.position.y);
while (Vector2.Distance(menuRect.position, destination) > 1)
{
yield return new WaitForEndOfFrame();
//Move towards destination
menuRect.position = Vector2.Lerp(menuRect.position, destination, Time.deltaTime * 10f);
}
menuRect.position = destination; //Set to destination
hamburgerIsOpen = true;
}
IEnumerator CloseHamburger()
{
StopCoroutine(openHamburger); //So Open and close threads don't overlap
openHamburger = OpenHamburger(); //Set new routine for new function call
RectTransform menuRect = menu.GetComponent<RectTransform>();
//Set Destination to Default Position
Vector2 destination = new Vector2(closedPosition, menuRect.position.y);
while (Vector2.Distance(menuRect.position, destination) > 1)
{
yield return new WaitForEndOfFrame();
//Move towards destination
menuRect.position = Vector2.Lerp(menuRect.position, destination, Time.deltaTime * 10f);
}
menuRect.position = destination; //Set to destination
hamburgerIsOpen = false;
}
public void OpenURL(string url) { Application.OpenURL(url); }
void InitializeEmailURL()
{
string emailAddress = EscapeURL("ContactMe@dewetron.com");
string emailSubject = EscapeURL("AR Connection");
string emailBody = EscapeURL(
"I would like to know more about DEWETRON products! \n\n" +
"Please contact me using the email address identified in this response.\n\n" +
"You may also contact me using the following phone number:\n\n" +
"With this response, I am giving you permission to contact me about DEWETRON products and services.\n\n" +
"Thanks\n\n");
emailUrl = "mailto:" + emailAddress + "?subject=" + emailSubject + "&body=" + emailBody;
}
public void Email() { OpenURL(emailUrl); }
string EscapeURL(string url)
{
return WWW.EscapeURL(url).Replace("+", "%20");
}