void CleanUpBlocks() { /*if (iBlockQueueIndex_ == 1) { * while (UseBlockList2_.Count > 0) { * GameObject Block = UseBlockList2_.Dequeue(); * Block.renderer.enabled = false; * UnusedBlockQueue_.Enqueue(Block); * } * iBlockQueueIndex_ = 2; * } * else if (iBlockQueueIndex_ == 2) { * while (UseBlockList1_.Count > 0) { * GameObject Block = UseBlockList1_.Dequeue(); * Block.renderer.enabled = false; * UnusedBlockQueue_.Enqueue(Block); * } * iBlockQueueIndex_ = 1; * }*/ // clean up unshown blocks foreach (int iIndex in UnShownBlockList_) { SBlock BlockThing = GetBlock(iIndex); BlockThing.Reset(); if (BlockModels_[iIndex] != null && BlockModels_[iIndex].GetComponent <Renderer>().enabled) { BlockModels_[iIndex].GetComponent <Renderer>().enabled = false; } } UnShownBlockList_.Clear(); }
private static void RunSingleTransactionBlockExample() { SBlockChain sBlockChain = new SBlockChain(); ISBlock block1 = new SBlock(0, "ABC123", 1000.00m, DateTime.Now, "QWE123", 10000, ClaimType.TotalLoss, null); ISBlock block2 = new SBlock(1, "VBG345", 2000.00m, DateTime.Now, "JKH567", 20000, ClaimType.TotalLoss, block1); ISBlock block3 = new SBlock(2, "XCF234", 3000.00m, DateTime.Now, "DH23ED", 30000, ClaimType.TotalLoss, block2); ISBlock block4 = new SBlock(3, "CBHD45", 4000.00m, DateTime.Now, "DH34K6", 40000, ClaimType.TotalLoss, block3); ISBlock block5 = new SBlock(4, "AJD345", 5000.00m, DateTime.Now, "28FNF4", 50000, ClaimType.TotalLoss, block4); ISBlock block6 = new SBlock(5, "QAX367", 6000.00m, DateTime.Now, "FJK676", 60000, ClaimType.TotalLoss, block5); ISBlock block7 = new SBlock(6, "CGO444", 7000.00m, DateTime.Now, "LKU234", 70000, ClaimType.TotalLoss, block6); ISBlock block8 = new SBlock(7, "PLO254", 8000.00m, DateTime.Now, "VBN456", 80000, ClaimType.TotalLoss, block7); sBlockChain.AcceptBlock(block1); sBlockChain.AcceptBlock(block2); sBlockChain.AcceptBlock(block3); sBlockChain.AcceptBlock(block4); sBlockChain.AcceptBlock(block5); sBlockChain.AcceptBlock(block6); sBlockChain.AcceptBlock(block7); sBlockChain.AcceptBlock(block8); sBlockChain.VerifyChain(); Console.WriteLine(""); Console.WriteLine(""); block4.CreatedDate = new DateTime(2017, 09, 20); sBlockChain.VerifyChain(); Console.WriteLine(); }
//int CheckBlockoverVertical(int x, int y, SBlock.BlockType type) //{ // if (y < 1 || y > 6) // return 0; // else if (mBlockArray[x, y].mType != type) // return 0; // else if (mBlockArray[x, y].mState == Block.BlockState.Match) // return 0; // mBlockArray[x, y].SetStateToMatch(); // return 1 + // CheckBlockoverVertical(x, y + 1, type) + // CheckBlockoverVertical(x, y - 1, type); //} #endregion #region SettingFunciont bool CheckMatchForSetRandomType(SBlock block) { int x = block.mData.mX; int y = block.mData.mY; //left if (x > 2 && x < 7 && block.mType == mBlockArray[x - 1, y].mType && block.mType == mBlockArray[x - 2, y].mType) { return(true); } //right else if (x < 5 && x > 0 && block.mType == mBlockArray[x + 1, y].mType && block.mType == mBlockArray[x + 2, y].mType) { return(true); } //top else if (y > 2 && y < 7 && block.mType == mBlockArray[x, y - 1].mType && block.mType == mBlockArray[x, y - 2].mType) { return(true); } //bottom else if (y < 5 && y > 0 && block.mType == mBlockArray[x, y + 1].mType && block.mType == mBlockArray[x, y + 2].mType) { return(true); } return(false); }
public static void resetColors() { OBlock.resetColor(); IBlock.resetColor(); TBlock.resetColor(); JBlock.resetColor(); LBlock.resetColor(); SBlock.resetColor(); ZBlock.resetColor(); }
private void DiscardColors(OptionArgs args) { OBlock.resetColor(); IBlock.resetColor(); TBlock.resetColor(); JBlock.resetColor(); LBlock.resetColor(); SBlock.resetColor(); ZBlock.resetColor(); ColorData.saveColors(); }
private void Reset(OptionArgs args) { BlockType.textureAsset = "Game/Bricks/Cat-Eye Brick"; OBlock.resetColor(); IBlock.resetColor(); TBlock.resetColor(); JBlock.resetColor(); LBlock.resetColor(); SBlock.resetColor(); ZBlock.resetColor(); ColorData.saveColors(); }
void AddNeighbor(int iX, int iY, int iZ) { if (!IsInRange(iX, iY, iZ)) { return; } int iIndex = CalcBlockIndex(iX, iY, iZ); SBlock NeighborBlock = GetBlock(iIndex); ++NeighborBlock.iNeighbors; if (!NeighborBlock.bIsInUpdateList) { UpdateBlocks_.Add(iIndex); NeighborBlock.bIsInUpdateList = true; } }
void CompileVisibleSet() { VisibleBlocks_.Clear(); foreach (int iIndex in UpdateBlocks_) { if (!IsInRange(iIndex)) { continue; } SBlock Block = GetBlock(iIndex); if (IsOn(Block.bIsVisible, Block.iNeighbors)) { Block.bIsVisible = true; VisibleBlocks_.Add(iIndex); } else { Block.Reset(); if (BlockModels_[iIndex] != null) { BlockModels_[iIndex].GetComponent <Renderer>().enabled = false; } } Block.bIsInUpdateList = false; Block.iNeighbors = 0; } UpdateBlocks_.Clear(); foreach (int iVisibleIndex in VisibleBlocks_) { // enable block if (ShouldDraw(iVisibleIndex)) { UseBlock(iVisibleIndex); } else { UnShownBlockList_.Enqueue(iVisibleIndex); } } // Clean up Used Queues CleanUpBlocks(); }
BlockType randomize() { BlockType randomBlock; switch (random.Next(1, 8)) { case 1: randomBlock = new OBlock(); break; case 2: randomBlock = new IBlock(); break; case 3: randomBlock = new TBlock(); break; case 4: randomBlock = new LBlock(); break; case 5: randomBlock = new JBlock(); break; case 6: randomBlock = new SBlock(); break; case 7: randomBlock = new ZBlock(); break; default: randomBlock = new LBlock(); break; } randomBlock.load(Game.Content); return(randomBlock); }
SBlock GetBlock(int iIndex) { if (!IsInRange(iIndex)) { return(null); } //if (BlockMap_.TryGetValue(iIndex, out Block)) if (BlockMap_[iIndex] != null) { return(BlockMap_[iIndex]); } SBlock Block; Block = new SBlock(); //BlockMap_.Add(iIndex, Block); BlockMap_[iIndex] = Block; return(Block); }
/// <summary> /// Generates a random block /// </summary> /// <param name="block">A reference to the Block object that will be affected</param> private void GenerateBlock(ref Block block) { switch (random.Next(0, 7)) { case 0: block = new IBlock(); break; case 1: block = new LBlock(); break; case 2: block = new RLBlock(); break; case 3: block = new SBlock(); break; case 4: block = new SquareBlock(); break; case 5: block = new TBlock(); break; case 6: block = new ZBlock(); break; default: throw new ArgumentException("Bad block type!"); } }
void ResetGame() { // clean up game while (UseBlockList1_.Count > 0) { GameObject Block = UseBlockList1_.Dequeue(); GameObject.Destroy(Block.gameObject); } while (UseBlockList2_.Count > 0) { GameObject Block = UseBlockList2_.Dequeue(); GameObject.Destroy(Block.gameObject); } while (UnusedBlockQueue_.Count > 0) { GameObject Block = UnusedBlockQueue_.Dequeue(); GameObject.Destroy(Block.gameObject); } if (BlockModels_ != null) { foreach (GameObject Block in BlockModels_) { if (Block != null) { GameObject.DestroyObject(Block.gameObject); } } } UnusedBlockQueue_.Clear(); UseBlockList1_.Clear(); UseBlockList2_.Clear(); UnShownBlockList_.Clear(); //BlockMap_.Clear(); UpdateBlocks_.Clear(); VisibleBlocks_.Clear(); // start new game iMaxIndex_ = iXMax_ * iYMax_ * iZMax_; BlockMap_ = new SBlock[iMaxIndex_]; for (int iIndex = 0; iIndex < iMaxIndex_; ++iIndex) { BlockMap_[iIndex] = new SBlock(); } BlockModels_ = new GameObject[iMaxIndex_]; Application.targetFrameRate = 1; fBlockSize_ = 1; //bScaleWithBlockSize ? BlockModel.transform.localScale[0] //: 1f; iBlockQueueIndex_ = 1; int iInnerRadius = iXMax_ / 10; int iXMid = iXMax_ / 2; int iYMid = iYMax_ / 2; int iZMid = iZMax_ / 2; for (int iX = 0; iX < iXMax_; iX++) { for (int iY = 0; iY < iYMax_; ++iY) { for (int iZ = 0; iZ < iZMax_; ++iZ) { double dVal = Mathf.Sqrt(((iX - iXMid) * (iX - iXMid) + (iY - iYMid) * (iY - iYMid) + (iZ - iZMid) * (iZ - iZMid))); if (dVal > iInnerRadius) { continue; } int iIndex = CalcBlockIndex(iX, iY, iZ); if (!IsInRange(iIndex)) { continue; } SBlock Block = GetBlock(iIndex); if (!Block.bIsVisible) { Block.bIsVisible = true; VisibleBlocks_.Add(iIndex); } iTotalCount_++; } } } //CameraMove_.SetCenter(GetCenter()); //Vector3 Direction = transform.position - Camera.mainCamera.transform.position; //Camera.mainCamera.transform.localRotation.SetLookRotation(Direction.normalized); //Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, iYMax_ * fBlockSize_ / 2f, -iYMax_ * fBlockSize_ / 9f); //Camera.main.transform.localRotation = Quaternion.identity; //Camera.mainCamera.fieldOfView = iYMax_ / 1.5f; sXMax_ = iXMax_.ToString(); sYMax_ = iYMax_.ToString(); sZMax_ = iZMax_.ToString(); }
public int Execute(int rightSide, short key) { var fourBitsMasks = Enumerable.Range(0, 4).Select(i => 1 << i).Reverse().ToArray(); var expandedRightSide = PermutateBits(rightSide, fourBitsMasks, expandPBlock); var transformedBits = expandedRightSide ^ key; transformedBits = new SBlock().Compress(transformedBits); return PermutateBits(transformedBits, fourBitsMasks, straightPBlock); }