public override void GameProc(IStateOwner pOwner) { base.GameProc(pOwner); if (pOwner.CurrentState is GameplayGameState stgs1) { //pOwner.EnqueueAction(() => { stgs1.PlayField.HasChanged = true; }); } if (StartOperation == DateTime.MaxValue) { StartOperation = LastOperation = DateTime.Now; } if (ClearActivities.Count > 0) { DateTime useNowTime = DateTime.Now; foreach (var ClearActivity in ClearActivities) { var elapsed = useNowTime - ClearActivity.StartClearTime; foreach (var block in ClearActivity.Blocks) { ClearActivity.ClearAction.ProcessBlock(pOwner, new BlockClearData(block, new BCPoint() { }), elapsed); } } } //for now we clear horizontally across... if ((DateTime.Now - LastOperation).TotalMilliseconds > MSBlockClearTime) { //clear another block on each row. var ClearResult = ClearFrame(pOwner); if (ClearRowInfo.Keys.Count >= 4) { FlashState = !FlashState; } if (ClearActivities.Count > 0) { DateTime NowTime = DateTime.Now; //if there are entries in ClearActivities, we want to make sure those are cleared as well. This is the case if the cleartime has elapsed for each. ClearResult |= ClearActivities.All((kvp) => { return(NowTime - kvp.StartClearTime > kvp.ClearAction.ClearTime); }); } LastOperation = DateTime.Now; if (ClearResult) { //reset the original State. pOwner.CurrentState = _BaseState; foreach (var iterate in AfterClear) { pOwner.EnqueueAction(iterate); } if (pOwner.CurrentState is GameplayGameState stgs2) { // pOwner.EnqueueAction(() => { stgs2.PlayField.HasChanged = true; }); } } } }
protected void PerformClearAct(NominoBlock[] FullRow, int index) { if (ClearAction == null) { FullRow[index] = null; } else { //if we have a clear action, then we want to create a new instance and set it up here, then add it to the ClearActivities Dictionary. //Remember- this is separate from our line clear style, and is used to animate each block "clearing" (shrinking away, fading, etc) FieldBlockClearTask fbct = new FieldBlockClearTask(ClearAction, new NominoBlock[] { FullRow[index] }); ClearActivities.Add(fbct); } }