public void Activate() { StateInformation i = _currStateInfo; i.inactive = false; _currStateInfo = i; }
public void Deactivate() { StateInformation i = _currStateInfo; i.inactive = true; _currStateInfo = i; }
public void Create_With_WorkGroup() { var group = Substitute.For <IWorkGroup>(); var test = new StateInformation(group); Assert.Equal(group, test.Group); }
public void OnMouseButton(Vector3 mousePosition, StateInformation stateInformation) { IPlacedObject selectedObject = stateInformation.selectedObject; MouseButtonState leftMouseButtonState = leftMouseButton.GetState(); // moving the Object if (leftMouseButtonState == MouseButtonState.DOWN) { selectedObject.SetAllCollidersStatus(false); } else if (leftMouseButtonState == MouseButtonState.PRESSED) { selectedObject.RemoveWeaponFromPerson(); //selectedObject.SetAllCollidersStatus(false); objectEditingModule.MoveObject(selectedObject, mousePosition); } else if (leftMouseButtonState == MouseButtonState.UP) { selectedObject.SetAllCollidersStatus(true); } // Giving an Enemy a Weapon if (leftMouseButtonState == MouseButtonState.UP && lastLeftMouseButtonState == MouseButtonState.PRESSED) { IPlacedObject hoveredObject = stateInformation.hoveredObject; bool objectCanBeGiven = objectInformationModule.CheckIfWeaponCanBeGivenToPerson(selectedObject, hoveredObject); if (objectCanBeGiven) { // give selectedObject to hoveredObject objectEditingModule.GiveWeaponToPerson(selectedObject, hoveredObject); } } lastLeftMouseButtonState = leftMouseButtonState; }
void Start() { stateInformation = new StateInformation(); interfaceManager = InterfaceManager.GetInstance(); prefabsManager = PrefabsManager.GetInstance(); levelController = LevelController.instance; levelDataManager = LevelDataManager.GetInstance(); startupModule = (IStartupModule)StartupModule.GetInstance(); objectDeletionModule = (IObjectDeletionModule)ObjectDeletionModule.GetInstance(); objectPlacementModule = (IObjectPlacementModule)ObjectPlacementModule.GetInstance(); objectEditingModule = (IObjectEditingModule)ObjectEditingModule.GetInstance(); objectInformationModule = (IObjectInformationModule)ObjectInformationModule.GetInstance(); GameObject leftMouseButtonObject = Instantiate(mouseButtonPrefab, transform); leftMouseButton = leftMouseButtonObject.GetComponent <MouseButton>(); GameObject rightMouseButtonObject = Instantiate(mouseButtonPrefab, transform); rightMouseButton = rightMouseButtonObject.GetComponent <MouseButton>(); leftMouseButton.Setup(0, mouseButtonLeftPressedTime); rightMouseButton.Setup(1, cameraDragTime); prefabsManager.AddPrefabs(); interfaceManager.SetupUI(prefabsManager.GetPrefabTable()); InitializeLevel(initialLevelWidth, initialLevelHeight); SetupLevel(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty infoProperty = property.FindPropertyRelative("Info"); SerializedProperty valueProperty = property.FindPropertyRelative("_value"); StateInformation stateInfo = (StateInformation)infoProperty.objectReferenceValue; if (stateInfo != null) { label.tooltip = stateInfo.Description; if (stateInfo.accuracy != AttributeInformation.Accuracy.Float) { EditorGUI.BeginChangeCheck(); float newValue = EditorGUI.IntField(position, label, Mathf.RoundToInt(valueProperty.floatValue)); if (EditorGUI.EndChangeCheck()) { valueProperty.floatValue = newValue; } } else { valueProperty.floatValue = EditorGUI.FloatField(position, label, valueProperty.floatValue); } GUI.tooltip = null; } else { EditorGUI.LabelField(position, label); } property.serializedObject.ApplyModifiedProperties(); }
//////////////////////////////////////////////////////////////////////////// public EqualityAnalyzer extract(StateInformation si) { if (si.equalityAnalyzer == null) { si.equalityAnalyzer = new EqualityAnalyzer(procedure); } return(si.equalityAnalyzer); }
public void OnMouseButton(Vector3 mousePosition, StateInformation stateInformation) { if (leftMouseButton.GetState() == MouseButtonState.PRESSED || leftMouseButton.GetState() == MouseButtonState.DOWN) { objectDeletionModule.DeleteObject(stateInformation.hoveredObject); stateInformation.hoveredObject = null; } }
public FunctionInliner extract(StateInformation si) { if (si.functionInliner == null) { si.functionInliner = new FunctionInliner(procedure); } return(si.functionInliner); }
public void OnMouseButton(Vector3 mousePosition, StateInformation stateInformation) { if (leftMouseButton.GetState() == MouseButtonState.DOWN) { objectEditingModule.AddPatrolPoint(stateInformation.selectedObject, mousePosition); interfaceManager.SetupObjectEditorPanel(stateInformation.selectedObject); } }
///////////////////////////////////////////////////// public MapCollector extract(StateInformation si) { if (si.mapCollector == null) { si.mapCollector = new MapCollector(); } return(si.mapCollector); }
public SubexpressionCounter extract(StateInformation si) { if (si.subexpressionCounter == null) { si.subexpressionCounter = new SubexpressionCounter(procedure); } return(si.subexpressionCounter); }
public BasicBlock() { label = null; cfg = null; statements = new List <StatementInfo>(); controlStatement = null; myPredecessors = new List <BasicEdge>(); preState = new StateInformation(); postState = preState; }
//////////////////////////////////////////////////////////////////////// public void mergeNextBlock() { Debug.Assert(controlStatement != null); Debug.Assert(controlStatement is UnconditionalBranch); BasicBlock next = controlStatement.successors.First().target; Debug.Assert(next.controlStatement != null); Debug.Assert(next.predecessors.Count() == 1); Debug.Assert(next != this); statements.RemoveAt(statements.Count - 1); //collect control statement int preNumStatements = statements.Count; next.removePredecessor(successors.First()); StateInformation insertionPrestate = (statements.Count > 0) ? statements.Last().postState : preState; int i = 0; foreach (var nsi in next.statements) { nsi.preState = (i == 0) ? insertionPrestate : statements.Last().postState; nsi.basicBlock = this; nsi.index = statements.Count; statements.Add(nsi); i++; } postState = statements.Last().postState; controlStatement = statements.Last().statement as ControlStatement; foreach (var e in controlStatement.successors) { e.setSource(this); } assertLocalInvariant(); next.controlStatement = null; next.statements = new List <StatementInfo>(); next.postState = next.preState; next.setControlStatement(new Block(next)); if (cfg.endNode.label == next.label) { cfg.endNode = this; } next.delete(); foreach (var e in controlStatement.successors) { e.target.assertLocalInvariant(); } assertLocalInvariant(); }
public DeadCodeEliminator extract(StateInformation si) { if (si.deadCodeEliminator == null) { si.deadCodeEliminator = new DeadCodeEliminator(); } si.deadCodeEliminator.initializedVariables = si.initializedVariables; return(si.deadCodeEliminator); }
public void AddTask_WorkGroup(string value) { using (var test = Create()) { test.Start(); var group = test.AddWorkGroup(value, 1); var state = new StateInformation(group); var t = new Task(state1 => { Thread.Sleep(100); }, state); test.AddTask(t); } }
public void OnMouseButton(Vector3 mousePosition, StateInformation stateInformation) { if (leftMouseButton.GetState() == MouseButtonState.PRESSED && stateInformation.objectToPlace.Type == PrefabType.LEVELELEMENT) { objectPlacementModule.PlaceObject(stateInformation.objectToPlace, mousePosition); } else if (leftMouseButton.GetState() == MouseButtonState.DOWN) { objectPlacementModule.PlaceObject(stateInformation.objectToPlace, mousePosition); } }
public DeadCodeEliminator extract(StateInformation si) { if (si.deadCodeEliminator == null) { si.deadCodeEliminator = new DeadCodeEliminator(procedure); } si.deadCodeEliminator.initializedVariables = si.initializedVariables; Debug.Assert(si.deadCodeEliminator.initializedVariables != null); return(si.deadCodeEliminator); }
/////////////////////////////////////////////////////////////////// protected PredicateStatement(Expression expression) { Debug.Assert(expression != null); Debug.Assert(expression.isGround); this.expression = expression; // this.myPredecessors = new ExpressionList<Predicate>(); // this.successors = new ExpressionList<Predicate>(); preStates = new StateInformation(); postStates = new StateInformation(); }
private StateInformation GetOrCreateStateInformation(TState state) { if (!states.ContainsKey(state)) { states[state] = new StateInformation() { state = state }; } return(GetStateInformation(state)); }
private void UpdateListeners(bool isCondutctorDied) { StateInformation info = new StateInformation(); info.Hares = _haresPercent; info.RemainKilled = _maxKilledPassengers; info.StationNumber = _currentStationNumber; info.TicketCount = _ticketCount; info.IsConductorDied = isCondutctorDied; foreach (var gameStateNotificationListener in _listeners) { gameStateNotificationListener.UpdateInfo(info); } }
//////////////////////////////////////////////////////////////////////// public void appendStatement(Statement s) { Debug.Assert(s != null); if (controlStatement == null) { // Debug.Assert(controlStatement == null); var si = new StatementInfo(s, postState, new StateInformation(), this, statements.Count); statements.Add(si); postState = si.postState; } else { insertStatementAt(statements.Count - 1, s); } }
private void Victory() { StateInformation info = new StateInformation(); info.Hares = _haresPercent; info.RemainKilled = _maxKilledPassengers; info.StationNumber = _currentStationNumber; info.TicketCount = _ticketCount; info.IsConductorDied = false; info.IsLevelFinished = true; foreach (var gameStateNotificationListener in _listeners) { gameStateNotificationListener.UpdateInfo(info); gameStateNotificationListener.GameOver(); } }
//////////////////////////////////////////////////////////////////////// public void setControlStatement(ControlStatement tc) { Debug.Assert(tc != null); if (controlStatement != null) { Debug.Assert(!ReferenceEquals(controlStatement, tc)); var os = new List <BasicEdge>(successors); foreach (var e in successors) { e.target.removePredecessor(e); } controlStatement = tc; statements[statements.Count - 1].statement = tc; foreach (var e in tc.successors) { Debug.Assert(e.source == this); } foreach (var e in tc.successors) { Debug.Assert(e.target.predecessors.Contains(e)); } foreach (var se in os) { if (se.target.predecessors.Count == 0) { se.target.delete(); } } } else { Debug.Assert(controlStatement == null); foreach (var e in tc.successors) { Debug.Assert(e.source == this); } controlStatement = tc; var cs = new StatementInfo(tc, postState, new StateInformation(), this, statements.Count); statements.Add(cs); postState = cs.postState; } assertLocalInvariant(); }
//////////////////////////////////////////////////////////////////////// public void delete() { // Console.WriteLine("\tDeleting block {0}", label); Debug.Assert(predecessors.Count() == 0); if (successors.Count > 0) { setControlStatement(new Block(this)); } Debug.Assert(successors.Count() == 0); cfg.removeNode(label); preState = null; postState = null; cfg = null; controlStatement = null; label = null; statements = null; }
public InitializedVariables extract(StateInformation si) { if (si.initializedVariables == null) { si.initializedVariables = new InitializedVariables(procedure); } else { Debug.Assert(si.initializedVariables.procedure != null); } if (si.equalityAnalyzer == null || si.equalityAnalyzer.pathCondition == null) { si.initializedVariables.pathCondition = new PropositionalFormula(true); } else { si.initializedVariables.pathCondition = si.equalityAnalyzer.pathCondition; } return(si.initializedVariables); }
//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// public StatementId insertStatementAt(int index, Statement statement) { Debug.Assert(controlStatement != null); Debug.Assert(statement != null); Debug.Assert(index >= 0 && index < statements.Count); StateInformation pre = statements[index].preState; var post = new StateInformation(); //(index == statements.Count) ? : statements[index].preState; statements[index].preState = post; var si = new StatementInfo(statement, pre, post, this, index); statements.Insert(index, si); assertLocalInvariant(); for (int i = index + 1; i < statements.Count; i++) { statements[i].index++; } return(statements[index].statementId); }
public StatementInfo( Statement statement, StateInformation preState, StateInformation postState, BasicBlock basicBlock, int index ) { Debug.Assert(statement != null); Debug.Assert(preState != null); Debug.Assert(postState != null); Debug.Assert(preState != postState); Debug.Assert(basicBlock != null); this.statement = statement; this.preState = preState; this.postState = postState; this.basicBlock = basicBlock; this.index = index; }
//////////////////////////////////// private void dumpState(StateInformation si) { if (si.initializedVariables == null || si.deadCodeEliminator == null) { return; } writeTabs(); cfgFile.Write("I = {"); foreach (var v in si.initializedVariables.firstOccurence.Keys) { if (si.deadCodeEliminator.liveVariables.Contains(v)) { cfgFile.Write(" " + v); } } cfgFile.WriteLine(" } <BR ALIGN=\"LEFT\"/>"); }
//////////////////////////////////////////////////////////////////////// internal void deleteStatement(int index) { Debug.Assert(index >= 0 && index < statements.Count - 1); // Console.WriteLine("Deleting statement {0}", label + "_" + index.ToString()); statements.RemoveAt(index); if (index == 0) { preState = statements[index].preState; } else { statements[index - 1].postState = statements[index].preState; } for (int i = index; i < statements.Count; i++) { statements[i].index--; } assertLocalInvariant(); }
private void Victory() { StateInformation info = new StateInformation(); info.Hares = _haresPercent; info.RemainKilled = _maxKilledPassengers; info.StationNumber = _currentStationNumber; info.TicketCount = _ticketCount; info.IsConductorDied = false; info.IsLevelFinished = true; foreach (var gameStateNotificationListener in _listeners) { gameStateNotificationListener.UpdateInfo(info); gameStateNotificationListener.GameOver(); } }
private void UpdateListeners(bool isCondutctorDied) { StateInformation info = new StateInformation(); info.Hares = _haresPercent; info.RemainKilled = _maxKilledPassengers; info.StationNumber = _currentStationNumber; info.TicketCount = _ticketCount; info.IsConductorDied = isCondutctorDied; foreach (var gameStateNotificationListener in _listeners) { gameStateNotificationListener.UpdateInfo(info); } }