public InteractiveDialoguePane(Screen screen, UIAlignment alignment, int x, int y, int width, int height, SpriteFont dialogueFont, SpriteFont optionFont, CharacterDialogueComponent dialogueComponent) : base(screen, alignment, x, y, width, height) { _dialogueComponent = dialogueComponent; _dialogueFont = dialogueFont; _optionFont = optionFont; _dialogueManager = DataManager.dialogueManager; _maxLineWidth = (float)_width - _margin * 2f; _optionButtons = new List <TextButton>(); setCurrentNodeUid(_dialogueManager.getCurrentDialogueNodeUid(dialogueComponent.dialogueUid)); }
public InteractiveDialoguePane(Screen screen, UIAlignment alignment, int x, int y, int width, int height, SpriteFont dialogueFont, SpriteFont optionFont, CharacterDialogueComponent dialogueComponent) : base(screen, alignment, x, y, width, height) { _dialogueComponent = dialogueComponent; _dialogueFont = dialogueFont; _optionFont = optionFont; _dialogueManager = DataManager.dialogueManager; _maxLineWidth = (float)_width - _margin * 2f; _optionButtons = new List<TextButton>(); setCurrentNodeUid(_dialogueManager.getCurrentDialogueNodeUid(dialogueComponent.dialogueUid)); }
public void beginDialogue(string levelUid, int entityA, int entityB, CharacterDialogueComponent dialogueComponent) { ScreenSystem screenSystem = _systemManager.getSystem(SystemType.Screen) as ScreenSystem; LevelScreen levelScreen = screenSystem.getScreen(ScreenType.Level) as LevelScreen; _currentEntityA = entityA; _currentEntityB = entityB; _currentDialogueComponent = dialogueComponent; _entityManager.addComponent(levelUid, entityA, new InDialogueComponent()); _entityManager.addComponent(levelUid, entityB, new InDialogueComponent()); levelScreen.addDialoguePane(dialogueComponent); }
public void removeDialoguePane(CharacterDialogueComponent dialogueComponent) { InteractiveDialoguePane pane = null; for (int i = 0; i < _dialogePanes.Count; i++) { if (_dialogePanes[i].dialogueComponent == dialogueComponent) { pane = _dialogePanes[i]; } } _transitions.Add(new ScaleTransition(pane, 1f, 0.1f, false, 0.1f, () => { pane.showText = false; }, () => { _dialogePanes.Remove(pane); })); }
public void addDialoguePane(CharacterDialogueComponent dialogueComponent) { InteractiveDialoguePane pane = new InteractiveDialoguePane( this, UIAlignment.MiddleCenter, 0, 0, 600, 300, _dialogueFont, _dialogueOptionFont, dialogueComponent); pane.scale = 0f; _dialogePanes.Add(pane); _transitions.Add(new ScaleTransition(pane, 0.1f, 1f, false, 0.1f, null, () => { pane.showText = true; })); }
// Handle dialogue private void handleDialogue(string levelUid, PhysicsComponent playerPhysicsComponent, bool inDialogue) { DialogueSystem dialogueSystem = _systemManager.getSystem(SystemType.Dialogue) as DialogueSystem; List <int> dialogueEntities = _entityManager.getEntitiesPosessing(levelUid, ComponentType.CharacterDialogue); for (int i = 0; i < dialogueEntities.Count; i++) { PhysicsComponent otherPhysicsComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.Physics) as PhysicsComponent; Vector2 relative = playerPhysicsComponent.body.Position - otherPhysicsComponent.body.Position; float distanceSq = relative.LengthSquared(); if (_newKeyState.IsKeyDown(Keys.E) && _oldKeyState.IsKeyUp(Keys.E)) { if (!inDialogue && distanceSq <= 1f) { CharacterDialogueComponent dialogueComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.CharacterDialogue) as CharacterDialogueComponent; dialogueSystem.beginDialogue(levelUid, PlayerSystem.PLAYER_ID, dialogueEntities[i], dialogueComponent); } } else { TooltipComponent tooltipComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.Tooltip) as TooltipComponent; if (tooltipComponent == null) { if (!inDialogue && distanceSq <= 1f) { _entityManager.addComponent(levelUid, dialogueEntities[i], new TooltipComponent("[Use] Talk", otherPhysicsComponent.body, 1f)); } } else { if (inDialogue || distanceSq > 1f) { _entityManager.removeComponent(levelUid, dialogueEntities[i], ComponentType.Tooltip); } } } } }