private IEnumerator DoSwapTwoGems(GridCell cellA, GridCell cellB) { isSwapping = true; var gem1 = cellA.GemCell; var gem2 = cellB.GemCell; gem1.SetStateSwapping(); gem2.SetStateSwapping(); cellA.ClearGemCell(); cellB.ClearGemCell(); cellA.InitGemCell(gem2, false); cellB.InitGemCell(gem1, false); var pos1 = cellA.Position; var pos2 = cellB.Position; iTween.MoveTo(gem1.gameObject, iTween.Hash("position", pos2, "islocal", true, "time", GemSwapTime)); iTween.MoveTo(gem2.gameObject, iTween.Hash("position", pos1, "islocal", true, "time", GemSwapTime)); yield return(new WaitForSeconds(GemSwapTime)); gem1.SetStateIdle(); gem2.SetStateIdle(); isSwapping = false; OnGemSwapFinished(); }
private IEnumerator DoSwapTwoGems(GridCell cellA, GridCell cellB) { isSwapping = true; var gem1 = cellA.GemCell; var gem2 = cellB.GemCell; gem1.SetStateSwapping(); gem2.SetStateSwapping(); cellA.ClearGemCell(); cellB.ClearGemCell(); cellA.InitGemCell(gem2, false); cellB.InitGemCell(gem1, false); var pos1 = cellA.Position; var pos2 = cellB.Position; iTween.MoveTo(gem1.gameObject, iTween.Hash("position", pos2, "islocal", true, "time", GemSwapTime)); iTween.MoveTo(gem2.gameObject, iTween.Hash("position", pos1, "islocal", true, "time", GemSwapTime)); yield return new WaitForSeconds(GemSwapTime); gem1.SetStateIdle(); gem2.SetStateIdle(); isSwapping = false; OnGemSwapFinished(); }