void Start() { commands = new ICommand[NUM_COMMAND]; textinfos = new string[NUM_COMMAND]; textinfos[0] = "x方向移动"; commands[0] = new MoveCommand(cube.transform, Vector3.right); textinfos[1] = "y方向移动"; commands[1] = new MoveCommand(cube.transform, Vector3.up); textinfos[2] = "z方向移动"; commands[2] = new MoveCommand(cube.transform, Vector3.forward); textinfos[6] = "变红"; commands[6] = new ColorChangeCommand(Color.red, cube.GetComponent <Renderer>().material); textinfos[7] = "变绿"; commands[7] = new ColorChangeCommand(Color.green, cube.GetComponent <Renderer>().material); textinfos[8] = "变蓝"; commands[8] = new ColorChangeCommand(Color.blue, cube.GetComponent <Renderer>().material); textinfos[9] = "换信息"; commands[9] = new TextChangeCommand(cube.GetComponentInChildren <TextMesh>(), infos); }
public MainViewModel() { // ファイルから読む体で userDict.Add("111", new UserModel("111", "社会人P") { Color = Colors.LightGreen }); userDict.Add("222", new UserModel("222", "八百屋")); Comments = model.Comments.ToReadOnlyReactiveCollection(comment => { if (!userDict.TryGetValue(comment.ID, out var user)) { user = new UserModel(comment.ID); userDict.Add(user.ID, user); } return(new CommentViewModel(comment, user)); }).AddTo(disposable); #region Command NameChangeCommand.Subscribe(obj => { var menuItem = obj as MenuItem; var comment = menuItem.DataContext as CommentViewModel; var ib = new InputBox { DataContext = comment, Text = comment.Name.Value, }; if (ib.ShowDialog() == true) { comment.Name.Value = ib.Text; } }); ColorChangeCommand.Subscribe(obj => { var menuItem = obj as MenuItem; var comment = menuItem.DataContext as CommentViewModel; comment.Color.Value = (Color)menuItem.Tag; }); ConnectCommand = IsRunning.Select(x => !x).ToAsyncReactiveCommand(); ConnectCommand.Subscribe(async _ => { await model.ConnectAsync("lv1234567"); IsRunning.Value = true; }).AddTo(disposable); DisconnectCommand = IsRunning.ToReactiveCommand(); DisconnectCommand.Subscribe(_ => { model.Disconnect(); IsRunning.Value = false; }).AddTo(disposable); #endregion ConnectCommand.Execute(); }