public static bool CanAddBlockHere(BlockObject aBlock, Vector2Int aPos) { for (int x = aPos.x; x < aPos.x + aBlock.size.x; x++) { for (int y = aPos.y; y < aPos.y + aBlock.size.y; y++) { Vector2Int currentPos = new Vector2Int(x, y); // if block is out of bounds if (!GameUtil.IsInside(currentPos, Vector2Int.zero, BoardManager.Instance.levelData.boardSize)) { return(false); } // if block is blocked by another block or an entity foreach (BlockObject block in BoardManager.Instance.blockList) { if (block.IsInsideSelf(currentPos)) { return(false); } } foreach (MobObject mob in BoardManager.Instance.mobList) { if (mob.IsInsideSelf(currentPos)) { return(false); } } } } return(true); }
// returns a list of blocks selected when dragging down on a block public static List <BlockObject> SelectDown(BlockObject aRootBlock) { List <BlockObject> treeDownList = TreeDown(aRootBlock); List <BlockObject> selectDownList = new List <BlockObject>(treeDownList); foreach (BlockObject currentBlock in treeDownList) { List <BlockObject> currentBlockHangers = GetBlocksAbove(currentBlock); foreach (BlockObject hangerBlock in currentBlockHangers) { if (!treeDownList.Contains(hangerBlock)) { if (!IsConnectedToFixed(hangerBlock, treeDownList)) { selectDownList.Add(hangerBlock); foreach (BlockObject hangerConnectedBlock in GetBlocksConnected(hangerBlock, selectDownList)) { selectDownList.Add(hangerConnectedBlock); } } } } } return(selectDownList); }
protected void RenderObject(BlockObject obj, int x, int y) { foreach (Block b in obj.GetBlocks()) { RenderBlock(b, b.Point, x, y); } }
// returns all blocks connected to this rootBlock while ignoring blocks inside ignoreList public static List <BlockObject> GetBlocksConnected(BlockObject aRootBlock, List <BlockObject> aIgnoreList) { List <BlockObject> connectedBlocks = new List <BlockObject>(); List <BlockObject> ignoreListClone = new List <BlockObject>(aIgnoreList); // isRoot = true will ignore the root Block in the recursive function bool isRoot = true; GetBlocksConnectedRecursive(aRootBlock, ignoreListClone); return(connectedBlocks); void GetBlocksConnectedRecursive(BlockObject rBlock, List <BlockObject> ignoreListX) { if (isRoot == false) { ignoreListX.Add(rBlock); connectedBlocks.Add(rBlock); } isRoot = false; foreach (BlockObject aboveBlock in GetBlocksAbove(rBlock)) { if (!ignoreListX.Contains(aboveBlock)) { GetBlocksConnectedRecursive(aboveBlock, ignoreListX); } } foreach (BlockObject belowBlock in GetBlocksBelow(rBlock)) { if (!ignoreListX.Contains(belowBlock)) { GetBlocksConnectedRecursive(belowBlock, ignoreListX); } } } }
// returns whether or not rootBlock has a connection to a fixed block public static bool IsConnectedToFixed(BlockObject aRootBlock, List <BlockObject> aIgnoreList) { bool isConnectedToFixed = false; List <BlockObject> ignoreListClone = new List <BlockObject>(aIgnoreList); IsConnectedToFixedRecursive(aRootBlock, ignoreListClone); return(isConnectedToFixed); void IsConnectedToFixedRecursive(BlockObject rBlock, List <BlockObject> rIgnoreList) { rIgnoreList.Add(rBlock); // OK so the reason why this uses BlockTypeEnum.FIXED is because // a block with state = BlockStateEnum.FIXED is not always gonna be fixed // so this we need to use BlockTypeEnum.FIXED or else floaters will happen if (rBlock.type == BlockTypeEnum.FIXED) { isConnectedToFixed = true; return; } foreach (BlockObject aboveBlock in GetBlocksAbove(rBlock)) { if (!rIgnoreList.Contains(aboveBlock)) { IsConnectedToFixedRecursive(aboveBlock, rIgnoreList); } } foreach (BlockObject belowBlock in GetBlocksBelow(rBlock)) { if (!rIgnoreList.Contains(belowBlock)) { IsConnectedToFixedRecursive(belowBlock, rIgnoreList); } } } }
public void Can_round_trip_with_transaction_objects() { _types.Value.TryAdd(0, typeof(Transaction)); var transaction = new Transaction { Id = $"{Guid.NewGuid()}" }; var blockObject = new BlockObject { Data = transaction }; blockObject.Hash = blockObject.ToHashBytes(_hash.Value); var block = new Block { Nonce = 1, PreviousHash = "rosebud".Sha256(), Timestamp = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Objects = new List <BlockObject> { blockObject } }; block.MerkleRootHash = block.ComputeMerkleRoot(_hash.Value); block.Hash = block.ToHashBytes(_hash.Value); block.RoundTripCheck(_hash.Value, _types.Value); }
public bool CheckPos(Vector2Int aOffset) { bool isValid = true; for (int x = this.entity.pos.x + aOffset.x; x < this.entity.pos.x + aOffset.x + this.entity.size.x; x++) { for (int y = this.entity.pos.y + aOffset.y; y < this.entity.pos.y + aOffset.y + this.entity.size.y; y++) { Vector2Int checkPos = new Vector2Int(x, y); BlockObject maybeABlock = BoardManager.GetBlockOnPosition(checkPos); MobObject maybeAMob = BoardManager.GetMobOnPosition(checkPos); if (maybeABlock != null) { return(false); } if (maybeAMob != null) { if (maybeAMob == this.entity) { } else { return(false); } } } } return(isValid); }
private void addPageText(PageObject page, TextObject text, BlockObject block, TextAttrObject attr, uint wExtraTagId, uint width, uint height) { // Add our TextObject m_Book.Objects.Add(text); // Refer the block to the text object block.ObjectLink = text.ID; ObjectInfoObject objInfo = new ObjectInfoObject(GetNextObjId()); objInfo.addLayoutTags(block.ID); if (wExtraTagId != 0x0) { objInfo.addLayoutTags(wExtraTagId); } m_Book.Objects.Add(objInfo); page.InfoObj = objInfo; // Now add out objects to the page page.Children.Add(attr); page.Children.Add(text); page.Children.Add(block); page.StreamTags.Add(new UInt32Tag(TagId.Link, block.ID)); }
private Block CreateBlock() { var transaction = new Transaction { Id = $"{Guid.NewGuid()}" }; var blockObject = new BlockObject { Data = transaction }; blockObject.Hash = blockObject.ToHashBytes(HashProvider); var block = new Block { Nonce = 1, PreviousHash = "rosebud".Sha256(), MerkleRootHash = HashProvider.DoubleHash(blockObject.Hash), Timestamp = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Objects = new List <BlockObject> { blockObject } }; block.MerkleRootHash = block.ComputeMerkleRoot(HashProvider); block.Hash = block.ToHashBytes(HashProvider); return(block); }
public void Can_round_trip_with_transaction_objects() { _types.Value.TryAdd(0, typeof(Transaction)); var transaction = new Transaction { Id = $"{Guid.NewGuid()}" }; var blockObject = new BlockObject { Data = transaction, Hash = null, }; var block = new Block { Nonce = 1, PreviousHash = "rosebud".Sha256(), Timestamp = DateTimeOffset.UtcNow.Ticks, Objects = new List <BlockObject> { blockObject } }; block.Hash = block.ToHashBytes(_hash.Value); block.RoundTripCheck(_hash.Value, _types.Value); }
/// <summary> /// Updates the panel display. Will select the good ui display function /// according to the type of object analyzed. /// </summary> void EngagePanelDisplay() { if (AnalyzedObject) { AnalyzerToolContainer.SetActive(true); if (colBroadcast.ObjType == ColliderBroadcast.ObjectType.Player) { // the analyzed object is a player. set the UI as such. analyzedPlayerScript = AnalyzedObject.GetComponent <PlayerObject> (); analyzedPlayerScript.ToggleSelection(true); // send cmds to serv for data update PlayerAnalyzeServerUpdate(); // Delayed function call, set the UI display. Invoke("UpdatePlayerAnalyzerDisplay", 0.1f); } else if (colBroadcast.ObjType == ColliderBroadcast.ObjectType.Block) { // the analyzed object is a ground block. set the UI as such. analyzedBlockScript = AnalyzedObject.GetComponent <BlockObject> (); analyzedBlockScript.ToggleSelection(true); // send cmds to serv for data update BlockAnalyzeServerUpdate(); // Delayed function call, set the UI display. Invoke("UpdateBlockAnalyzerDisplay", 0.1f); } } }
static public EasyBlock CreateBlock(GameObject parent) { var block = ScriptableObject.CreateInstance <EasyBlock>(); block.name = parent.name; foreach (Transform child in parent.transform) { var obj = new BlockObject(child.name); #if UNITY_2018_3_OR_NEWER if (PrefabUtility.IsPartOfAnyPrefab(child.gameObject)) #else if (PrefabUtility.GetPrefabType(child.gameObject) != PrefabType.None) #endif { #if UNITY_2018_2_OR_NEWER obj.GameObject = PrefabUtility.GetCorrespondingObjectFromSource(child.gameObject) as GameObject; #else obj.GameObject = PrefabUtility.GetPrefabParent(child.gameObject) as GameObject; #endif obj.LocalPosition = child.localPosition; obj.LocalRotation = child.localRotation; obj.LocalScale = child.localScale; block.ToDictionary().Add(child.GetSiblingIndex(), obj); } } return(block); }
public void FixBlocksBelowEntity() { foreach (BlockObject block in this.tempFixedBlockList) { block.ResetColor(); block.isUnderEntity = false; block.state = BlockStateEnum.ACTIVE; } this.tempFixedBlockList = new List <BlockObject>(); HashSet <BlockObject> blocksUnderEntities = new HashSet <BlockObject>(); foreach (MobObject mobObject in mobList) { if (!mobObject.canSelectUnder) { for (int x = mobObject.pos.x; x < mobObject.pos.x + mobObject.size.x; x++) { BlockObject maybeABlock = GetBlockOnPosition(new Vector2Int(x, mobObject.pos.y - 1)); if (maybeABlock != null && maybeABlock.state == BlockStateEnum.ACTIVE) { maybeABlock.isUnderEntity = true; maybeABlock.state = BlockStateEnum.FIXED; blocksUnderEntities.Add(maybeABlock); } } } } this.tempFixedBlockList = blocksUnderEntities.ToList(); }
public RoundResult(Field start, Field end, BlockObject obj, int[] removedLines, int erodedObjectCells) { this.FieldAtStart = start; this.FieldAtEnd = end; this.Object = obj; this.RemovedLines = removedLines; this.ErodedObjectCells = erodedObjectCells; }
void OnCollisionExit(Collision coll) { if (coll.transform.tag == "Block") { blockStand = null; jump = false; } }
public Block(World world, int x, int y, float value, int area) { this.world = world; this.x = x; this.y = y; this.value = value; this.BlockObject = null; this.mapArea = area; }
public void InitData(bool poolreturn = true) { if (poolreturn) { blockobj.gameObject.transform.parent = Game.instance.gameObject.transform; } m_renderer = null; blockobj = null; }
public void DestroyBlock(BlockObject block) { GameObject gameObject; placedBlocks.TryRemove(block, out gameObject); soundEffectManager.PlaySoundEffect(block.blockBreak, gameObject.transform.position, .05f, 1f, 0f, 2f); Destroy(gameObject); }
private void Start() { _blockObject = GetComponent <BlockObject>(); //绑定块的点击事件 blockClick = UISceneWidget.Get(gameObject); if (blockClick != null) { blockClick.PointerDown += BlockOnPointerDown; blockClick.PointerUp += BlockOnPointerUp; } }
public BBeB ParseHTML(HtmlDocument doc, BindingParams bindingParams, TocEntry tocEntries) { m_Book = new BBeB(); byte[] thumb = File.ReadAllBytes(bindingParams.IconFile); setHeaderValues(thumb.Length); m_Book.MetaData = bindingParams.MetaData; m_Book.ThumbnailData = thumb; // Create our default Attribute objects createDefaultAttributeObjects(BBeB.ReaderPageWidth, BBeB.ReaderPageHeight); // cover page works, but it's ugly createCoverPage(); m_CurrentPage = createPage(); PageObject firstBookPage = m_CurrentPage; m_StartReadingBlock = null; m_StartReadingPage = null; addBookPage(m_CurrentPage); IHTMLDocument2 dom = (IHTMLDocument2)doc.DomDocument; IHTMLDOMNode domNode = (IHTMLDOMNode)dom.body; IHTMLDOMChildrenCollection children = (IHTMLDOMChildrenCollection)domNode.childNodes; TextBlockBuilder tbBuilder = new TextBlockBuilder(GetNextObjId(), m_CharMapper); foreach (IHTMLDOMNode child in children) { tbBuilder = ParseDomNode(child, tbBuilder); } PrintHTMLElementChildren(children); // If we have any text left then add it FlushTextToBlock(m_CurrentPage, tbBuilder, m_MainBodyTextAttr); finalizePage(m_CurrentPage); // Create the table of contents createTocPage(firstBookPage, tocEntries); m_TocObject.AddEntry(m_StartReadingPage.ID, m_StartReadingBlock.ID, "Start Reading"); // Also serialize the table of contents object m_TocObject.Serialize(); finalizeBook(); return(m_Book); }
static Tesselator() { Cube = new GameObject(); Cube.Shader = GraphicsLoader.TextureShader; Cube.Mesh = GraphicsLoader.Cube; BlockObject = new BlockObject(); BlockObject.Shader = GraphicsLoader.TextureShader; BlockObject.Mesh = new CubeMesh(Cube.Mesh.Vertices, Cube.Mesh.UVs, Cube.Mesh.Normals); BlockObject.Texture = TextureMap.GetTexture("dirt"); }
public int GetBlockIdByObject(BlockObject block) { if (_idList.ContainsKey(block)) { return(_idList[block]); } else { Debug.LogError($"No Such block : {block} | {this.ToString()}"); return(-1); } }
public void Start() { pb = GetComponent <PlayerBase>(); swingobject = GetComponentInChildren <SwingObject>(); swingobject.Setup(basicAttackDamage, GetComponent <CapsuleCollider>(), pb); swingobject.gameObject.SetActive(false); blockobject = GetComponentInChildren <BlockObject>(); blockobject.gameObject.SetActive(false); pb.animator.SetInteger("AttackState", -1); }
/// <summary> /// 不拖动时,也检测特殊块的形成 /// </summary> internal void ExternalTestingpecialBlock(BlockObject blockObject) { //赋值正确块的blockObject parentCallingScript = blockObject; //重新找比对用邻居 AssignLRUD(); if ((blockObject.name == left1 && blockObject.name == left2) || (blockObject.name == left1 && blockObject.name == right1) || (blockObject.name == right1 && blockObject.name == right2) || (blockObject.name == up1 && blockObject.name == up2) || (blockObject.name == up1 && blockObject.name == down1) || (blockObject.name == down1 && blockObject.name == down2)) { // 特殊块形成的方法 CheckForSpecialBlockFormation(blockObject.name); } }
/// <summary> /// 是否可以移动 /// </summary> /// <param 反向ID="dir"></param> /// <returns></returns> internal bool isMovePossibleInDirection(int dir) { parentCallingScript = this; if (adjacentItems[dir]) { if (adjacentItems[dir].JustCheckIfCanBrust(name, dir)) { return(true); } } return(false); }
public void BlockSelectorItemOnPointerDown(BlockData aBlockGhostData) { if (editMode == EditModeEnum.ADD && selectionState == SelectionStateEnum.DEFAULT) { print("EditorManager - PreviewBlock"); this.blockGhost = Instantiate(BoardManager.Instance.blockMaster); this.blockGhost.Init(aBlockGhostData); this.selectionState = SelectionStateEnum.HOLDING; } else { throw new System.Exception("Block selector item activated but editMode != ADD"); } }
public bool FanBelowMe() { // TODO check if above a fan // print("IFallable - checking if above a fan"); for (int x = this.entity.pos.x; x < this.entity.pos.x + this.entity.size.x; x++) { bool colIsBlocked = false; for (int y = this.entity.pos.y - 1; y >= 0; y--) { if (colIsBlocked == false) { Vector2Int checkPos = new Vector2Int(x, y); EntityObject maybeAEntity = BoardManager.GetEntityOnPosition(checkPos); if (maybeAEntity != null) { // print("IFallable - encountered entity. checking if it's a fan or not" + checkPos); if (maybeAEntity is BlockObject) { print("IFallable - entity is a block" + checkPos); BlockObject maybeABlock = maybeAEntity as BlockObject; if (maybeABlock.type == BlockTypeEnum.FAN) { print("IFallable - entity is a fan" + checkPos); return(true); } else { print("IFallable - entity is not a fan. colIsBlocked" + checkPos); colIsBlocked = true; } } else { print("IFallable - entity is not a block. colIsBlocked" + checkPos); colIsBlocked = true; } } else { // print("IFallable - nothing at this location"); } } else { // print("Ifallable - col is already blocked"); } } } return(false); }
//this gets called by a block object which wants to know which lasers are hitting it public List <Laser> GetInputLasers(BlockObject blockObject) { List <Laser> lasersToReturn = new List <Laser>(); foreach (Laser laser in lasers) { if (laser.destinationBlock == blockObject) { lasersToReturn.Add(laser); } } return(lasersToReturn); }
public override void UseItemStart(ItemOperationInfo info) { Pack pack = info.invoker.GetComponent <Pack>(); BlockObject bo = BlockFactory.Instance.GetBlockObject(placedBlockId); Vector3Int pos = new Vector3Int( Mathf.FloorToInt(info.operationPosition.x), Mathf.FloorToInt(info.operationPosition.y), 0); if (pack.SelectedItem.count > 0 && bo.SetBlock(pos)) { pack.ConsumeItemAtIndex(pack.SelectedItemIndex, 1); } }
// Use this for initialization void Start() { this.block = this.GetComponent<BlockObject>(); if ( block != null ) { var mesh = this.GetComponentInChildren<MeshFilter>(); if ( meshLookup.ContainsKey(mesh.sharedMesh) == false ) { SubMesh[] subMesh = new SubMesh[6]; Vector3[] directions = new Vector3[]{ Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back}; for ( int i = 0; i < directions.Length; i++ ) { subMesh[i] = new SubMesh(); List<int> triangles = new List<int>(); for ( int t = 0; t < mesh.sharedMesh.triangles.Length; t+=3) { int indexA = mesh.sharedMesh.triangles[t+0]; int indexB = mesh.sharedMesh.triangles[t+1]; int indexC = mesh.sharedMesh.triangles[t+2]; Vector3 a = mesh.sharedMesh.vertices[indexA]; Vector3 b = mesh.sharedMesh.vertices[indexB]; Vector3 c = mesh.sharedMesh.vertices[indexC]; Vector3 normal = Vector3.Cross( (c-a), (c-b)); float angle = Vector3.Angle(directions[i], normal); if ( Mathf.Approximately( angle, 0) ) { triangles.Add( indexA); triangles.Add( indexB); triangles.Add( indexC); } } subMesh[i].triangles = triangles.ToArray(); meshLookup[mesh.sharedMesh] = subMesh; } } SubMesh[] submesh = meshLookup[mesh.sharedMesh]; mesh.mesh.triangles = submesh[4].triangles; } }
private void ConnectBlock(BlockObject block, BBeB book) { UInt32Tag linkTag = (UInt32Tag)block.FindFirstTag(TagId.Link); if (linkTag == null) { throw new InvalidBookException("Can't find link for block " + block.ID); } block.LinkObj = book.FindObject((ushort)linkTag.Value); if (block.LinkObj == null) { throw new InvalidBookException("Can't find object id " + linkTag.Value); } }
public override void Start() { base.Start (); Projectile projectile = Projectile.GetComponentsInChildren<Projectile>(true)[0]; if ( projectile.ProjectilePrefab != null ) { projectileBlock = projectile.ProjectilePrefab.GetBlock(); PreviewBlockInstance = (GameObject)Instantiate(projectileBlock.PreviewBlock); PreviewBlockInstance.SetActive(false); Util.DestroyAllColliders(PreviewBlockInstance); } }