IEnumerator UseAnimation(UsableObject usable, float posX, float posY) { Vector3 pos = new Vector3(); pos.x = posX; pos.y = posY; desPosition = transform.parent.InverseTransformPoint(pos); desPosition.z = defaultPosition.z; handState = LeftHandState.UsingTo; yield return(new WaitForSeconds(movingTime - lightUpTime / 2)); mask.SetActive(true); sprite.sprite = sprite1; yield return(new WaitForSeconds(lightUpTime / 2)); RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.zero, 100, interactLayerMask); usable.Use(posX, posY, hit.collider == null?null: hit.collider.gameObject); handState = LeftHandState.UsingBack; yield return(new WaitForSeconds(lightUpTime / 2)); mask.SetActive(false); sprite.sprite = sprite0; yield return(new WaitForSeconds(movingTime - lightUpTime / 2)); handState = LeftHandState.None; }
// Use this for initialization void Start() { handState = LeftHandState.None; leftH = GetComponent <AudioSource> (); }