public override string UpdateActionText(IObjectAction action, bool performing)
 {
     if (action is MoveObjectAction)
     {
         return
             (string.Format("Center X:{0,9:0.00}/n", this.center.X) +
              string.Format("Center Y:{0,9:0.00}", this.center.Y));
     }
     else if (action is ScaleObjectAction)
     {
         if (MathF.Abs(this.scale.X - this.scale.Y) >= 0.01f)
         {
             return
                 (string.Format("Scale X:{0,8:0.00}/n", this.scale.X) +
                  string.Format("Scale Y:{0,8:0.00}", this.scale.Y));
         }
         else
         {
             return(string.Format("Scale:{0,8:0.00}", this.scale.X));
         }
     }
     else if (action is RotateObjectAction)
     {
         return(string.Format("Angle:{0,6:0.0}°", MathF.RadToDeg(this.angle)));
     }
     return(base.UpdateActionText(action, performing));
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is RotateObjectAction)
     {
         return(false);
     }
     return(base.IsActionAvailable(action));
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is MoveObjectAction ||
         action is RotateObjectAction ||
         action is ScaleObjectAction)
     {
         return(this.HasTransform);
     }
     return(false);
 }
 public override string UpdateActionText(IObjectAction action, bool performing)
 {
     if (action is MoveObjectAction)
     {
         return
             (string.Format("Center X:{0,9:0.00}/n", this.circle.Position.X) +
              string.Format("Center Y:{0,9:0.00}", this.circle.Position.Y));
     }
     else if (action is ScaleObjectAction)
     {
         return(string.Format("Radius:{0,8:0.00}", this.circle.Radius));
     }
     return(base.UpdateActionText(action, performing));
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is MoveObjectAction)
     {
         return(true);
     }
     if (action is RotateObjectAction)
     {
         return(true);
     }
     if (action is ScaleObjectAction)
     {
         return(true);
     }
     return(false);
 }
    void Raycast()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        bool       isCollider = Physics.Raycast(ray, out hit);

        //射线与collider发生了碰撞
        if (isCollider)
        {
            //hit.transform.gameObject.SendMessage("excuse", SendMessageOptions.DontRequireReceiver);
            IObjectAction _temp = hit.transform.GetComponent <IObjectAction>(); //获取碰撞物体上的继承了IObjectAciton接口的组件
            if (_temp != null)
            {
                _temp.Accept(visitor);                //如果非空,则代表这个物体上有我们需要的组件,就使用
            }
        }
    }
            public override string UpdateActionText(IObjectAction action, bool performing)
            {
                if (action is MoveObjectAction)
                {
                    return
                        (string.Format("X:{0,7:0}/n", this.gameObj.Transform.RelativePos.X) +
                         string.Format("Y:{0,7:0}/n", this.gameObj.Transform.RelativePos.Y) +
                         string.Format("Z:{0,7:0}", this.gameObj.Transform.RelativePos.Z));
                }
                else if (action is ScaleObjectAction)
                {
                    return(string.Format("Scale:{0,5:0.00}", this.gameObj.Transform.RelativeScale));
                }
                else if (action is RotateObjectAction)
                {
                    return(string.Format("Angle:{0,5:0}°", MathF.RadToDeg(this.gameObj.Transform.RelativeAngle)));
                }

                return(base.UpdateActionText(action, performing));
            }
 protected override void OnBeginAction(IObjectAction action)
 {
     base.OnBeginAction(action);
     bool shapeAction =
         !(action is RectSelectObjectAction) &&
         !(action is NullObjectAction);
     if (this.selectedBody != null && shapeAction) this.selectedBody.BeginUpdateBodyShape();
 }
 public void RemoveAction(IObjectAction action)
 {
     mActions.Remove(action);
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is MoveObjectAction) return true;
     if (action is RotateObjectAction) return true;
     if (action is ScaleObjectAction) return true;
     return false;
 }
 public override string UpdateActionText(IObjectAction action, bool performing)
 {
     if (action is MoveObjectAction)
     {
         return
             string.Format("Center X:{0,9:0.00}/n", this.circle.Position.X) +
             string.Format("Center Y:{0,9:0.00}", this.circle.Position.Y);
     }
     else if (action is ScaleObjectAction)
     {
         return string.Format("Radius:{0,8:0.00}", this.circle.Radius);
     }
     return base.UpdateActionText(action, performing);
 }
