public void LoadZone(OverworldObject playerUnit) { Debug.Log("LOADING AREA: " + instanceJSONFileName); Instance instance = new Instance(instanceJSONFileName); UtilityFunctions.GetActiveUnitDetector().LoadNewInstance(instance, spawnLocation, playerUnit); }
private void UpdateGUI(OverworldObject marker) { labelConnections.Text = String.Format("Level {0} Connections", selectedMarker); connections[(int)Connection.East].Text = marker.East.ToString(); connections[(int)Connection.West].Text = marker.West.ToString(); connections[(int)Connection.North].Text = marker.North.ToString(); connections[(int)Connection.South].Text = marker.South.ToString(); exits[(int)Exit.Normal].Text = marker.NormalExit.ToString(); exits[(int)Exit.Secret].Text = marker.SecretExit.ToString(); coords[(int)Coords.X].Text = marker.X.ToString(); coords[(int)Coords.Y].Text = marker.Y.ToString(); if (marker.DoorKey == 0) { doorKeyCombo.SelectedIndex = -1; doorKey.Text = ""; } else if ((marker.DoorKey & 0x80) == 0) { doorKeyCombo.SelectedIndex = (int)DoorKey.Door; doorKey.Text = marker.DoorKey.ToString(); } else { doorKeyCombo.SelectedIndex = (int)DoorKey.Key; doorKey.Text = (256 - marker.DoorKey).ToString(); } }
/// <summary> /// Teleports a given <see cref="OverworldObject"/> to specified location. /// </summary> /// <param name="overworldObject">OverworldObject attempting to travel.</param> /// <param name="to">Location to travel to.</param> /// <returns>Returns true if the overworld object moved successfully, and false otherwise.</returns> public bool BlinkTo(OverworldObject overworldObject, Vector3Int to, bool ignoreUnits) { bool valid = false; if (ignoreUnits) { valid = IsTileOpen(to, true); } else { valid = IsTileOpen(to, false); } if (valid) { Vector3Int oldPosition = overworldObject.position; overworldObject.position = to; SetSurroundingTileOpacity(oldPosition, overworldObject.position); UtilityFunctions.SetSpriteDefaultPosition(overworldObject.overworldObjectCoordinator); if (overworldObject == UtilityFunctions.GetActivePlayer().GetCurrentOverworldObject()) { overworldObject.overworldObjectCoordinator.SetCameraPosition(); } return(true); } return(false); }
/// <summary> /// Adds the basic player overworld object actions to the current overworld object. /// </summary> /// <param name="overworldObject">The overworld object to add the actions to.</param> private void AttachPlayerOverworldObjectActions(OverworldObject overworldObject) { overworldObject.AddOverworldObjectAction(new TestOWOAction(ControllerInputs.TopFace, KeyCode.None, overworldObject)); overworldObject.AddOverworldObjectAction(new Interact(ControllerInputs.RightFace, KeyCode.None, overworldObject)); overworldObject.AddOverworldObjectAction(new Jump(ControllerInputs.BottomFace, KeyCode.Space, overworldObject)); overworldObject.AddOverworldObjectAction(new ToggleRun(ControllerInputs.RightBumper, KeyCode.LeftShift, overworldObject)); overworldObject.AddOverworldObjectAction(new ToggleStationary(ControllerInputs.LeftBumper, KeyCode.None, overworldObject)); }
/// <summary> /// Adds an overworld object to the unit detector at a given position. /// </summary> /// <param name="overworldObject">The overworld object to be added.</param> /// <param name="position">The position to place the overworld object at.</param> public void SpawnOverworldObject(OverworldObject overworldObject, Vector3Int position) { overworldObject.position = position; overworldObjects.Add(overworldObject); UtilityFunctions.SetSpriteDefaultPosition(overworldObject.overworldObjectCoordinator); if (overworldObject is Unit) { CheckHitboxesAtUnit((Unit)overworldObject); } }
/// <summary> /// Checks if a unit is currently in the air. /// </summary> /// <param name="unit">Unit to check.</param> /// <returns>Returns true if the unit is airborne, and false otherwise.</returns> public bool IsAirborne(OverworldObject overworldObject) { Vector3Int currentPosition = overworldObject.position; currentPosition.x++; currentPosition.y++; currentPosition.z--; if (geography.HasTile(currentPosition)) { return(false); } return(true); }
public void Draw(SpriteBatch spriteBatch) { _game.GraphicsDevice.SetRenderTarget(_renderTarget); _game.GraphicsDevice.Clear(Color.Transparent); Texture2D map = Load.OverworldMap; spriteBatch.Begin(); spriteBatch.Draw(map, new Rectangle(0, 0, map.Width * SCALE, map.Height * SCALE), Color.White); //test foreach (OverworldObject marker in markers) { /* * if (marker.East >= 0 && marker.East < NUM_MARKERS) * { * DrawConnectorDots(spriteBatch, marker.X, markers[marker.East].X, marker.Y, markers[marker.East].Y); * }*/ // A quirk of all the level markers in Paradise - they all have 1 westward connection to the previous level that unlocks it (except the first level)! if (marker.West >= 0 && marker.West < NUM_MARKERS) { DrawConnectorDots(spriteBatch, marker.X, markers[marker.West].X, marker.Y, markers[marker.West].Y); } /* * if (marker.North >= 0 && marker.North < NUM_MARKERS) * { * DrawConnectorDots(spriteBatch, marker.X, markers[marker.North].X, marker.Y, markers[marker.North].Y); * } * if (marker.South >= 0 && marker.South < NUM_MARKERS) * { * DrawConnectorDots(spriteBatch, marker.X, markers[marker.South].X, marker.Y, markers[marker.South].Y); * }*/ } //Connector dots go behind level/hat markers foreach (OverworldObject marker in markers) { marker.Draw(spriteBatch); } if (selectedMarker != -1) { OverworldObject m = markers[selectedMarker]; Texture2D sm = Load.SelectedMarker; spriteBatch.Draw(sm, new Rectangle((m.X - 2 + m.xOffset) * SCALE, (m.Y - 2 + m.yOffset) * SCALE, (m.size + 4) * SCALE, (m.size + 4) * SCALE), Color.White); } spriteBatch.End(); _game.GraphicsDevice.SetRenderTarget(null); }
/// <summary> /// Changes the current unit detector instance. /// </summary> /// <param name="instance">The instance that the unit detector will change to.</param> /// <param name="spawnPosition">The position where the player will be placed at.</param> public void LoadNewInstance(Instance instance, Vector3Int spawnPosition, OverworldObject playerUnit) { OverworldObject player = playerUnit; string playerUnitJSONFileName; int playerLevel; int playerProgressionPoint; ResetUnitDetector(); //Unit newPlayerUnit = new Unit(playerUnitJSONFileName, playerLevel, TargetTypes.Ally); SwapGeography(instance.GetGeographyName()); // stuff regarding: resetting unit detector, placing player unit, setting instance special tiles (+ spawning units) ? if (instance.GetUnitSpawners() != null) { unitSpawners = new List <UnitSpawner>(); foreach (UnitSpawner unitSpawner in instance.GetUnitSpawners()) { AddUnitSpawner(unitSpawner); } } if (instance.GetLoadingZones() != null) { loadingZones = new List <LoadingZone>(); foreach (LoadingZone loadingZone in instance.GetLoadingZones()) { loadingZones.Add(loadingZone); } } MarkLoadingZones(); currentInstance = instance; //UtilityFunctions.GetActiveGeology().SetLocation(instance); UtilityFunctions.GetActiveUnitDetector().SpawnOverworldObject(playerUnit, spawnPosition); UtilityFunctions.GetActivePlayer().SetCurrentOverworldObject(playerUnit); //UtilityFunctions.SetSpriteDefaultPosition(playerUnit.overworldObjectCoordinator); //InitializeInstance(spawnPosition, leadUnit); }
void loadData() { Load.LoadOverworldMap(_game.GraphicsDevice); Load.LoadOverworldObjects(_game.GraphicsDevice); string[] lines = Utils.SplitNonEmptyLines(File.ReadAllText(Levels.GetOverworldMarkerPath())); uint[,] table = Utils.LinesToUintTable(lines, lines.Length, 9, false); markers = new OverworldObject[NUM_MARKERS]; for (int i = 0; i < NUM_MARKERS; i++) { uint[] row = Enumerable.Range(0, table.GetLength(1)) .Select(x => table[i, x]) .ToArray(); MarkerType type = (i + 1 < FIRST_MAGIC_HAT) ? MarkerType.NormalLevel : MarkerType.MagicHat; markers[i] = new OverworldObject(row, type); } }
/// <summary> /// Prevents movement from an <see cref="OverworldObject"/> for a specified amount of time. /// </summary> /// <param name="overworldObject">The overworldObject to have its movement delayed.</param> /// <param name="z">The amount of tiles travelled in the Z-axis.</param> private void DelayMovements(OverworldObject overworldObject, int z) { if (z == 0) { overworldObject.canMove = false; controllerReference.StartCoroutine(overworldObject.UnlockMovement()); } if (z > 0) { overworldObject.canAscend = false; controllerReference.StartCoroutine(overworldObject.UnlockAscent()); } else if (z < 0) { overworldObject.canDescend = false; controllerReference.StartCoroutine(overworldObject.UnlockDescent()); } }
public Interact(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) : base(controllerInput, keyboardInput, overworldObject) { }
/// <summary> /// Removes an overworld object from the unit detector. /// </summary> /// <param name="overworldObject">The overworld object to be removed.</param> public void RemoveOverworldObject(OverworldObject overworldObject) { overworldObjects.Remove(overworldObject); overworldObject.overworldObjectCoordinator.StopAllCoroutines(); GameObject.Destroy(overworldObject.overworldObjectCoordinator.gameObject); }
public OverworldObjectAction(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) { this.controllerInput = controllerInput; this.keyboardInput = keyboardInput; this.overworldObject = overworldObject; }
public UseSkill(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject, Skill skill) : base(controllerInput, keyboardInput, overworldObject) { this.skill = skill; }
public ToggleManualMovement(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) : base(controllerInput, keyboardInput, overworldObject) { }
public ToggleTurn(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) : base(controllerInput, keyboardInput, overworldObject) { }
public FloatDescend(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) : base(controllerInput, keyboardInput, overworldObject) { }
public void SetCurrentOverworldObject(OverworldObject overworldObject) { currentOverworldObject = overworldObject; AttachPlayerOverworldObjectActions(currentOverworldObject); overworldObject.overworldObjectCoordinator.SetCameraPosition(); }
public TestOWOAction(ControllerInputs controllerInput, KeyCode keyboardInput, OverworldObject overworldObject) : base(controllerInput, keyboardInput, overworldObject) { }
/// <summary> /// Translates a unit a specified value in the X, Y and Z planes. /// </summary> /// <param name="unit">The unit whose position will be translated.</param> /// <param name="x">Amount of tiles to travel in the X axis.</param> /// <param name="y">Amount of tiles to travel in the Y axis.</param> /// <param name="z">Amount of tiles to travel in the Z axis.</param> /// <returns>Returns true if the overworld object moved successfully, and false otherwise.</returns> public bool Move(OverworldObject overworldObject, int x, int y, int z) { Vector3Int zyTranslation = UtilityFunctions.TranslateZAsY(new Vector3Int(x, y, z)); x = zyTranslation.x; y = zyTranslation.y; Vector3Int currentPosition = overworldObject.position; Vector3Int newPosition = new Vector3Int(currentPosition.x + x, currentPosition.y + y, currentPosition.z + z); Vector3Int highestFloorTile = GetHighestFloorTileAtPosition(newPosition); Directions moveDirection; if (Math.Abs(x) > Math.Abs(y)) { if (x >= 0) { moveDirection = Directions.NE; } else { moveDirection = Directions.SW; } } else if (Math.Abs(x) < Math.Abs(y)) { if (y >= 0) { moveDirection = Directions.NW; } else { moveDirection = Directions.SE; } } else { moveDirection = overworldObject.direction; } if (overworldObject.canTurn) { overworldObject.direction = moveDirection; } if (IsTileOpen(newPosition, false) && !overworldObject.isStationary && !geography.HasTile(newPosition) && highestFloorTile.z != -255) { Vector3Int oldPosition = overworldObject.position; Vector3Int tileToPlace = newPosition; overworldObject.position = tileToPlace; DelayMovements(overworldObject, z); if (overworldObject is Unit) { CheckHitboxesAtUnit((Unit)overworldObject); } //if unit moved was the player, check for loading zones if (UtilityFunctions.GetActivePlayer().GetCurrentOverworldObject().Equals(overworldObject)) { LoadingZone loadingZone = GetLoadingZoneAtPosition(overworldObject.position); if (loadingZone != null /*&& !UtilityFunctions.GetActiveEncounter().IsEncounterActive()*/) { loadingZone.LoadZone(overworldObject); } } return(true); } return(false); }