public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.previousPosition.X != this.position.X || this.previousPosition.Y != this.position.Y) { if (this.isFocused == false) { officeWorld.NotifyTextPositionChanged(this, this.previousToken, this.position); } else { officeWorld.NotifyObjectPositionChanged(this, this.position); } this.previousPosition = new Vector2f(this.position.X, this.position.Y); } if (this.isFocused != this.previousIsFocused) { officeWorld.NotifyObjectFocusChanged(this, this.isFocused); this.previousIsFocused = this.isFocused; } if (this.displayedText.Equals(this.previousDisplayedText) == false) { officeWorld.NotifyObjectTextChanged(this, this.displayedText); this.previousDisplayedText = this.displayedText; AToken nextToken = this.NextToken; if (nextToken != null && nextToken.IsTextFull) { while (nextToken != null) { nextToken.SetKinematicParameters(nextToken.InitialPosition, new SFML.System.Vector2f(0, 0)); nextToken = nextToken.NextToken; } } } if (this.isTextLaunched && this.speedText > 0 && this.indexText < this.text.Length) { this.nbCharacterToAdd += this.speedText * timeElapsed.AsSeconds() * this.speedFactor; int nbCharacterToAddInteger = (int)this.nbCharacterToAdd; this.indexText += nbCharacterToAddInteger; this.indexText = Math.Min(this.text.Length, this.indexText); this.nbCharacterToAdd -= nbCharacterToAddInteger; this.displayedText = this.text.Substring(0, this.indexText); } if (this.IsTextFull && this.isTextLaunched) { this.isTextLaunched = false; } }
public virtual void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.isFocused != this.previousIsFocused) { officeWorld.NotifyObjectFocusChanged(this, this.isFocused); this.previousIsFocused = this.isFocused; } if (this.currentAnimationIndex != this.previousAnimationIndex) { officeWorld.NotifyObjectAnimationChanged(this, this.currentAnimationIndex); this.previousAnimationIndex = this.currentAnimationIndex; } if (this.speedVector != null && (this.speedVector.X != 0 || this.speedVector.Y != 0)) { this.position += this.speedVector * timeElapsed.AsSeconds(); } if (this.previousPosition.X != this.position.X || this.previousPosition.Y != this.position.Y) { officeWorld.NotifyObjectPositionChanged(this, this.position); this.previousPosition = new Vector2f(this.position.X, this.position.Y); } }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (details.Equals("endDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; if (dialogue == lObject) { AObject patient = world.GetObjectFromId("patient main"); if (this.isSuccess) { patient.SetAnimationIndex(8); } else { patient.SetAnimationIndex(7); } this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(2); this.moment = ExposePhaseMoment.END_DIALOGUE; } } else if (details.Equals("speedUpDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; dialogue.SpeedFactor = 10; } }
public MainWindow() { this.officeWorld = new OfficeWorld(); this.object2DManager = new Object2DManager(this.officeWorld); this.objectFocused = null; }
public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.associatedToken != this.previousAssociatedToken) { if (this.associatedToken != null) { AToken nextToken = this.NextToken; int i = 0; while (nextToken != null) { if (i == 0) { officeWorld.NotifyTextUpdated(nextToken, nextToken.PreviousToken, this.associatedToken, this.InitialPosition); } else { officeWorld.NotifyTextUpdated(nextToken, nextToken.PreviousToken, null, this.InitialPosition); } i++; nextToken = nextToken.NextToken; } officeWorld.NotifyInternalGameEvent(this.previousAssociatedToken, this.associatedToken, "association"); } this.previousAssociatedToken = this.associatedToken; } base.UpdateLogic(officeWorld, timeElapsed); }
public Object2DManager(OfficeWorld world) { //this.SizeScreen = new Vector2f(800, 600); this.textureManager = new TextureManager(); this.fontManager = new FontManager(); this.soundManager = new SoundManager(); this.layersList = new List <LayerObject2D>(); this.initializeResources(); this.mappingLayerToLayerObject2D = new Dictionary <ALayer, LayerObject2D>(); this.mappingObjectToObject2D = new Dictionary <AObject, AObject2D>(); world.ResourcesToLoad += OnResourcesToLoad; world.LayerCreated += OnLayerCreated; world.LayerDestroyed += OnLayerDestroyed; world.ObjectCreated += OnObjectCreated; world.ObjectDestroyed += OnObjectDestroyed; world.ObjectPositionChanged += OnObjectPositionChanged; world.TextPositionChanged += OnTextPositionChanged; world.ObjectFocusChanged += OnObjectFocusChanged; world.ObjectAnimationChanged += OnObjectAnimationChanged; world.ObjectTextChanged += OnObjectTextChanged; world.ObjectTextStateChanged += OnObjectTextStateChanged; world.TextUpdated += OnTextUpdated; world.GameStateChanged += OnGameStateChanged; }
public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.previousAnimationIndex != this.currentAnimationIndex) { if (this.previousAnimationIndex == 2) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.END_TALK, "dialogueReflexion")); } if (this.currentAnimationIndex == 2) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.START_TALK, "dialogueReflexion")); } if (this.previousAnimationIndex == 3) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.END_TALK, "dialogueToubib")); } if (this.currentAnimationIndex == 3) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.START_TALK, "dialogueToubib")); } } base.UpdateLogic(officeWorld, timeElapsed); }
public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.previousAnimationIndex != this.currentAnimationIndex) { if (this.previousAnimationIndex == 4) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.END_TALK, "dialoguePatientFail")); } if (this.currentAnimationIndex == 4) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.START_TALK, "dialoguePatientFail")); } if (this.previousAnimationIndex == 5) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.END_TALK, "dialoguePatientSuccess")); } if (this.currentAnimationIndex == 5) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.START_TALK, "dialoguePatientSuccess")); } if (this.previousAnimationIndex == 2) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.END_TALK, "dialoguePatient")); } if (this.currentAnimationIndex == 2) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.START_TALK, "dialoguePatient")); } if (this.currentAnimationIndex == 1) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.DOOR_OPEN, "dialoguePatient")); } if (this.currentAnimationIndex == 6) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.DOOR_KNOCK, "dialoguePatient")); } if (this.currentAnimationIndex == 7) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.VALIDATION, "fail")); } if (this.currentAnimationIndex == 8) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.VALIDATION, "success")); } } base.UpdateLogic(officeWorld, timeElapsed); }
public override void VisitEnd(OfficeWorld world) { base.VisitEnd(world); LevelNode firstLevelNode = world.CreateGame("Levels", 5); // Level links this.NextNode = firstLevelNode; }
public override void VisitEnd(OfficeWorld world) { if (this.isSuccess) { world.NbHappyPatient++; } base.VisitEnd(world); }
public override void UpdateLogic(OfficeWorld world, Time timeElapsed) { this.timeElapsed += timeElapsed; if (this.timeElapsed > periodPhase) { this.NodeState = NodeState.NOT_ACTIVE; } }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { DialogueObject dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; if (dialogue == lObject) { this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(1); this.moment = PrePhaseMoment.TEXT_APPEARED; } }
public override void UpdateLogic(OfficeWorld world, Time timeElapsed) { this.timeElapsed += timeElapsed; if (this.timeElapsed > periodPhase) { switch (this.moment) { case PrePhaseMoment.START: AObject bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(1); AObject toubib = world.GetObjectFromId("toubib main"); toubib.SetAnimationIndex(3); this.moment = PrePhaseMoment.BUBBLE_APPEARED; this.periodPhase = Time.FromSeconds(1.2f); this.timeElapsed = Time.Zero; break; case PrePhaseMoment.BUBBLE_APPEARED: DialogueObject dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; dialogue.SetKinematicParameters(new Vector2f(-380f, dialogue.GetHeight(-150)), new Vector2f(0f, 0f)); dialogue.LaunchDialogue(1); AObject queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(100f, 100f), new Vector2f(0f, 0f)); bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(2); this.moment = PrePhaseMoment.START_TALKING; break; case PrePhaseMoment.TEXT_APPEARED: dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; dialogue.ResetDialogue(); bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(3); queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0)); this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(1); this.moment = PrePhaseMoment.END; break; case PrePhaseMoment.END: this.NodeState = NodeState.NOT_ACTIVE; break; } } }
public override void Dispose(OfficeWorld world) { foreach (List <AToken> tokens in this.tokensList) { foreach (AToken token in tokens) { token.NextToken = null; token.PreviousToken = null; } } }
/* public override void SetKinematicParameters(Vector2f position, Vector2f speedVector) * { * base.SetKinematicParameters(position, speedVector); * * foreach(List<AToken> tokens in this.tokensList) * { * foreach (AToken token in tokens) * { * token.SetKinematicParameters(position, speedVector); * } * } * }*/ public void AddTokenToWorld(OfficeWorld world, int indexLayer) { foreach (List <AToken> tokens in this.tokensList) { foreach (AToken token in tokens) { world.AddObject(token, indexLayer); token.SetKinematicParameters(new Vector2f(-1000, -1000), new Vector2f(0, 0)); } } }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (details.Equals("association")) { AToken token = (lObjectTo as AToken); /*DialogueObject dialogue = world.GetObjectFromId((lObject as FieldToken).AssociatedToken) as DialogueObject; * dialogue.ResetDialogue();*/ token.DisplayText = string.Empty; this.isValidated = true; this.timeElapsed = Time.Zero; } }
public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.previousAnimationIndex != this.currentAnimationIndex) { if (this.currentAnimationIndex == 1) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.OPEN_BUBBLE, string.Empty)); } else if (this.currentAnimationIndex == 3) { officeWorld.NotifyGameStateChanged(officeWorld.CurrentLevel.LevelName, new GameEvent(EventType.CLOSE_BUBBLE, string.Empty)); } } base.UpdateLogic(officeWorld, timeElapsed); }
public bool ValidateField(OfficeWorld world) { if (this.associatedToken != null) { this.text = this.associatedToken.Text; if (this.trueText.ToLower().Equals(this.associatedToken.Text.ToLower())) { world.NotifyObjectTextStateChanged(this, true); return(true); } } world.NotifyObjectTextStateChanged(this, false); return(false); }
public override void UpdateLogic(OfficeWorld world, Time timeElapsed) { this.timeElapsed += timeElapsed; if (this.timeElapsed > periodPhase) { switch (this.moment) { case ExposePhaseMoment.START: DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; dialogue.LaunchDialogue(2); AObject queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(100f, 100f), new Vector2f(0f, 0f)); AObject bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(2); this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(2); this.moment = ExposePhaseMoment.BUBBLE_APPEARED; break; case ExposePhaseMoment.END_DIALOGUE: dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; dialogue.ResetDialogue(); bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(3); queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0)); this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(2); this.moment = ExposePhaseMoment.END; break; case ExposePhaseMoment.END: this.NodeState = NodeState.NOT_ACTIVE; break; } } }
public override void VisitStart(OfficeWorld world) { base.VisitStart(world); DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; this.isSuccess = dialogue.IsSuccess; AObject toubib = world.GetObjectFromId("toubib main"); toubib.SetAnimationIndex(3); AObject bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(1); this.periodPhase = Time.FromSeconds(1.2f); this.timeElapsed = Time.Zero; }
public void ValidateDialogue(OfficeWorld world) { this.nbAnswer = 0; this.nbGoodAnswer = 0; foreach (List <AToken> tokens in this.tokensList) { IEnumerable <AToken> fieldTokens = tokens.Where(pElem => pElem is FieldToken); this.nbAnswer += fieldTokens.Count(); foreach (FieldToken fieldToken in fieldTokens) { if (fieldToken.ValidateField(world)) { this.nbGoodAnswer++; } } } }
public void Dispose(OfficeWorld world) { world.ResourcesToLoad -= OnResourcesToLoad; world.LayerCreated -= OnLayerCreated; world.LayerDestroyed -= OnLayerDestroyed; world.ObjectCreated -= OnObjectCreated; world.ObjectDestroyed -= OnObjectDestroyed; world.ObjectPositionChanged -= OnObjectPositionChanged; world.ObjectFocusChanged -= OnObjectFocusChanged; world.TextPositionChanged -= OnTextPositionChanged; world.ObjectAnimationChanged -= OnObjectAnimationChanged; world.ObjectTextChanged -= OnObjectTextChanged; world.ObjectTextStateChanged -= OnObjectTextStateChanged; world.TextUpdated -= OnTextUpdated; world.GameStateChanged -= OnGameStateChanged; }
public override void UpdateLogic(OfficeWorld officeWorld, Time timeElapsed) { if (this.duration != Time.Zero) { if (this.duration < this.elapsedTime) { this.duration = Time.Zero; this.elapsedTime = Time.Zero; this.SetKinematicParameters(this.position, new Vector2f(0, 0)); } else { this.elapsedTime += timeElapsed; } } base.UpdateLogic(officeWorld, timeElapsed); }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (details.Equals("endDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue patient") as DialogueObject; if (dialogue == lObject) { this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(3); this.moment = StartPhaseMoment.TEXT_APPEARED; } } else if (details.Equals("speedUpDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue patient") as DialogueObject; dialogue.SpeedFactor = 10; } }
public override void UpdateLogic(OfficeWorld world, Time timeElapsed) { if (this.NodeState == NodeState.ACTIVE) { if (this.currentPhaseNode == null) { this.currentPhaseNode = this.phaseNodes[0]; this.currentPhaseNode.VisitStart(world); } else if (this.currentPhaseNode.NodeState == NodeState.NOT_ACTIVE) { if (this.currentPhaseNode is ResolvePhase) { this.isSuccess = (this.currentPhaseNode as ResolvePhase).IsSuccess; } this.currentPhaseNode.VisitEnd(world); if (this.currentPhaseNode.NextNode == null) { this.currentPhaseNode = null; } else { this.currentPhaseNode = this.currentPhaseNode.NextNode as APhaseNode; this.currentPhaseNode.VisitStart(world); } } if (this.currentPhaseNode != null) { this.currentPhaseNode.UpdateLogic(world, timeElapsed); } else { this.NodeState = NodeState.NOT_ACTIVE; } } }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (this.moment == ThinkPhaseMoment.START_TIMER) { if (details.Equals("timerPassed")) { this.EndTimerAction(world); } else if (details.Equals("association")) { AToken tokenTo = lObjectTo as AToken; if (lObject != null) { AToken tokenFrom = lObject as AToken; tokenFrom.DisplayText = tokenFrom.Text; } tokenTo.DisplayText = string.Empty; } } }
public override void VisitStart(OfficeWorld world) { base.VisitStart(world); world.NbPatient++; AObject patient = world.GetObjectFromId("patient main"); AObject toubib = world.GetObjectFromId("toubib main"); //AObject test = world.GetObjectFromId("test"); patient.SetAnimationIndex(1); toubib.SetAnimationIndex(2); DialogueObject dialogue = world.GetObjectFromId("dialogue patient") as DialogueObject; dialogue.SetKinematicParameters(new Vector2f(-100f, -200f), new Vector2f(0f, 0f)); this.periodPhase = Time.FromSeconds(3); this.timeElapsed = Time.Zero; }
public override void VisitStart(OfficeWorld world) { base.VisitStart(world); AObject patient = world.GetObjectFromId("patient main"); AObject toubib = world.GetObjectFromId("toubib main"); patient.SetAnimationIndex(3); toubib.SetAnimationIndex(2); DialogueObject dialogue = world.GetObjectFromId("dialogue patient") as DialogueObject; dialogue.ResetDialogue(); //dialogue.SetKinematicParameters(new Vector2f(-100f, -200f), new Vector2f(0f, 0f)); DialogueObject dialogueToubib = world.GetObjectFromId("dialogue toubib") as DialogueObject; dialogueToubib.SetKinematicParameters(new Vector2f(-380f, dialogueToubib.GetHeight(-150)), new Vector2f(0f, 0f)); AObject queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0f, 0f)); AObject noteblock = world.GetObjectFromId("notebook main"); (noteblock as NotebookObject).SetTransition(new Vector2f(-600, 600), new Vector2f(0, -150), Time.FromSeconds(3)); AObject bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(1); AObject timer = world.GetObjectFromId("timer main"); timer.SetAnimationIndex(1); timer.SetKinematicParameters(new Vector2f(320, 200), new Vector2f(0f, 0f)); this.periodPhase = Time.FromSeconds(1.2f); this.timeElapsed = Time.Zero; }
public override void UpdateLogic(OfficeWorld officeWorld, Time TimeElapsed) { if (this.isDialogueLaunched && this.currentTokenRowIndex < this.tokensList.Count) { if (this.currentTokenIndex < 0 || this.tokensList[this.currentTokenRowIndex][this.currentTokenIndex].IsTextFull) { this.currentTokenIndex++; if (this.currentTokenIndex >= this.tokensList[this.currentTokenRowIndex].Count) { this.currentTokenRowIndex++; this.currentTokenIndex = 0; if (this.currentTokenRowIndex != 0 && this.currentTokenRowIndex < this.tokensList.Count && this.currentTokenRowIndex % 8 == 0) { this.ResetUntilRow(this.currentTokenRowIndex); } } if (this.currentTokenRowIndex < this.tokensList.Count && this.currentTokenIndex < this.tokensList[this.currentTokenRowIndex].Count) { Vector2f newPosition = new Vector2f(this.position.X, this.position.Y + (this.currentTokenRowIndex % 8) * this.rowHeight); this.tokensList[this.currentTokenRowIndex][this.currentTokenIndex].InitialPosition = newPosition; this.tokensList[this.currentTokenRowIndex][this.currentTokenIndex].SetKinematicParameters(newPosition, new Vector2f(0, 0)); this.tokensList[this.currentTokenRowIndex][this.currentTokenIndex].LaunchText(this.speedFactor); } } } if (this.IsDialogueFull && this.isDialogueLaunched) { officeWorld.NotifyInternalGameEvent(this, null, "endDialogue"); this.isDialogueLaunched = false; } }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (details.Equals("endDialogue")) { DialogueObject dialogue; AObject patient = world.GetObjectFromId("patient main"); if (this.isSuccess) { dialogue = world.GetObjectFromId("dialogue successAnswer") as DialogueObject; } else { dialogue = world.GetObjectFromId("dialogue failAnswer") as DialogueObject; } if (dialogue == lObject) { this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(3); this.moment = ResolvePhaseMoment.END_DIALOGUE; } } else if (details.Equals("speedUpDialogue")) { DialogueObject dialogue; if (this.isSuccess) { dialogue = world.GetObjectFromId("dialogue successAnswer") as DialogueObject; } else { dialogue = world.GetObjectFromId("dialogue failAnswer") as DialogueObject; } dialogue.SpeedFactor = 10; } }