This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
using UnityEngine.Events; | |
public static class MonoExtensions | |
{ | |
public static Coroutine Wait(this MonoBehaviour mono, float delay, UnityAction action) | |
{ | |
return mono.StartCoroutine(ExecuteAction(delay, action)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class LayerExtensions | |
{ | |
public static bool Contains(this LayerMask mask, int layer) | |
{ | |
return (mask.value & 1 << layer) > 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
public class PlayerMovement : MonoBehaviour | |
{ | |
public float rollDuration = 1f; | |
private bool isRolling; | |
public Transform pivot; | |
public Transform ghostPlayer; | |
public LayerMask contactWallLayer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Transform ghostPlayer; | |
private IEnumerator RollToDirection(Direction swipeDirection) | |
{ | |
if (!isRolling) | |
{ | |
isRolling = true; | |
float angle = 90f; | |
Vector3 axis = GetAxis(swipeDirection); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public LayerMask contactWallLayer; | |
private void Roll(Direction direction) | |
{ | |
StartCoroutine(RollToDirection(direction)); | |
} | |
private IEnumerator RollToDirection(Direction swipeDirection) | |
{ | |
if(!isRolling) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Roll(Direction direction) | |
{ | |
StartCoroutine(RollToDirection(direction)); | |
} | |
private IEnumerator RollToDirection(Direction swipeDirection) | |
{ | |
if(!isRolling) | |
{ | |
isRolling = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class PlayerMovement : MonoBehaviour | |
{ | |
public float rollDuration = 1f; | |
private bool isRolling; | |
public Transform pivot; | |
public InputManager InputManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void OnEndDrag(PointerEventData eventData) | |
{ | |
if (draggingStarted && direction != Direction.None) | |
{ | |
//A swipe is detected | |
if (onSwipeDetected != null) | |
onSwipeDetected.Invoke(direction); | |
} | |
//reset the variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class InputManager : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler | |
{ | |
public Action<Direction> onSwipeDetected; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.EventSystems; | |
public class InputManager : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler | |
{ | |
public enum Direction { Left, Up, Right, Down, None } | |
Direction direction; | |
Vector2 startPos, endPos; |
NewerOlder