/// <summary> /// 批量生成TaskCell到场景中,并进行初始化赋值 /// </summary> public void GenerateTaskCell() { for (int i = 0; i < commands.Count; i++) { GameObject go = Instantiate(Resources.Load <GameObject>("UI/TaskCell"), GameObject.Find("TaskShowPanel").transform); if (commands[i].commandType == CommandType.Delay) { WaitingStep step = go.AddComponent <WaitingStep>(); step.delayTime = float.Parse(commands[i].Param) / 1000f; go.transform.Find("Text").GetComponent <Text>().text = "待机指令"; } else { MovingStep step = go.AddComponent <MovingStep>(); JointsMessage jm = new JointsMessage(); jm.IKPoint = cps[commands[i].Param].point * 0.001f; string key = string.Format("{0:d3}", (StepManager.Instance.SavedPointMessage.Count + 1)); StepManager.Instance.SavedPointMessage.Add(key, jm); MechanicalControl.Instance.ShowTag(jm.IKPoint, key); step.targetPoint.IKPoint = jm.IKPoint; go.transform.Find("Text").GetComponent <Text>().text = "移动指令"; } StepManager.Instance.Steps.Add(go); } }
/// <summary> /// 老方法的运动,用DoTween控制关节点旋转,现在已弃用,以后有需要可参考使用 /// </summary> /// <param name="pointMessage"></param> /// <returns></returns> List <Tweener> RotateTo(JointsMessage pointMessage) { List <Tweener> tweeners = new List <Tweener>(); for (int i = 0; i < jointsDic.Count; i++) { tweeners.Add(RotateToSingle(jointsDic["Joint" + i], pointMessage.jointRotation[i])); } return(tweeners); }
/// <summary> /// 机器人开始自由运动 /// </summary> /// <param name="jointsMessage"></param> public void StartRotate(JointsMessage jointsMessage) { //老方法的运动,用Dowteem实现的各个关节配合移动的方式 //List<Tweener> tweeners = new List<Tweener>(); //if (jointsMessage != null) //{ // tweeners = RotateTo(jointsMessage); //} //allowIn = true; StartCoroutine(SimpleMoveP(jointsMessage.IKPoint)); }
//public Action OnRotateComplete; //protected bool allowIn = true; /// <summary> /// 保存末端点和各关节信息 /// </summary> /// <returns>存储末端点和各关节信息的类</returns> public JointsMessage SavePoint() { JointsMessage jointsMessage = new JointsMessage(); for (int i = 0; i < jointsDic.Count; i++) { jointsMessage.jointRotation.Add(jointsDic["Joint" + i].localEulerAngles); jointsMessage.IKPoint = GetGoInScene.GetInstance().PointTag.position; } return(jointsMessage); }