public virtual void StartDragging(GameObject target) { if (IsDraggable) { //StartDragging(HydraController.Instance.GetHand(m_hand)); if (!HydraController.Instance.IsHandDragging(m_hand)) { //Clone instrument here if (IsCloneable) { BaseAttachment attach = UIFactory.CreateGhostDragger(this); attach.StartDragging(HydraController.Instance.GetHand(m_hand)); } else { if (IsDragging) { StopDragging(); } SetIsDragging(true); Undock(); FixedJoint joint = gameObject.AddComponent <FixedJoint>(); joint.connectedBody = target.GetComponent <Rigidbody>(); rigidbody.isKinematic = false; HydraController.Instance.SetHandDragging(m_hand, this); } } } }
/* * Check if we're inside an object */ protected void CheckForObjectCollision() { m_heldObject = HydraController.Instance.HandTarget(m_hand, ProximityType.INSTRUMENT_INTERIOR, m_mode); if (m_heldObject != null) { BaseAttachment attach = m_heldObject.GetComponent <BaseAttachment>(); if (attach != null) { if (attach.respondsToToolMode(m_mode)) { //m_gestureState = GestureState.INTERIOR; m_attachment = attach; m_toolHandState = BaseTool.HandState.HOLDING; m_attachment.SetToolMode(m_mode); m_attachment.SetActiveHand(m_hand); if (mode == ToolMode.IDLE) { m_attachment.StartHover(); } } } } }
public override bool AddDockableAttachment(BaseAttachment attach) { if (base.AddDockableAttachment(attach)) { //attach.rigidbody.velocity = Vector3.zero; attach.rigidbody.isKinematic = true; InstrumentAttachment instrument = attach as InstrumentAttachment; attach.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.PRIMARY, BaseTool.ToolMode.GRABBING }); instrument.EnableControls(); instrument.SetCloneable(false); GameObject volumetric = UIFactory.CreateVolumetricCylinder(); volumetric.transform.position = new Vector3(attach.transform.position.x, m_volumetricYOffset, attach.transform.position.z); volumetric.transform.parent = transform; iTween.ColorTo(volumetric, iTween.Hash("color", new Color(1.0f, 1.0f, 1.0f, 0.2f), "time", 0.8f)); m_volumetrics[instrument] = volumetric; PlaceObjects(); //iTween.MoveTo(attach.gameObject, iTween.Hash("position", transform.localPosition, "uselocal", true )); return(true); } return(false); }
void Awake() { m_attach = GetComponent <BaseAttachment>(); m_frameComponents = new List <GameObject>(); m_outlineFrameComponents = new List <GameObject>(); m_gridColumns = new List <GameObject>(); m_gridRows = new List <GameObject>(); for (int i = 0; i < m_guiPanels.childCount; i++) { m_frameComponents.Add(m_guiPanels.GetChild(i).gameObject); } for (int i = 0; i < m_selectGuiPanels.childCount; i++) { m_outlineFrameComponents.Add(m_selectGuiPanels.GetChild(i).gameObject); } m_lastWidth = m_frameWidth; m_lastHeight = m_frameHeight; if (m_hasGrid) { CreateGrid(m_numGridRows, m_numGridColumns); } if (m_label != null) { SetLabel(m_sliderLabel); m_label.transform.localPosition = m_frameOffset * 2.0f; } }
public GameObject GetClosestObjectInList(List <GameObject> targetList, GameObject target, BaseTool.ToolMode mode) { float closestDistance = -1.0f; GameObject closestObject = null; if (targetList != null && target != null) { foreach (GameObject obj in targetList) { if (obj != null) { float dist = Vector3.Distance(obj.transform.position, target.transform.position); if (dist < closestDistance || closestDistance < 0) { BaseAttachment attach = obj.GetComponent <BaseAttachment>(); if (attach != null) { if (attach.respondsToToolMode(mode)) { closestDistance = dist; closestObject = obj; } } } } } } return(closestObject); }
/* * Creates a training point at a position or transform location */ //public RBFTrainingAttachment CreateTrainingPoint(){ // RBFTrainingAttachment training = UI.UIFactory.CreateRBFSphereTraining(); // training.owner = this; // training.transform.position = transform.position; // training.transform.localScale = transform.localScale; // training.transform.parent = transform; // foreach(RBFPlugAttachment plug in m_plugs) // training.StorePlugValue(plug); // m_trainingPoints.Add(training); // ResetRBF(); // return training; //} public override bool AddDockableAttachment(BaseAttachment attach) { if (base.AddDockableAttachment(attach)) { attach.rigidbody.isKinematic = true; RBFTrainingAttachment rbfAttach = attach as RBFTrainingAttachment; rbfAttach.owner = this; rbfAttach.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.PRIMARY, BaseTool.ToolMode.GRABBING }); rbfAttach.SetCloneable(false); rbfAttach.SetIsDraggable(true); rbfAttach.SetIsDockable(true); foreach (RBFPlugAttachment plug in m_plugs) { rbfAttach.StorePlugValue(plug); } SetSelectedtraining(rbfAttach); return(true); } return(false); }
public override void RemoveDockableAttachment(BaseAttachment attach) { base.RemoveDockableAttachment(attach); attach.rigidbody.isKinematic = false; CalculateDisplayedItems(); PlaceObjects(); }
public virtual void Undock() { if (m_dockedInto != null) { m_dockedInto.RemoveDockableAttachment(this); m_dockedInto = null; } }
public void InstrumentControlsAreVisible(BaseAttachment attach) { if (m_activeAttachment != null && attach != m_activeAttachment) { m_activeAttachment.HideControls(); } m_activeAttachment = attach; }
public virtual void RemoveDockableAttachment(BaseAttachment attach) { while (m_childDockables.Contains(attach)) { m_childDockables.Remove(attach); } attach.transform.parent = null; }
public void SetHandDragging(BaseTool.ToolHand hand, BaseAttachment target) { if (hand == BaseTool.ToolHand.LEFT) { m_leftHandDragTarget = target; } m_rightHandDragTarget = target; }
public virtual bool IsInDockingRange(BaseAttachment attach, float range) { if (attach == null) { return(false); } return((Vector3.Distance(transform.position, attach.transform.position) < range) ? true : false); }
/* * Dockable object modifiers */ public virtual void DockInto(BaseAttachment attach) { attach.AddDockableAttachment(this); m_dockedInto = attach; m_dockedIntoLast = attach; if (IsDraggable) { SetIsDragging(false); } }
public ClipCubeHolder FindAttachmentHolder(BaseAttachment attach) { foreach (ClipCubeHolder holder in m_cubeHolders) { if (holder.attach == attach) { return(holder); } } return(null); }
public override void RemoveDockableAttachment(BaseAttachment attach) { base.RemoveDockableAttachment(attach); attach.transform.parent = null; ClipCubeHolder holder = FindAttachmentHolder(attach); if (holder != null) { holder.attach = null; } }
protected HttpResponseMessage GetDownloadResponse(string root, BaseAttachment attachment) { var response = new HttpResponseMessage(HttpStatusCode.OK); var filePath = Path.Combine(root, attachment.FileName); var fileStream = new FileStream(filePath, FileMode.Open); response.Content = new StreamContent(fileStream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentDisposition.FileName = attachment.OriginalFileName; return(response); }
public override void RemoveDockableAttachment(BaseAttachment attach) { base.RemoveDockableAttachment(attach); attach.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.GRABBING }); Destroy(m_volumetrics[attach]); attach.DisableControls(); attach.rigidbody.isKinematic = false; PlaceObjects(); }
public override bool AddDockableAttachment(BaseAttachment attach) { SliderAttachment slider = attach as SliderAttachment; slider.SetCloneable(false); slider.SetIsDraggable(true); slider.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.GRABBING }); slider.DockInto(m_paramscroller); //iTween.MoveTo(slider.gameObject, iTween.Hash("position", transform.position, "time", 0.5f, "islocal", true)); //iTween.RotateTo(slider.gameObject, iTween.Hash("rotation", transform.rotation, "time", 0.5f)); return(true); }
/* * Tool exit state */ public override void TransitionOut() { if (m_attachment != null) { LeavingProximity(); if (HydraController.Instance.IsHandDragging(m_hand)) { HydraController.Instance.GetHandDragging(m_hand).StopDragging(); } m_attachment.Gesture_Exit(); } m_heldObject = null; m_attachment = null; }
public override void RemoveDockableAttachment(BaseAttachment attach) { base.RemoveDockableAttachment(attach); RBFTrainingAttachment rbfAttach = attach as RBFTrainingAttachment; rbfAttach.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.GRABBING }); foreach (RBFPlugAttachment plug in m_plugs) { rbfAttach.RemovePlugValue(plug); } attach.rigidbody.isKinematic = false; }
public override bool AddDockableAttachment(BaseAttachment attach) { if (base.AddDockableAttachment(attach)) { ClipCubeHolder holder = FindClosestHolder(attach.transform.position); if (holder.attach == null) { attach.SetCloneable(false); holder.attach = attach; attach.transform.parent = holder.placeholder; iTween.MoveTo(attach.gameObject, iTween.Hash("position", Vector3.zero, "islocal", true, "time", 0.5f)); attach.transform.rotation = holder.placeholder.rotation; return(true); } } return(false); }
public override bool AddDockableAttachment(BaseAttachment attach) { if (base.AddDockableAttachment(attach)) { CalculateDisplayedItems(); attach.transform.parent = m_controlHolder.transform; //attach.transform.localPosition = new Vector3(0.0f, m_childDockables.Count * attach.interiorTrigger.GetSize().y, 0.0f); attach.transform.localRotation = Quaternion.identity; attach.transform.localScale = new Vector3(m_itemScale, m_itemScale, m_itemScale); m_lastAttachHeight = attach.interiorTrigger.GetSize().y + m_itemSpacing; m_lastAttachWidth = attach.interiorTrigger.GetSize().x; PlaceObjects(); UpdateColliders(new Vector3(m_lastAttachWidth * 0.5f, (m_upperVisibleBounds - m_lowerVisibleBounds) * 0.5f, 0.0f), new Vector3(m_lastAttachWidth, m_upperVisibleBounds - m_lowerVisibleBounds, m_collisionDepth)); return(true); } return(false); }
public virtual void DockIntoClosest() { GameObject[] docks = GameObject.FindGameObjectsWithTag("ParentIsADock"); BaseAttachment closestValidDock = null; float closestDist = 0.0f; foreach (GameObject dockTag in docks) { BaseAttachment dockAttach = dockTag.transform.parent.GetComponent <BaseAttachment>(); if (dockAttach.DockAcceptsType(this.GetType())) { if (closestValidDock == null) { closestDist = Vector3.Distance(dockAttach.transform.position, transform.position); closestValidDock = dockAttach; } float dist = Vector3.Distance(dockAttach.transform.position, transform.position); if (dist < closestDist) { closestValidDock = dockAttach; closestDist = dist; } } } if (closestValidDock != null) { if (IsInDockingRange(closestValidDock, closestValidDock.dockingRange)) { DockInto(closestValidDock); } else { Floating(); } } else { Floating(); } }
/* * Dock modifiers */ public virtual bool AddDockableAttachment(BaseAttachment attach) { if (m_childDockables == null) { m_childDockables = new List <BaseAttachment>(); } if (DockAcceptsType(attach.GetType())) { m_childDockables.Add(attach); attach.transform.parent = transform; return(true); } else { Debug.LogError(this + " can't dock with a " + attach.GetType()); } return(false); }
public static BaseAttachment CreateGhostDragger(BaseAttachment attach) { BaseAttachment ghostAttach = null; if (attach.GetType() == typeof(SliderAttachment)) { SliderAttachment slider = attach as SliderAttachment; ghostAttach = UIFactory.CreateSlider(slider.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT); } else if (attach.GetType() == typeof(ClipButtonAttachment)) { ClipButtonAttachment clipButton = attach as ClipButtonAttachment; ghostAttach = UIFactory.CreateClipButton(clipButton.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT); } else if (attach.GetType() == typeof(ClipCubeAttachment)) { ClipCubeAttachment cubeButton = attach as ClipCubeAttachment; ghostAttach = UIFactory.CreateClipCube(cubeButton.musicRef); } else if (attach.GetType() == typeof(InstrumentAttachment)) { InstrumentAttachment instrument = attach as InstrumentAttachment; ghostAttach = UIFactory.CreateInstrument(instrument.musicRef); } else if (attach.GetType() == typeof(RBFTrainingSpawnerAttachment)) { ghostAttach = UIFactory.CreateRBFSphereTraining(); } ghostAttach.transform.parent = attach.transform; ghostAttach.transform.position = attach.transform.position; ghostAttach.transform.localScale = attach.transform.localScale; ghostAttach.transform.parent = null; ghostAttach.SetTransient(true); ghostAttach.SetCloneable(false); return(ghostAttach); }
public void SetParentAttachment(BaseAttachment attachment) { m_ParentAttachment = attachment; }
public override void RemoveDockableAttachment(BaseAttachment attach) { base.RemoveDockableAttachment(attach); m_paramscroller.RemoveDockableAttachment(attach); }