// Called by child collider when hit player tank public void Assemble(TetrisTank tank) { if (!assembled) { assembled = true; m_fallingLogic.enabled = false; // activate weapon coroutine var tankRigidBody = tank.gameObject.GetComponent <Rigidbody>(); int numChildren = transform.childCount; Transform[] childBlocks = new Transform[numChildren]; for (int i = 0; i < numChildren; i++) { childBlocks[i] = transform.GetChild(i); //childBlocks[i].SendMessage("TransformToTankBlock"); childBlocks[i].GetComponent <TetrisBlock>().TransformToTankBlock(tankRigidBody); } tank.UpdateCenterOfMass(childBlocks); Destroy(gameObject); } }
// Called by child collider when hit player tank public void Assemble(TetrisTank tank) { if (!assembled) { assembled = true; //m_fallingLogic.enabled = false; // fit to tank grid system tank.SnapToGrid(transform); ///////////////// var tankRigidBody = tank.gameObject.GetComponent <Rigidbody2D>(); tank.UpdateCenterOfMass(childBlocks); tank.BuildConnection(childBlocks, assembleHitBlockId); for (int i = 0; i < childBlocks.Length; i++) { // activate weapon coroutine childBlocks[i].TransformToTankBlock(tankRigidBody); } Destroy(gameObject); } }