public void SetBlock(Point aPosition, AbstractBlock aBlock) { aBlock.SetPosition(aPosition); AbstractBlock previousBlock = myGrid[aPosition.Y][aPosition.X].GetBlock(); myBlocks[myBlocks.LastIndexOf(previousBlock)] = aBlock; myGrid[aPosition.Y][aPosition.X].SetBlock(aBlock); //here }
// +Player actions! public void SwapBlocksRight(Point aPosition) { AbstractBlock leftBlock = myGridContainer.GetBlockAtPosition(aPosition); AbstractBlock rightBlock = myGridContainer.GetBlockAtPosition(aPosition + new Point(1, 0)); if ((leftBlock is ColorBlock || leftBlock is EmptyBlock) && leftBlock.IsSwitching() == false) { if ((rightBlock is ColorBlock || rightBlock is EmptyBlock) && rightBlock.IsSwitching() == false) { leftBlock.SetPosition(aPosition + new Point(1, 0)); rightBlock.SetPosition(aPosition); myGridContainer.myGrid[aPosition.Y][aPosition.X].SetBlock(rightBlock); myGridContainer.myGrid[aPosition.Y][aPosition.X + 1].SetBlock(leftBlock); float magicSwitchTime = 0.66f / myModifiedGameSpeed; leftBlock.StartTheSwitchingCalculation(magicSwitchTime, ESwitchDirection.ToTheRight); rightBlock.StartTheSwitchingCalculation(magicSwitchTime, ESwitchDirection.ToTheLeft); } } }