/// <summary>
        /// Draw trajectory line
        /// </summary>
        private void DrawTrajectory()
        {
            LineRenderer line = trajectoryLine.GetComponent <LineRenderer>();

            //look of the line
            line.startWidth = 0.2f;
            line.material   = Resources.Load("Materials/Projection") as Material;
            line.startColor = Color.blue;
            line.endColor   = Color.cyan;

            //show line
            line.enabled = true;

            DriverPractice dp          = DPMDataHandler.dpmodes.Where(d => d.gamepiece.Equals(FieldDataHandler.gamepieces[gamepieceIndex].name)).ToArray()[0];
            GameObject     releaseNode = Auxiliary.FindObject(dpmRobot.gameObject, dp.releaseNode);

            int verts = 100; //This determines how far along time the illustration goes.

            line.positionCount = verts;

            UnityEngine.Vector3 pos  = releaseNode.transform.position + releaseNode.GetComponent <BRigidBody>().transform.rotation *dp.releasePosition;
            UnityEngine.Vector3 vel  = releaseNode.GetComponent <BRigidBody>().velocity + releaseNode.transform.rotation * VelocityToVector3(dp.releaseVelocity);
            UnityEngine.Vector3 grav = GameObject.Find("BulletPhysicsWorld").GetComponent <BPhysicsWorld>().gravity;
            for (int i = 0; i < verts; i++)
            {
                line.SetPosition(i, pos);
                vel = vel + grav * Time.fixedDeltaTime;
                pos = pos + vel * Time.fixedDeltaTime;
            }
        }
        /// <summary>
        /// Refreshes the position of the move arrows with the position offsets.
        /// </summary>
        public void RefreshMoveArrows()
        {
            dp = dpmRobot.GetDriverPractice(FieldDataHandler.gamepieces[gamepieceIndex]);
            GameObject releaseNode = Auxiliary.FindObject(dpmRobot.gameObject, dp.releaseNode);

            moveArrows.transform.parent        = releaseNode.transform;
            moveArrows.transform.localPosition = dp.releasePosition;
        }
 /// <summary>
 /// Updates input field values of release position and velocity
 /// </summary>
 private void UpdateTrajectoryValues()
 {
     dp = dpmRobot.GetDriverPractice(FieldDataHandler.gamepieces[gamepieceIndex]);
     IncrementTrajectoryValues();
     xOffsetEntry.GetComponent <InputField>().text           = dp.releasePosition.x.ToString();
     yOffsetEntry.GetComponent <InputField>().text           = dp.releasePosition.y.ToString();
     zOffsetEntry.GetComponent <InputField>().text           = dp.releasePosition.z.ToString();
     releaseSpeedEntry.GetComponent <InputField>().text      = dp.releaseVelocity.x.ToString();
     releaseVerticalEntry.GetComponent <InputField>().text   = dp.releaseVelocity.y.ToString();
     releaseHorizontalEntry.GetComponent <InputField>().text = dp.releaseVelocity.z.ToString();
     RefreshMoveArrows();
 }
        public DriverPractice GetDriverPractice(Gamepiece g)
        {
            DriverPractice dp = new DriverPractice(g.name, "node_0.bxda", "node_0.bxda", UnityEngine.Vector3.zero, UnityEngine.Vector3.zero);

            if (DPMDataHandler.dpmodes.Where(d => d.gamepiece.Equals(g.name)).Count() > 0)
            {
                dp = DPMDataHandler.dpmodes.Where(d => d.gamepiece.Equals(g.name)).ToArray()[0];
            }
            else
            {
                DPMDataHandler.dpmodes.Add(dp);
                DPMDataHandler.WriteRobot();
                SetAllInteractors();
            }
            return(dp);
        }
        /// <summary>
        /// Creates a <see cref="GameObject"/> instantiated from the MoveArrows prefab.
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private GameObject CreateMoveArrows()
        {
            dp = dpmRobot.GetDriverPractice(FieldDataHandler.gamepieces[gamepieceIndex]);
            GameObject releaseNode = Auxiliary.FindObject(dpmRobot.gameObject, dp.releaseNode);
            GameObject arrows      = Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows"));

            arrows.name                    = "ReleasePositionMoveArrows";
            arrows.transform.parent        = releaseNode.transform;
            arrows.transform.localPosition = dp.releasePosition;
            arrows.transform.localRotation = dpmRobot.gameObject.transform.localRotation;

            arrows.GetComponent <MoveArrows>().Translate = (translation) =>
            {
                arrows.transform.position += translation;
                dp.releasePosition         = arrows.transform.localPosition;
            };

            arrows.GetComponent <MoveArrows>().OnClick   = () => dpmRobot.gameObject.GetComponent <SimulatorRobot>().LockRobot();
            arrows.GetComponent <MoveArrows>().OnRelease = () => dpmRobot.gameObject.GetComponent <SimulatorRobot>().UnlockRobot();

            StateMachine.SceneGlobal.Link <MainState>(arrows, false);

            return(arrows);
        }