private void ChangeToPaths(SubMenuStates state_) { if (currentMenuState != MenuStates.paths) { currentMenuState = MenuStates.paths; currentEC = sceneElements[2]; menu.EnableMenu("PathsButton"); menu.DisableMenu("TopoButton"); menu.DisableMenu("GraphButton"); menu.DisableMenu("PeopleButton"); menu.DisableSimulatorButtons(); cam.DisableMovement(); } menu.CloseEditMenus(); currentSubMenuState = state_; currentEC.ChangeState(currentSubMenuState); GameObject pgo = new GameObject("alg"); if (state_ == SubMenuStates.edit) { EnableEditMenu(pgo); } }
public bool Intersect(ISceneElement other) { if (other == null || this == other) { return(false); } return(DoIntersect(other)); }
public void AddElement(ISceneElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } _elements.Add(element); _commands[element] = null; }
public BlueprintLineLoop(ISceneElement instance, int millis, params Vector3d[] vertices) { _Instance = instance; Vertices = vertices; Lifespan = millis; if (Lifespan > 0) { Timer = new Stopwatch(); Timer.Start(); } }
public void RemoveElement(ISceneElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } if (_commands.ContainsKey(element)) { _commands.Remove(element); } _elements.Remove(element); }
public void NewScenario(int w_, int h_) { simulationStarted = false; simulationPaused = true; simulationFinished = false; menu.SetPlayText(simulationPaused); width = w_; height = h_; if (map != null) { DeleteAll(); } // Create the building/map passing the specified dimensions map = GameObject.Instantiate(mapPrefab, this.transform).GetComponent <Map>(); map.Setup(this, width, height, size); graph = GameObject.Instantiate(graphPrefab, this.transform).GetComponent <Graph>(); graph.Setup(this); people = GameObject.Instantiate(peoplePrefab, this.transform).GetComponent <People>(); people.Setup(this); // scene info creation? sceneElements = new List <ISceneElement>(); sceneElements.Add(map); sceneElements.Add(graph); sceneElements.Add(people); currentSceneElement = SceneElementEnum.map; currentEC = sceneElements[(int)currentSceneElement]; currentMenuState = MenuStates.cam; currentSubMenuState = SubMenuStates.create; isoCameraPosition = new Vector3(0, 14, 0); isoCameraRotation = Quaternion.Euler(new Vector3(45, 45, 0)); //DataController.SetProjectName(filename); graph.gameObject.SetActive(true); }
private void ChangeToTopology(SubMenuStates state_) { if (currentMenuState != MenuStates.map) { currentMenuState = MenuStates.map; currentEC = sceneElements[0]; menu.EnableMenu("TopoButton"); menu.DisableMenu("GraphButton"); menu.DisableMenu("PeopleButton"); menu.DisableMenu("PathsButton"); menu.DisableSimulatorButtons(); cam.DisableMovement(); } menu.CloseEditMenus(); currentSubMenuState = state_; currentEC.ChangeState(currentSubMenuState); }
private void ChangeToGraph(SubMenuStates state_) { if (currentMenuState != MenuStates.graph) { currentMenuState = MenuStates.graph; currentEC = sceneElements[1]; menu.EnableMenu("GraphButton"); menu.DisableMenu("TopoButton"); menu.DisableMenu("PeopleButton"); menu.DisableMenu("PathsButton"); menu.DisableSimulatorButtons(); cam.DisableMovement(); } graph.gameObject.SetActive(true); menu.CloseEditMenus(); currentSubMenuState = state_; currentEC.ChangeState(currentSubMenuState); }
/// <summary> Check that a scene element can be intersected by another scene element /// </summary> /// <param name="sceneElement"></param> /// <returns>intersected scene element</returns> public ISceneElement CheckIntersect(ISceneElement sceneElement) { if (sceneElement == null) { return(null); } foreach (var element in _elements) { if (element == sceneElement) { continue; } if (sceneElement.Intersect(element)) { return(element); } } return(null); }
private void ChangeToPeople(SubMenuStates state_) { if (currentMenuState != MenuStates.people) { currentMenuState = MenuStates.people; currentEC = sceneElements[2]; menu.EnableMenu("PeopleButton"); menu.DisableMenu("TopoButton"); menu.DisableMenu("GraphButton"); menu.DisableMenu("PathsButton"); menu.DisableSimulatorButtons(); cam.DisableMovement(); } menu.CloseEditMenus(); currentSubMenuState = state_; currentEC.ChangeState(currentSubMenuState); if (state_ == SubMenuStates.create) { EnableEditMenu(people.GetNextPerson().gameObject); } }
public void Init(ISceneElement obj) { m_Weight = 0; m_TargetObj = obj; }
public SceneObject Downcast() { m_TargetObj = null; return(this); }
public virtual void Dispose() { _Instance = null; }
public BlueprintLineLoop(ISceneElement instance, params Vector3d[] vertices) : this(instance, 0, vertices) { }
protected override bool DoIntersect(ISceneElement other) { return(false); }
protected void ChangeScene(Scene next_scene) { if (_CurrentScene == next_scene || next_scene == null) { return; } SceneChangeEventArgs scea = new SceneChangeEventArgs(_CurrentScene, next_scene); IEnumerable <RenderSet> next_sets = next_scene.AllRenderSetsInOrder(); IEnumerator <RenderSet> next_set_enum = next_sets.GetEnumerator(); IEnumerable <RenderSet> current_sets = null; IEnumerator <RenderSet> current_set_enum = null; RenderSetChangeEventArgs rscea; if (_CurrentScene != null) { // Get the enumerable for the render sets; these need to be in the same order! current_sets = _CurrentScene.AllRenderSetsInOrder(); current_set_enum = current_sets.GetEnumerator(); // Enumerate from the beginning of the set enumerable foreach (RenderSet render_set in current_sets) { if (!next_set_enum.MoveNext()) { break; } rscea = new RenderSetChangeEventArgs(render_set, next_set_enum.Current); // Process this scene for (int i = 0; i < render_set.Count;) // For each renderable in render set { var renderable = render_set [i]; if (renderable is ISceneElement) // If object also implements scene object { ISceneElement scene_object = (ISceneElement)renderable; // Cast to scene object if (scene_object is IWorldObject) { IWorldObject world_object = (IWorldObject)scene_object; // Disable the body object is not preserved world_object.Body.Enabled &= world_object.Preserve; } if (scene_object.Preserve) // If scene object is preserved { next_set_enum.Current.Add(renderable); // Add in this object render_set.RemoveAt(i); // Remove from previous scene_object.OnRenderSetTransfer(this, rscea); continue; } } i++; } } foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) { if (!current_set_enum.MoveNext()) { break; } // Process next scene, PART 1 foreach (IRenderable renderable in render_set) { if (renderable is ISceneElement) // If object also implements scene object { if (renderable is IWorldObject) { IWorldObject world_object = (IWorldObject)renderable; // HACK: temporarily enable all bodies in this renderset // in order to allow deferred updates to affect bodies if (world_object.Body != null) { world_object.Body.Enabled = true; } } } } } } if (_CurrentScene != null) { _CurrentScene.OnSceneExit(this, scea); } // Enumerate from the beginning of the set enumerable if (_CurrentScene != null) { current_set_enum = current_sets.GetEnumerator(); } // Process next scene, PART 2 foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) { if (current_set_enum != null) { if (!current_set_enum.MoveNext()) { break; } rscea = new RenderSetChangeEventArgs(current_set_enum.Current, render_set); } else { rscea = new RenderSetChangeEventArgs(null, render_set); } foreach (IRenderable renderable in render_set) { if (renderable is ISceneElement) { ISceneElement scene_element = (ISceneElement)renderable; // Body.Enabled should be updated with a RenderSetEntry event handler scene_element.OnRenderSetEntry(this, rscea); } } } var last_scene = _CurrentScene; if (last_scene != null) { if (last_scene.FollowTarget == null) { next_scene.Follow(null); } else if (last_scene.FollowTarget.Preserve) { next_scene.Follow(last_scene.FollowTarget, true); } } next_scene.OnSceneEntry(next_scene, scea); _CurrentScene = next_scene; // Update the scene reference GC.Collect(); }
public NullCommand(ISceneElement sceneElement) : base(sceneElement) { }
protected abstract bool DoIntersect(ISceneElement other);