Ejemplo n.º 1
0
        /// <summary>
        /// Called when the Block was detached from a Hand, check if detachement from Hand inidcates
        /// an attachment to an other Block
        /// </summary>
        /// <param name="hand"></param>
        public void OnDetachedFromHand(Hand hand)
        {
            holdingHand = null;

            //Send message to Blocks in Structure that Stucture detached from Hand
            blockCommunication.SendMessageToConnectedBlocks("OnIndirectDetachedFromHand");

            //Check if any Block in the Structure is collding with an other Block
            GameObject block = blockCommunication.FindFirstCollidingBlock();

            //no Block is colliding, Structure is free
            if (block == null)
            {
                return;
            }

            //One of the Block is colliding, check if it collding on the Groove- or Tap
            block.GetComponent <AttachHandHandler>().GrooveOrTapHit(out List <CollisionObject> currentCollisionObjects, out OTHER_BLOCK_IS_CONNECTED_ON connectedOn);

            //The collding Block is NOT indirectly attached to a Floor plate, call the AttachHandHandler of the collding Block
            if (!currentCollisionObjects[0].CollidedBlock.GetComponent <BlockCommunication>().IsIndirectlyAttachedToFloor())
            {
                block.GetComponent <AttachHandHandler>().MatchRotationWithBlock(currentCollisionObjects, connectedOn);
            }

            //The colliding Block IS indirectly attached to the Floor, call FloorHandler to connect the Structure to the Floor
            else if (currentCollisionObjects[0].CollidedBlock.GetComponent <BlockCommunication>().IsIndirectlyAttachedToFloor())
            {
                GetComponent <AttachFloorHandler>().AttachToFloor();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attach the Block to the Floor plate or Block that is indirectly connected to the Floor plate
        /// </summary>
        public void AttachToFloor()
        {
            //Find a Block that is collding
            GameObject block = blockCommunication.FindFirstCollidingBlock();

            if (block != null)
            {
                //Check if the Block is collding with a Groove or a Tap
                block.GetComponent <AttachFloorHandler>().GrooveOrTapHit(out List <CollisionObject> currentCollisionObjects, out OTHER_BLOCK_IS_CONNECTED_ON connectedOn);

                //Match the Rotation of the Block with the collding one
                block.GetComponent <AttachFloorHandler>().MatchRotationWithCollidingBlock(currentCollisionObjects, connectedOn);
            }
        }