Skip to content

Commit

Permalink
Fixed with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Dezerack committed Jan 10, 2024
1 parent 62dbef4 commit 32a7502
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 55 deletions.
20 changes: 10 additions & 10 deletions Assets/Scripts/ClickOnObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ void OnMouseOver()
// Handle finger movements based on TouchPhase
switch (touch.phase)
{
//When a touch has first been detected, change the message and record the starting position
case TouchPhase.Began:
// Record initial touch position.
Debug.Log("Word");
break;
// When a touch has first been detected, change the message and record the starting position
case TouchPhase.Began:
// Record initial touch position.
Debug.Log("Word");
break;

//Determine if the touch is a moving touch
case TouchPhase.Ended:
// Report that the touch has ended when it ends
Debug.Log("Bye bye");
break;
// Determine if the touch is a moving touch
case TouchPhase.Ended:
// Report that the touch has ended when it ends
Debug.Log("Bye bye");
break;
}
}
}
Expand Down
84 changes: 41 additions & 43 deletions Assets/Scripts/MovementJoystick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ public class MovementJoystick : MonoBehaviour
private Vector2 joystickOriginalPos;
private float joystickRadius;


void Start()
{
//Joystick starting position
// Joystick starting position
joystickOriginalPos = joystickBG.transform.position;
joystickRadius = joystickBG.GetComponent<RectTransform>().sizeDelta.y / 4;
}

void Update() //Collider2D other
void Update() // Collider2D other
{
if (Input.touchCount > 0)
{
Expand All @@ -31,50 +30,49 @@ void Update() //Collider2D other
// Handle finger movements based on TouchPhase
switch (touch.phase)
{
//When a touch has first been detected, change the message and record the starting position
case TouchPhase.Began:
// Record initial touch position.
Collider2D[] colliders = Physics2D.OverlapPointAll(AdjustPointToScreen(5, touch.position));
HashSet<string> tag = new HashSet<string>();
foreach (Collider2D collider in colliders)
{
tag.Add(collider.gameObject.tag);
}
//priority interactions
if(tag.Contains("Item"))
{
Debug.Log("Item");
}
else if (tag.Contains("NPC"))
{
Debug.Log("NPC");
}
else if (tag.Contains("Quit"))
{
Debug.Log("Quit");
Application.Quit();
}
//if nothing clicked move joystick to touch position
else
{
joystick.transform.position = touch.position;
joystickBG.transform.position = touch.position;
joystickTouchPos = touch.position;
}
break;
// When a touch has first been detected, change the message and record the starting position
case TouchPhase.Began:
// Record initial touch position.
Collider2D[] colliders = Physics2D.OverlapPointAll(AdjustPointToScreen(5, touch.position));
HashSet<string> tag = new HashSet<string>();
foreach (Collider2D collider in colliders)
{
tag.Add(collider.gameObject.tag);
}
// priority interactions
if (tag.Contains("Item"))
{
Debug.Log("Item");
}
else if (tag.Contains("NPC"))
{
Debug.Log("NPC");
}
else if (tag.Contains("Quit"))
{
Debug.Log("Quit");
Application.Quit();
}
// if nothing clicked move joystick to touch position
else
{
joystick.transform.position = touch.position;
joystickBG.transform.position = touch.position;
joystickTouchPos = touch.position;
}
break;

//Determine if the touch is a moving touch
case TouchPhase.Ended:
// Report that the touch has ended when it ends
joystickVec = Vector2.zero;
joystick.transform.position = joystickOriginalPos;
joystickBG.transform.position = joystickOriginalPos;
break;
// Determine if the touch is a moving touch
case TouchPhase.Ended:
// Report that the touch has ended when it ends
joystickVec = Vector2.zero;
joystick.transform.position = joystickOriginalPos;
joystickBG.transform.position = joystickOriginalPos;
break;
}
}
}


// for the draging
public void Drag(BaseEventData baseEventData)
{
Expand All @@ -84,7 +82,7 @@ public void Drag(BaseEventData baseEventData)

float joystickDist = Vector2.Distance(dragPos, joystickTouchPos);

if(joystickDist < joystickRadius)
if (joystickDist < joystickRadius)
{
joystick.transform.position = joystickTouchPos + joystickVec * joystickDist;
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Scripts/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ void Start()

void FixedUpdate()
{
if(movementJoystick.joystickVec.y != 0)
if (movementJoystick.joystickVec.y != 0)
{
rb.velocity = new Vector2(movementJoystick.joystickVec.x * playerSpeed, movementJoystick.joystickVec.y * playerSpeed);
rb.velocity =
new Vector2(movementJoystick.joystickVec.x * playerSpeed, movementJoystick.joystickVec.y * playerSpeed);
}

else
Expand Down

0 comments on commit 32a7502

Please sign in to comment.