public void nextCard(E_moveOutDirection direction) { if (cardMoveEnabled == true) { StartCoroutine(moveCardOut(direction)); } }
IEnumerator moveCardOut(E_moveOutDirection direction) { //Debug.Log ("move out"); EventScript es = spawnedCard.GetComponent <EventScript>(); moveBackEnabled = false; while (actMoveDistance.magnitude <= moveOutMax) { if (anim != null) { if (direction == E_moveOutDirection.none) { //Debug.Log("move out 'none'"); //compatibility to old system if (actMoveDistance.x > 0) { actMoveDistance.x += moveOutSpeed * Time.deltaTime * Screen.width; } else { actMoveDistance.x -= moveOutSpeed * Time.deltaTime * Screen.width; } /* if (actMoveDistance.x > 0) * { * actMoveDistance.x += moveOutSpeed * Time.deltaTime * Screen.width; * } * else * { * actMoveDistance.x -= moveOutSpeed * Time.deltaTime * Screen.width; * } * * if (actMoveDistance.y > 0) * { * actMoveDistance.y += moveOutSpeed * Time.deltaTime * Screen.width; * } * else * { * actMoveDistance.y -= moveOutSpeed * Time.deltaTime * Screen.width; * }*/ } else { switch (direction) { case E_moveOutDirection.left: //move x to the left side, let y go to 0 actMoveDistance.x -= moveOutSpeed * Time.deltaTime * Screen.width; actMoveDistance.y = Mathf.Lerp(actMoveDistance.y, 0, moveOutSpeed * Time.deltaTime * Screen.width); break; case E_moveOutDirection.right: //move x to the right side, let y go to 0 actMoveDistance.x += moveOutSpeed * Time.deltaTime * Screen.width; actMoveDistance.y = Mathf.Lerp(actMoveDistance.y, 0, moveOutSpeed * Time.deltaTime * Screen.width); break; case E_moveOutDirection.up: //move y to up, let x go to 0 actMoveDistance.y += moveOutSpeed * Time.deltaTime * Screen.width; actMoveDistance.x = Mathf.Lerp(actMoveDistance.x, 0, moveOutSpeed * Time.deltaTime * Screen.width); break; case E_moveOutDirection.down: //move y down, let x go to 0 actMoveDistance.y -= moveOutSpeed * Time.deltaTime * Screen.width; actMoveDistance.x = Mathf.Lerp(actMoveDistance.x, 0, moveOutSpeed * Time.deltaTime * Screen.width); break; } } anim.SetFloat("CardPos", actMoveDistance.x); //only set y if card is of type FourDirection if (es != null) { if (es.swipeType == EventScript.E_SwipeType.FourDirection) { anim.SetFloat("CardPosY", actMoveDistance.y); } } else { es = spawnedCard.GetComponent <EventScript>(); } } moveBackEnabled = false; //fixes bug, where move back is enabled, but this routine is also active yield return(null); } newCard(); moveBackEnabled = true; }