/// <summary> /// 处理命令系统业务逻辑 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { //执行Undo操作 if (evt.PropertyName.Equals("CommandArgs")) { ICommandArgs _args = (ICommandArgs)evt.NewValue; if (!_args.GetCommandName().ToLower().Equals("undo")) { return; } _CommandService.GetCommandStack().Undo(); return; } //执行Redo操作 if (evt.PropertyName.Equals("CommandArgs")) { ICommandArgs _args = (ICommandArgs)evt.NewValue; if (!_args.GetCommandName().ToLower().Equals("redo")) { return; } _CommandService.GetCommandStack().Redo(); return; } }
/// <summary> /// 业务逻辑处理函数 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { // 执行Undo操作 if (evt.PropertyName.Equals("UndoMessage")) { _CommandService.GetCommandStack().Undo(); return; } //执行Redo操作 if (evt.PropertyName.Equals("RedoMessage")) { _CommandService.GetCommandStack().Redo(); return; } }
/// <summary> /// 更新命令UI的状态 /// </summary> IEnumerator UpdateCommandUIState() { //获取命令系统堆栈 ICommandStack stack = _commandService.GetCommandStack(); while (true) { if (stack.CanUndo()) { goUndo.GetComponent <Button>().interactable = true; } else { goUndo.GetComponent <Button>().interactable = false; } if (stack.CanRedo()) { goRedo.GetComponent <Button>().interactable = true; } else { goRedo.GetComponent <Button>().interactable = false; } yield return(new WaitForSeconds(0.3f)); } }
/// <summary> /// 处理命令系统业务逻辑 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { //处理创建物体业务逻辑 if (evt.PropertyName.Equals("CommandArgs")) { ICommandArgs _args = (ICommandArgs)evt.NewValue; if (!_args.GetCommandName().ToLower().Equals("create")) { return; } //获取创建参数 CreateCommandArgs args = (CreateCommandArgs)evt.NewValue; if (args.prefabsPath == null || args.prefabsPath.Equals("")) { return; } //新建创建命令并执行命令(注意命令执行方法是让命令堆栈执行Execute) CommandPartCreate cmd = new CommandPartCreate(); cmd.Position = args.Position; cmd.PartPrefab = args.prefabsPath; _CommandService.GetCommandStack().Execute(cmd); return; } }
/// <summary> /// 业务逻辑处理函数 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { if (evt.PropertyName.Equals("CreateTowerMessage")) { //给参数赋值 CreateTowerCommandStr str = (CreateTowerCommandStr)evt.NewValue; TowerCreateControllCommand cmd = new TowerCreateControllCommand(); cmd.Position = str.Position; _commandService.GetCommandStack().Execute(cmd); } if (evt.PropertyName.Equals("CreatePhoneMessage")) { //给参数赋值 CreatePhoneCommandStr str = (CreatePhoneCommandStr)evt.NewValue; PhoneCreateControllCommand cmd = new PhoneCreateControllCommand(); cmd.Position = str.Position; _commandService.GetCommandStack().Execute(cmd); } }
/// <summary> /// 业务逻辑处理函数 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { if (evt.PropertyName.Equals("DeletePartMessage")) { //给参数赋值 DeleteCommandStr str = (DeleteCommandStr)evt.NewValue; CubeDeleteControllCommand cmd = new CubeDeleteControllCommand(); cmd.ObjectId = str.ObjectID; _commandService.GetCommandStack().Execute(cmd); } }
/// <summary> /// 业务逻辑处理函数 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { if (evt.PropertyName.Equals("ColorParMessage")) { //给参数赋值 ColorCommandStr str = (ColorCommandStr)evt.NewValue; CubeColorControllCommand cmd = new CubeColorControllCommand(); cmd.OldColor = str.OldColor; cmd.NewColor = str.NewColor; cmd.ColorObjectID = str.ObjectID; _commandService.GetCommandStack().Execute(cmd); } }
/// <summary> /// 处理命令系统业务逻辑 /// </summary> /// <param name="evt"></param> public override void ProcessLogic(PropertyMessage evt) { //处理删除物体业务逻辑 if (evt.PropertyName.Equals("CommandArgs")) { ICommandArgs _args = (ICommandArgs)evt.NewValue; if (!_args.GetCommandName().ToLower().Equals("move")) { return; } //获取创建参数 MoveCommandArgs args = (MoveCommandArgs)evt.NewValue; CommandPartMove cmd = new CommandPartMove(); cmd.TargetPartObjectId = args.PartObjectId; _CommandService.GetCommandStack().Execute(cmd); return; } }