Example #12
0
 public void AddAction(IObjectAction action)
 {
     mActions.Add(action);
 }
 public void AddAction(IObjectAction action)
 {
     mOverrides.Add(action);
 }
 protected override void PostPerformAction(IEnumerable <CamViewState.SelObj> selObjEnum, IObjectAction action)
 {
     base.PostPerformAction(selObjEnum, action);
     if (action is MoveObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos);
     }
     else if (action is RotateObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeAngle);
     }
     else if (action is ScaleObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeScale);
     }
 }
 protected override void OnEndAction(IObjectAction action)
 {
     base.OnEndAction(action);
     bool shapeAction =
         !(action is RectSelectObjectAction) &&
         !(action is NullObjectAction);
     if (this.selectedBody != null && shapeAction)
     {
         this.selectedBody.EndUpdateBodyShape();
     }
     if (this.createAction)
     {
         this.createAction = false;
         UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromFirst);
     }
 }
        protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, IObjectAction action)
        {
            base.PostPerformAction(selObjEnum, action);
            SelShape[] selShapeArray = selObjEnum.OfType<SelShape>().ToArray();

            // Update the body directly after modifying it
            if (this.selectedBody != null) this.selectedBody.SynchronizeBodyShape();

            // Notify property changes
            DualityEditorApp.NotifyObjPropChanged(this,
                new ObjectSelection(this.selectedBody),
                ReflectionInfo.Property_RigidBody_Shapes);
            DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(selShapeArray.Select(s => s.ActualObject)));
        }
 public override bool IsActionAvailable(IObjectAction action)
 {
     return(false);
 }
Example #18
0
 public void RemoveAction(IObjectAction action)
 {
     mActions.Remove(action);
 }
 protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, IObjectAction action)
 {
     base.PostPerformAction(selObjEnum, action);
     if (action is MoveObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos);
     }
     else if (action is RotateObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeAngle);
     }
     else if (action is ScaleObjectAction)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeScale);
     }
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is RotateObjectAction) return false;
     return base.IsActionAvailable(action);
 }
 public override bool IsActionAvailable(IObjectAction action)
 {
     if (action is MoveObjectAction ||
         action is RotateObjectAction ||
         action is ScaleObjectAction)
         return this.HasTransform;
     return false;
 }
 public override string UpdateActionText(IObjectAction action, bool performing)
 {
     if (action is MoveObjectAction)
     {
         return
             string.Format("Center X:{0,9:0.00}/n", this.center.X) +
             string.Format("Center Y:{0,9:0.00}", this.center.Y);
     }
     else if (action is ScaleObjectAction)
     {
         if (MathF.Abs(this.scale.X - this.scale.Y) >= 0.01f)
         {
             return
                 string.Format("Scale X:{0,8:0.00}/n", this.scale.X) +
                 string.Format("Scale Y:{0,8:0.00}", this.scale.Y);
         }
         else
         {
             return string.Format("Scale:{0,8:0.00}", this.scale.X);
         }
     }
     else if (action is RotateObjectAction)
     {
         return string.Format("Angle:{0,6:0.0}°", MathF.RadToDeg(this.angle));
     }
     return base.UpdateActionText(action, performing);
 }
            public override string UpdateActionText(IObjectAction action, bool performing)
            {
                if (action is MoveObjectAction)
                {
                    return
                        string.Format("X:{0,7:0}/n", this.gameObj.Transform.RelativePos.X) +
                        string.Format("Y:{0,7:0}/n", this.gameObj.Transform.RelativePos.Y) +
                        string.Format("Z:{0,7:0}", this.gameObj.Transform.RelativePos.Z);
                }
                else if (action is ScaleObjectAction)
                {
                    return string.Format("Scale:{0,5:0.00}", this.gameObj.Transform.RelativeScale);
                }
                else if (action is RotateObjectAction)
                {
                    return string.Format("Angle:{0,5:0}°", MathF.RadToDeg(this.gameObj.Transform.RelativeAngle));
                }

                return base.UpdateActionText(action, performing);
            }
 public override bool IsActionAvailable(IObjectAction action)
 {
     return false;
 }
 public void AddAction(IObjectAction action)
 {
     mActions.Add(action);
 }