public Scenario(Sugarism.Scenario model, Mode mode) { if (null == model) { Log.Error("Not Found Sugarism.Scenario"); return; } _model = model; _mode = mode; Log.Debug("begin. Scenario"); _sceneList = new List <Scene>(); foreach (Sugarism.Scene mScene in _model.SceneList) { Scene scene = new Scene(mScene, _mode); _sceneList.Add(scene); } _sceneIter = _sceneList.GetEnumerator(); if (_sceneIter.MoveNext()) { string msg = string.Format("begin. Scene: {0}", _sceneIter.Current.Description); Log.Debug(msg); } else { Log.Error("fail to move next scene"); } }
private void start(Sugarism.Scenario model) { _scenario = new Scenario(model, this); ScenarioStartEvent.Invoke(); NextCmd(); }
public bool LoadScenario(TextAsset textAsset) { if (null == textAsset) { Log.Error("not found text asset"); return false; } Log.Debug(string.Format("try to load scenario; {0}", textAsset.name)); object result = null; bool isDeserialized = JsonUtils.Deserialize<Sugarism.Scenario>(textAsset.text, out result, JSON_SETTINGS); if (false == isDeserialized) { string msg = string.Format("Failed to Load Scenario from the text asset: {0}", textAsset.name); Log.Error(msg); return false; } Sugarism.Scenario scenarioModel = result as Sugarism.Scenario; start(scenarioModel); return true; }
public void AddSampleScenario() { Sugarism.Scenario model = new Sugarism.Scenario(null); Scenario snr = new Scenario(model); Add(snr); }
public void Import() { // get file path to import OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = JsonUtils.FILE_EXTENSION; dlg.Filter = JsonUtils.FILE_FILTER; var isGotFilePath = dlg.ShowDialog(); if (false == isGotFilePath) { return; } string filePath = dlg.FileName; if (string.IsNullOrEmpty(filePath)) { return; } string text; // read the file as text bool isRead = FileUtils.ReadAllTextAsUTF8(filePath, out text); if (false == isRead) { return; } // deserialize the text to object object result = null; bool isDeserialized = JsonUtils.Deserialize <Sugarism.Scenario>(text, out result, _jsonSerializerSettings); if (false == isDeserialized) { return; } // Sugarism.Scenario model = result as Sugarism.Scenario; Scenario scenario = new Scenario(filePath, model); Add(scenario); }
// use after deserialize SceneList public Scenario(string filePath, Sugarism.Scenario model) { _model = model; _owner = null; _fileFullPath = filePath; _sceneList = new ObservableCollection <Scene>(); foreach (Sugarism.Scene scene in _model.SceneList) { Scene s = new Scene(scene); SceneList.Add(s); s.Owner = this; } _isExpanded = true; _isSelected = true; _inputBindings = new InputBindingCollection(); _inputBindings.Add(new KeyBinding(CmdExpand, Key.Enter, ModifierKeys.None)); _inputBindings.Add(new KeyBinding(CmdAddChild, Key.A, ModifierKeys.Control)); }
public Scenario(Sugarism.Scenario model) : this(Properties.Resources.Scenario, model) { }