Example #1
0
        ///<summary>キーによる位置移動</summary>
        void ChangePosKey()
        {
            if (Event.current.type != EventType.KeyDown)
            {
                return;
            }

            var keycode = Event.current.keyCode;

            if ((keycode == KeyCode.UpArrow) || (keycode == KeyCode.DownArrow) ||
                (keycode == KeyCode.LeftArrow) || (keycode == KeyCode.RightArrow) ||
                (keycode == KeyCode.KeypadMinus))
            {
                Undo.RecordObject(parent_, "ChangePartsPosKey");

                List <Action> cmdDo   = new List <Action>();
                List <Action> cmdUndo = new List <Action>();
                string        id      = MethodBase.GetCurrentMethod().Name;

                foreach (enPartsType item in Enum.GetValues(typeof(enPartsType)))
                {
                    var editParts = PartsConverter.Convert(item);
                    if (!isMultiParts_[editParts])
                    {
                        continue;
                    }

                    Vector2Int movePos = GetPartsObject(item).pos;
                    switch (keycode)
                    {
                    case KeyCode.UpArrow:
                        movePos.y += 1;
                        break;

                    case KeyCode.DownArrow:
                        movePos.y -= 1;
                        break;

                    case KeyCode.LeftArrow:
                        movePos.x -= 1;
                        break;

                    case KeyCode.RightArrow:
                        movePos.x += 1;
                        break;

                    case KeyCode.KeypadMinus:
                        movePos = BasePosition.GetPosEdit(item, false);
                        break;                                 //元の位置に戻す
                    }

                    Vector2Int newPos = RoundPosVector(movePos);
                    // GetNewPos(item, RoundPosVector(movePos));
                    var activeTack = parent_.GetActiveScore().GetActiveTackPoint();
                    var lastPos    = activeTack.motionData_.mPos.GetPos(editParts);
                    var partsType  = item;
                    //コマンドPos
                    cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos));
                    cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos));
                    id += partsType;
                }

                if (cmdDo.Any())
                {
                    ARIMotionMainWindow.tackCmd_.Do(new MotionCommand(id,
                                                                      () => { foreach (var cmd in cmdDo)
                                                                              {
                                                                                  cmd();
                                                                              }
                                                                      },
                                                                      () => { foreach (var cmd in cmdUndo)
                                                                              {
                                                                                  cmd();
                                                                              }
                                                                      }));
                }

                SetupPartsData(true);
            }
        }
Example #2
0
 void StateToPartsObject()
 {
     foreach (enPartsType item in Enum.GetValues(typeof(enPartsType)))
     {
         GetPartsObject(item).pos            = sendMotion_.stPos.GetPos(item) + BasePosition.GetPosEdit(item, false);
         GetPartsObject(item).partsTransform = sendMotion_.stTransform.GetTransform(item);
     }
 }
Example #3
0
        //Pos---------------

        ///<summary>マウスによる位置移動</summary>
        void ChangePos()
        {
            if (Event.current.button != 0)
            {
                return;
            }

            if (!IsSelectedParts())
            {
                return;
            }

            Vector2 mousePos = (Event.current.mousePosition / mag_);

            //ドラッグ
            if (Event.current.type == EventType.MouseDrag)
            {
                List <Action> cmdDo   = new List <Action>();
                List <Action> cmdUndo = new List <Action>();
                string        id      = MethodBase.GetCurrentMethod().Name;

                //コア以外
                foreach (enPartsType item in Enum.GetValues(typeof(enPartsType)))
                {
                    var editParts = PartsConverter.Convert(item);
                    if (!isMultiParts_[editParts])
                    {
                        continue;
                    }

                    Vector2Int basePos = BasePosition.GetPosEdit(item, false);

                    //コアは左右両方でやるとおかしくなるので、片方だけ
                    if ((editParts == enEditPartsType.Arm) || (editParts == enEditPartsType.Leg))
                    {
                        if ((item == enPartsType.RightArm) || (item == enPartsType.RightLeg))
                        {
                            continue;
                        }

                        //基礎位置なし
                        basePos = Vector2Int.zero;
                    }

                    Vector2 movePos = new Vector2(
                        mousePos.x - camPos_.x - multiOffset_[editParts].x, -mousePos.y + camPos_.y - multiOffset_[editParts].y);
                    Undo.RecordObject(parent_, "ChangePartsPos");

                    Vector2Int newPos     = RoundPosVector(movePos) - basePos;
                    var        activeTack = parent_.GetActiveScore().GetActiveTackPoint();
                    var        lastPos    = activeTack.motionData_.mPos.GetPos(editParts);
                    var        partsType  = editParts;
                    id += partsType;
                    //コマンドPos
                    cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos));
                    cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos));
                }

                // //コア
                // if (isMultiParts_[enEditPartsType.Core])
                // {
                //  var editParts = enEditPartsType.Core;

                //  Vector2 movePos = new Vector2(
                //      mousePos.x - camPos_.x - multiOffset_[editParts].x, -mousePos.y + camPos_.y - multiOffset_[editParts].y);
                //  Undo.RecordObject(parent_, "ChangePartsPos");

                //  Vector2Int newPos = RoundPosVector(movePos);

                //  // GetNewPos(editParts, RoundPosVector(movePos));
                //  var activeTack = parent_.GetActiveScore().GetActiveTackPoint();
                //  var lastPos = activeTack.motionData_.mPos.GetPos(editParts);
                //  // var partsType = item;
                //  id += editParts;
                //  //コマンドPos
                //  cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos));
                //  cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos));
                // }

                if (cmdDo.Any())
                {
                    ARIMotionMainWindow.tackCmd_.Do(new MotionCommand(id,
                                                                      () => { foreach (var cmd in cmdDo)
                                                                              {
                                                                                  cmd();
                                                                              }
                                                                      },
                                                                      () => { foreach (var cmd in cmdUndo)
                                                                              {
                                                                                  cmd();
                                                                              }
                                                                      }));
                }

                SetupPartsData(true);
            }
        }