public override void OnDestroy() { base.OnDestroy(); UnsubscribeInput(); gemViews = null; actionQueueByTurn = null; if (sequence != null) { sequence.Kill(); sequence = null; } completedRuleInfo = null; }
IEnumerator StartUpdateChanges(Action <Int64> OnNoAnyMatches) { isPlaying = true; sequence = GOTween.Sequence().SetAutoKill(false); var currentFrame = 0; var startTurn = Model.currentTurn; var noUpdateCount = 0; while (true) { if (currentFrame % FRAME_BY_TURN == 0) { var passedTurn = Model.currentTurn - startTurn; var currentTime = FRAME_BY_TURN * TIME_PER_FRAME * passedTurn; // Debug.Log("currentTime : " + Model.currentTurn + ", " + currentTime); var countOfAction = actionQueueByTurn.Count; Queue <Action <GOSequence, float> > actionQueue; if (actionQueueByTurn.TryGetValue(Model.currentTurn, out actionQueue)) { while (actionQueue.Count > 0) { var action = actionQueue.Dequeue(); action.Invoke(sequence, currentTime); } actionQueueByTurn.Remove(Model.currentTurn); } updateResult.feedResult = Controller.Feed(); updateResult.fallResult = Controller.Fall(); updateResult.matchResult = Controller.Match(); if (passedTurn == 6) { if (updateResult.matchResult.Count == 0 && OnNoAnyMatches != null) { OnNoAnyMatches(passedTurn); } } if (updateResult.HasAnyResult) { noUpdateCount = 0; MatchGems(updateResult.matchResult, sequence, currentTime); FeedGems(updateResult.feedResult, sequence, currentFrame); FallGems(updateResult.fallResult, sequence, currentTime); } else if (countOfAction > 0) { noUpdateCount = 0; } else { noUpdateCount += 1; } Controller.TurnNext(); // Debug.Log(noUpdateCount + ", " + sequence.IsComplete + ", " + countOfAction); if (passedTurn > 20) { yield return(null); } if (noUpdateCount > 20 && sequence.IsComplete) { break; } } currentFrame += 1; } sequence.Kill(); isPlaying = false; }