public void ChainResizeDown() { ResizeObjectMesh(); foreach (var sc in myCodeBlock.GetSnapColliderGroup().SnapColliderSet) { CodeBlock cb = sc.Value.MyCodeBlockArg; cb?.transform.ResetCodeBlockSize(); cb?.GetCodeBlockObjectMesh().Recenter(); cb?.GetCodeBlockObjectMesh().ChainResizeDown(); } }
private void SnapToParentCenter(CodeBlock collidedCodeBlock, Transform parentTransform) { Vector3 centerPos = collidedCodeBlock.GetCodeBlockObjectMesh().GetCenterPosition(); centerPos.x = centerPos.x / parentTransform.localScale.x; collidedCodeBlock.transform.SnapToParent(parentTransform, SnapPosition - centerPos); }
// TODO: humanDidIt is such a hack public void DoSnapAction(CodeBlock myCodeBlock, CodeBlock collidedCodeBlock, bool humanDidIt = true) { Transform parentTransform = transform.parent; myCodeBlock.SetArgumentBlockAt(collidedCodeBlock, myArgumentPosition, humanDidIt); Vector3 centerPos = collidedCodeBlock.GetCodeBlockObjectMesh().GetCenterPosition(); centerPos.x = centerPos.x / parentTransform.localScale.x; collidedCodeBlock.transform.SnapToParent(parentTransform, snapPosition - centerPos); }
// Private methods, reconsider if you need to make these public private void AddNewArgumentAt(CodeBlock newArgumentCodeBlock, int position, bool humanDidIt) { GetArgListCodeBlocks()[position] = newArgumentCodeBlock; if (newArgumentCodeBlock != null) { if (humanDidIt) { LoggingManager.instance.UpdateLogColumn(SnapLoggingManager.GetSnapToColName(), string.Join("", "Add ", argList[position].name, " to ", myCodeBlock.name, " at ", position.ToString())); } AudioManager.instance.PlaySoundAtObject(gameObject, AudioManager.snapAudioClip); myCodeBlock.GetCodeBlockObjectMesh().ResizeChain(); } }
public void Recenter() { Transform parentTransform = GetMyCodeBlock().transform.parent; if (parentTransform == CodeBlockManager.instance.transform) { return; } Vector3 centerPos = myCodeBlock.GetCodeBlockObjectMesh().GetCenterPosition(); SnapCollider sc = parentTransform.GetChild(0).GetComponent <SnapCollider>(); centerPos.x = centerPos.x / parentTransform.localScale.x; // this is on object mesh.... myCodeBlock.transform.SnapToParent(parentTransform, sc.SnapPosition - centerPos); }
public void ResizeChain() { // resize up CodeBlock parentBlock = GetMyCodeBlock().FindParentCodeBlock(); if (parentBlock != null) { ResizeObjectMesh(); parentBlock.GetCodeBlockObjectMesh().ResizeChain(); } else { ChainResizeDown(); } }
private void RemoveCurrentBlockArg() { if (HasCodeBlockArgAttached()) { CodeBlock tmpargBlock = MyCodeBlockArg; if (MyCodeBlockArg.GetCodeBlockSnap() != CodeBlockSnap.CurrentlyDraggingCodeBlockSnap) { MyCodeBlockArg.transform.localPosition = MyCodeBlockArg.transform.localPosition + new Vector3(0.25f, 1.1f, 1.25f); } tmpargBlock.transform.SnapToCodeBlockManager(); tmpargBlock.GetCodeBlockObjectMesh().ResizeChain(); // need to resize myself as well MyCodeBlock.GetCodeBlockObjectMesh().ResizeChain(); // somehow has hori issue on unsnap, not resizing its parents? AudioManager.instance.PlaySoundAtObject(MyCodeBlock.transform, AudioManager.popAudioClip); // TODO: probably needs a log } }