public bool AddBlockToCountry(CreateBlock block) { try { var country = _countryRepository.GetByIdAsync(block.CountryId); if (country == null) { throw new ApplicationException("This country is not available"); } var newBlock = new Block { BlockOwner = block.BlockOwner, BlockNumber = -1, //Will pull data from blockchain when update Axis = block.Axis, YAxis = block.YAxis, Status = Status.Pending, TxTran = block.TxTran }; country.TotalBlocks++; country.Status = Status.NewBlockAddedPending; country.Blocks.Add(newBlock); _countryRepository.Update(country); } catch (System.Exception) { throw; } return(true); }
internal void Split(CreateBlock createBlock) { int num = 2; ManifestBlock[] subBlocks = new ManifestBlock[num]; for (int j = 0; j < num; j++) { subBlocks[j] = createBlock(); } List <ManifestRecord> list = new List <ManifestRecord>(); Converter <ManifestRecord, ManifestRecord> converter = null; for (int i = 0; i < num; i++) { int index = (int)(i / (double)num * recordList.Count); int num4 = (int)((i + 1.0) / num * recordList.Count); if (converter == null) { converter = mr => mr.ReplaceBlock(subBlocks[i]); } subBlocks[i].recordList = recordList.GetRange(index, num4 - index) .ConvertAll(converter); ManifestRecord item = recordList[index].ReplaceIndirect(subBlocks[i].blockId); list.Add(item); subBlocks[i].SetDirty(); } recordList = list; SetDirty(); }
void Start() { tCamInitialPos = tCamera.position; createBlock = GetComponent <CreateBlock>(); Block[] bks = FindObjectsOfType <Block>();//疆場景景的Block元素加入於bks陣列 foreach (Block b in bks) { blocks.Add(b); } }
private void CreateBlock <TBlockType>(ContentReference parent, Action <TBlockType> build = null) where TBlockType : BlockData { var command = new CreateBlock( Fixture.GetContentType(typeof(TBlockType)), parent, IpsumGenerator.Generate(1, 3, false) ); if (build != null) { command.Build = p => build.Invoke((TBlockType)p); } _blocks.Add(command.Execute()); }
private void CreateBlock <TBlockType>(ContentReference parent, CultureInfo culture = null, Action <TBlockType> build = null) where TBlockType : BlockData { TBlockType block = default; if (Fixture.Cultures.Count == 0) { throw new InvalidOperationException("Need atleast one culture"); } List <CultureInfo> cultures = new List <CultureInfo>(Fixture.Cultures); if (culture != null) { cultures.Clear(); cultures.Add(culture); } foreach (var c in cultures) { if (block is null) { var command = new CreateBlock( Fixture.GetContentType(typeof(TBlockType)), parent, IpsumGenerator.Generate(1, 3, false) ); command.Culture = c; command.Build = CreateBuild(build); block = (TBlockType)command.Execute(); Add(block); continue; } if (build == null) { Update(block, c, null); continue; } Update((TBlockType)(BlockData)block, c, p => build.Invoke((TBlockType)(BlockData)p)); } }
public async Task <IActionResult> PurchaseBlock([FromBody] CreateBlock newBlock) { try { if (!ModelState.IsValid) { return(Json(new { IsSuccess = false, Message = "" })); } else { var currentUser = _userRepository.GetByIdAsync(_userAppContext.CurrentUserId); newBlock.BlockOwner = currentUser.WalletAddress.ToLower(); var blockCreated = _countryService.AddBlockToCountry(newBlock); return(Json(new { IsSuccess = blockCreated })); } } catch (Exception e) { return(Json(new { IsSuccess = false, Message = e.Message })); } }
void createGap(float delta) { print("Creating new block with delta: " + delta); // Kill all the children foreach (Transform child in dock.transform) { Destroy(child.gameObject); } // Destroy the script CreateBlock old_script = dock.GetComponent <CreateBlock>(); if (old_script != null) { Destroy(old_script); } // Add a new one :) CreateBlock script = dock.AddComponent <CreateBlock>(); script.x = delta; script.z = 0.15f; // Keep static, only vary x }
public CreateBlock(CreateBlock other) : base(other) { this.prefab = other.prefab; this.face = other.face; this.height = other.height; }
public CreateZipLine(CreateBlock other) : base(other) { }