public void MaxSentence(JObject json) { Total.Value++; MaxTotal.Value++; Swipes.Add(1); CheckRound(); }
///<summary>Converts the angle of a swipe on the screen into a direction for the snake (`Snake.DIRECTION_*`). /// If a direction cannot be determined, returns -1.</summary> public int directionForSwipe(float swipeAngle) { // use the onscreen angles from the center of the direction cube to the corners as boundaries for the directions Vector2 centerScreenPoint = this.smallCamera.WorldToScreenPoint(this.center.position); // (implicit conversion from Vector3) Vector2 posXposZScreenPoint = this.smallCamera.WorldToScreenPoint(this.posXposZ.position); Vector2 negXposZScreenPoint = this.smallCamera.WorldToScreenPoint(this.negXposZ.position); Vector2 negXnegZScreenPoint = this.smallCamera.WorldToScreenPoint(this.negXnegZ.position); Vector2 posXnegZScreenPoint = this.smallCamera.WorldToScreenPoint(this.posXnegZ.position); float posXposZAngle = Swipes.angleBetweenPoints(centerScreenPoint, posXposZScreenPoint); float negXposZAngle = Swipes.angleBetweenPoints(centerScreenPoint, negXposZScreenPoint); float negXnegZAngle = Swipes.angleBetweenPoints(centerScreenPoint, negXnegZScreenPoint); float posXnegZAngle = Swipes.angleBetweenPoints(centerScreenPoint, posXnegZScreenPoint); //Debug.Log("+x+z: " + posXposZAngle + ", -x+z: " + negXposZAngle + ", -x-z: " + negXnegZAngle + ", +x-z: " + posXnegZAngle); if (this.angleIsInRange(swipeAngle, posXposZAngle, negXposZAngle)) { return(Snake.DIRECTION_POS_Z); } else if (this.angleIsInRange(swipeAngle, negXposZAngle, negXnegZAngle)) { return(Snake.DIRECTION_NEG_X); } else if (this.angleIsInRange(swipeAngle, negXnegZAngle, posXnegZAngle)) { return(Snake.DIRECTION_NEG_Z); } else if (this.angleIsInRange(swipeAngle, posXnegZAngle, posXposZAngle)) { return(Snake.DIRECTION_POS_X); } return(-1); }
public void MinSentence(JObject json) { Total.Value++; MinTotal.Value++; Swipes.Add(0); CheckRound(); }
public void SetNextSwipeType(Swipes swipe) { if (swipe == Swipes.Invalid) { m_SR_nextSwipe.gameObject.SetActive(false); return; } m_SR_nextSwipe.transform.position = new Vector3(0.0f, 0.0f, m_SR_nextSwipe.transform.position.z); m_SR_nextSwipe.transform.rotation = Quaternion.identity; if (swipe == Swipes.Up) { m_SR_nextSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 0.0f)); } else if (swipe == Swipes.Down) { m_SR_nextSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 180.0f)); } else if (swipe == Swipes.Left) { m_SR_nextSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 90.0f)); } else if (swipe == Swipes.Right) { m_SR_nextSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 270.0f)); } }
public void SetCurrentSwipeType(Swipes swipe, float timeUntilNextSwipe) { m_swipeType = swipe; m_SR_currentSwipe.transform.position = new Vector3(0.0f, 0.0f, m_SR_currentSwipe.transform.position.z); m_SR_currentSwipe.transform.rotation = Quaternion.identity; if (swipe == Swipes.Up) { m_SR_currentSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 0.0f)); } else if (swipe == Swipes.Down) { m_SR_currentSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 180.0f)); } else if (swipe == Swipes.Left) { m_SR_currentSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 90.0f)); } else if (swipe == Swipes.Right) { m_SR_currentSwipe.transform.Rotate(new Vector3(0.0f, 0.0f, 270.0f)); } m_SR_currentSwipeIndicator.transform.rotation = m_SR_currentSwipe.transform.rotation; m_start = m_audioManager.GetTimePassed(); m_end = m_start + timeUntilNextSwipe; m_divider = 1.0f / (m_end - m_start); }
private void Start() { player = GameObject.Find("player").GetComponent <SpawnSticks>(); swipeScript = GameObject.Find("spawner").GetComponent <Swipes>(); //forwardBtn = GameObject.Find("ButtonForward").GetComponent<Button>(); //downBtn = GameObject.Find("ButtonDown").GetComponent<Button>(); audioS = GameObject.Find("audio").GetComponent <AudioSource>(); mainCam = GameObject.Find("Main Camera").GetComponent <Camera>(); }
public void SwipeDetection() { if (Input.GetMouseButtonDown(0)) { fingerStart = Input.mousePosition; fingerEnd = Input.mousePosition; } if (Input.GetMouseButton(0)) { fingerEnd = Input.mousePosition; currentSwipe = new Vector2(fingerEnd.x - fingerStart.x, fingerEnd.y - fingerStart.y); // Make sure it was a legit swipe, not a tap if (currentSwipe.magnitude < minSwipeLength) { direction = Swipes.None; return; } float angle = (Mathf.Atan2(currentSwipe.y, currentSwipe.x) / (Mathf.PI)); Debug.Log(angle); // Swipe up if (angle > 0.375f && angle < 0.625f) { direction = Swipes.Up; Debug.Log("Up"); // Swipe down } else if (angle < -0.375f && angle > -0.625f) { direction = Swipes.Down; Debug.Log("Down"); // Swipe left } else if (angle < -0.875f || angle > 0.875f) { direction = Swipes.Left; Debug.Log("Left"); // Swipe right } else if (angle > -0.125f && angle < 0.125f) { direction = Swipes.Right; Debug.Log("Right"); } else if (angle > 0.125f && angle < 0.375f) { direction = Swipes.TopRight; Debug.Log("top right"); } else if (angle > 0.625f && angle < 0.875f) { direction = Swipes.TopLeft; Debug.Log("top left"); } else if (angle < -0.125f && angle > -0.375f) { direction = Swipes.BottomRight; Debug.Log("bottom right"); } else if (angle < -0.625f && angle > -0.875f) { direction = Swipes.BottomLeft; Debug.Log("bottom left"); } } if (Input.GetMouseButtonUp(0)) { direction = Swipes.None; } }
public void FetchProfiles(JObject json) { Server.Instance.FetchProfiles(GameId.Value, Round.Value, Swipes.ToArray()); Swipes.Clear(); Round.Value++; }
private void Start() { intStick = 0; stickCol = GetComponent <StickCol>(); swipeScript = GameObject.Find("spawner").GetComponent <Swipes>(); }