private IEnumerator PositionJewelFromQueue(IRuntimeJewel jq, IRuntimeJewel jq2) { Vector2 BoardTo1 = BoardPos.OffsetJewelByPosition(jq.Pos); Vector2 BoardFrom1 = BoardPos.OffsetJewelByPosition(jq.LastPos); Vector3 to1 = BoardPos.GetNextJewelPosition(BoardTo1, utils.DeckPosition.position); Vector3 from1 = BoardPos.GetNextJewelPosition(BoardFrom1, utils.DeckPosition.position); GameEvents.Instance.Notify <IPositionJewel>(i => i.OnJewelPosition(jq, from1, to1)); Vector2 BoardTo2 = BoardPos.OffsetJewelByPosition(jq2.Pos); Vector2 BoardFrom2 = BoardPos.OffsetJewelByPosition(jq2.LastPos); Vector3 to2 = BoardPos.GetNextJewelPosition(BoardTo2, utils.DeckPosition.position); Vector3 from2 = BoardPos.GetNextJewelPosition(BoardFrom2, utils.DeckPosition.position); GameEvents.Instance.Notify <IPositionJewel>(i => i.OnJewelPosition(jq2, from2, to2)); yield return(new WaitForSeconds(utils.JEWELPOSITIONDELAY)); jq.DoUnselect(); jq2.DoUnselect(); yield return(new WaitForSeconds(utils.JEWELPOSITIONUNSELECTDELAY)); OnDonePosition(); }
private IEnumerator CascadeJewelFromQueue() { IRuntimeJewel jq = JewelsToFall.Dequeue(); Vector2 BoardTo = BoardPos.OffsetJewelByPosition(jq.Pos); Vector2 BoardFrom = BoardPos.OffsetJewelByPosition(jq.LastPos); Vector3 to = BoardPos.GetNextJewelPosition(BoardTo, utils.DeckPosition.position); Vector3 from = jq.IsNew() ? new Vector3(to.x, BoardPos.GetBoardTopPos().y, to.z) : new Vector3(to.x, BoardPos.GetNextJewelPosition(BoardFrom, utils.DeckPosition.position).y, to.z); if (jq.IsNew()) { var uiJewel = UiJewelPool.Instance.Get(jq); IUiJewelComponents comp = uiJewel.MonoBehavior.GetComponent <IUiJewelComponents>(); //comp.UIRuntimeData.OnSetData(jq); uiJewel.MonoBehavior.name = jq.JewelID; uiJewel.transform.position = from; utils.PlayerBoard.AddJewel(uiJewel); } yield return(new WaitForSeconds(utils.JEWELFALLDELAY)); if (jq.IsNew() || jq.LastPos.y != jq.Pos.y) { OnNotifyPositionChange(jq, from, to); } if (JewelsToFall.Count > 0) { JewelsFalling = utils.MBehaviour.StartCoroutine(CascadeJewelFromQueue()); } else { yield return(new WaitForSeconds(.2f)); CheckEndCascade(); } }