public void ActivateDialog(Dialog dialog, MapObject dismissReference) { this.dismissReference = dismissReference; currentDialog = dialog; dialogActive = true; NextMessage(); }
public void RunScript(int id, MapObject caller) { currentCommand = 0; this.caller = caller; currentScript = Global.GetScript(id); currentPage = GetCurrentPage(); NextCommand(); }
public void NextMessage() { if (IsDialogActive()) { // Resets animation index animationIndex = 0; animatedText = ""; // If there's animation, just show the whole text if (isAnimating) { isAnimating = false; return; } // Checks if there's a remaining text if (remainingText != null && remainingText != "") { currentText = GetCurrentText(remainingText); remainingText = null; return; } // Finishes the dialog if (nextTextIndex >= currentDialog.Messages.Count()) { nextTextIndex = 0; dialogActive = false; currentDialog = null; currentText = ""; if (ScriptInterpreter.Instance.IsScriptRunning()) { ScriptInterpreter.Instance.FinishedCommand(); } else { if (dismissReference != null) dismissReference.Dismiss(); dismissReference = null; } } else // or shows the next message { currentText = GetCurrentText(currentDialog.Messages[nextTextIndex]); nextTextIndex++; } } }
private void DrawObjectName(MapObject obj, SpriteBatch spriteBatch) { // Draw the name if (obj.Name != null && obj.SavedInformation.IsActive) { Vector2 textSize = Global.MapFont.MeasureString(obj.Name); int zoom = (int)CameraManager.Instance.Zoom; spriteBatch.DrawString(Global.MapFont, obj.Name, new Vector2(obj.CurrentPosition.X + (Global.TileSize / 2) - (textSize.X / 2), obj.CurrentPosition.Y - Global.MapFont.LineSpacing) + new Vector2(1, 1), new Color(Color.Black, 0.5f)); spriteBatch.DrawString(Global.MapFont, obj.Name, new Vector2(obj.CurrentPosition.X + (Global.TileSize / 2) - (textSize.X / 2), obj.CurrentPosition.Y - Global.MapFont.LineSpacing), obj.NameColor); } }
private void DrawObject(MapObject obj) { int size = Global.TileSize; int textureId = obj.GetSprite(); Texture2D texture = obj.Texture; Vector2 currentPosition = obj.CurrentPosition; spriteBatch.Draw(texture, new Rectangle((int)currentPosition.X, (int)currentPosition.Y, size, size), Utils.GetRectangleByGid(textureId, size, texture.Width), Color.White); }
private void UpdateObject(MapObject obj, double timePassed) { int size = Global.TileSize; Vector2 currentPosition = obj.CurrentPosition; Vector2 destinationPosition = obj.DestinationPosition; Vector2 mapPosition = obj.MapPosition; double lerpTime = obj.LerpTime; currentPosition = mapPosition * size; // Calculate moving animation if (obj.IsMoving) { int x = (int)(currentPosition.X + (destinationPosition.X - currentPosition.X) * lerpTime); int y = (int)(currentPosition.Y + (destinationPosition.Y - currentPosition.Y) * lerpTime); currentPosition = new Vector2(x, y); lerpTime += timePassed * obj.AnimationSpeed; // Finished movement if (lerpTime >= 1) { lerpTime = 0; obj.IsMoving = false; mapPosition = destinationPosition / size; mustTeleport = currentMap.GetCollision(mapPosition) == 2; if (mustTeleport) teleportObject = (Teleport)currentMap.GetObject(mapPosition); } } obj.CurrentPosition = currentPosition; obj.DestinationPosition = destinationPosition; obj.MapPosition = mapPosition; obj.LerpTime = lerpTime; }