public FieldLineActionGameState(GameplayGameState _BaseState, int[] ClearRows, IEnumerable <Action> pAfterClearActions) : base(_BaseState) { PlayField = _BaseState.PlayField; //prep the ClearRowInfo. take the row information from the state at the specified row indices, and plop them into ClearRowInfo at those keys. var ContentData = _BaseState.PlayField.Contents; ClearRowInfo = new Dictionary <int, NominoBlock[]>(); foreach (var index in ClearRows) { NominoBlock[] thisrow = new NominoBlock[ContentData[index].Length]; Array.Copy(ContentData[index], thisrow, ContentData[index].Length); //add to Dictionary. ClearRowInfo.Add(index, thisrow); //wipe out the original row to all be nulls. for (int i = 0; i < ContentData[index].Length; i++) { ContentData[index][i] = null; } } AfterClear = pAfterClearActions; // RowNumbers = ClearRows; }
public InsertBlockRowsActionGameState(GameplayGameState pBaseState, int InsertRow, NominoBlock[][] RowData, IEnumerable <Action> pAfterClearActions) : base(pBaseState) { RowInsertions = new Queue <NominoBlock[]>(); foreach (NominoBlock[] AddRow in RowData) { RowInsertions.Enqueue(AddRow); } InsertionRow = InsertRow; AfterClear = pAfterClearActions; }
public FieldLineActionDissolve(GameplayGameState _BaseState, int[] ClearRows, IEnumerable <Action> pAfterClearActions) : base(_BaseState, ClearRows, pAfterClearActions) { List <Point> AllBlockPositions = new List <Point>(); RowClearCount = ClearRows.Length; foreach (int grabrow in ClearRows) { var rowcontent = _BaseState.PlayField.Contents[grabrow]; for (int addblock = 0; addblock < rowcontent.Length; addblock++) { if (rowcontent[addblock] != null) { AllBlockPositions.Add(new Point(grabrow, addblock)); } } } ClearBlockList = new Queue <Point>(); foreach (var choosernd in BagChooser.Shuffle(new Random(), AllBlockPositions)) { ClearBlockList.Enqueue(choosernd); } }
public override void GameProc(IStateOwner pOwner) { if (!PlayedDeathSound) { PlayedDeathSound = true; TetrisGame.Soundman.PlaySound("mmdeath", pOwner.Settings.std.EffectVolume); } if ((DateTime.Now - CompleteSummaryTime).TotalMilliseconds > 500) { CompleteSummaryTime = DateTime.MaxValue; TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.GameOver.Key, pOwner.Settings.std.EffectVolume); GameplayGameState standardstate = GameOveredState as GameplayGameState; if (standardstate != null) { var grabposition = standardstate.GetLocalScores().IsEligible(standardstate.GameStats.Score); if (grabposition > 0) { NewScorePosition = grabposition; } } } if (((DateTime.Now - InitTime)).TotalMilliseconds < 1500) { return; } if ((DateTime.Now - LastAdvance).TotalMilliseconds > 50 && !CompleteScroll) { LastAdvance = DateTime.Now; TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.GameOverShade.Key, pOwner.Settings.std.EffectVolume); CoverBlocks++; GameplayGameState standardstate = GameOveredState as GameplayGameState; if (standardstate != null) { if (CoverBlocks >= standardstate.PlayField.RowCount) { CoverBlocks = standardstate.PlayField.RowCount; CompleteScrollTime = DateTime.Now; CompleteScroll = true; CompleteSummary = false; } } } if (CompleteScroll && !CompleteSummary) { int calcresult = (int)((DateTime.Now - CompleteScrollTime).TotalMilliseconds) / 750; if (calcresult > 0) { if (CurrentLinesDisplay != calcresult) { TetrisGame.Soundman.PlaySound("block_place_2", pOwner.Settings.std.EffectVolume); } CurrentLinesDisplay = calcresult; } if (CurrentLinesDisplay > LineMaxIndex) { CompleteSummary = true; CompleteSummaryTime = DateTime.Now; } } //gameproc doesn't pass through! }