//Function called from Update to shift the map based on the player party's current location private void RepositionMap() { //Finding the selected party's tile so we know where the map should show TileInfo partyTile = CharacterManager.globalReference.selectedGroup.GetComponent <WASDOverworldMovement>().currentTile; //If the party tile is different from before, we update the tile position if (this.currentTile == null || this.currentTile != partyTile) { //Setting our current tile to the party tile this.currentTile = partyTile; //Getting the row and column of the current tile CreateTileGrid.TileColRow newTileColRow = CreateTileGrid.globalReference.GetTileCoords(partyTile); if (newTileColRow != null) { //Getting the rect transform component for this game object RectTransform ourRect = this.GetComponent <RectTransform>(); //Setting the pivot position based on the offsets ourRect.pivot = new Vector2((newTileColRow.col * 1f) / (CreateTileGrid.globalReference.cols * 1f), (newTileColRow.row * 1f) / (CreateTileGrid.globalReference.rows * 1f)); //Re-centering the map sprite so that our pivot position is now at 0,0 in the middle of the minimap ourRect.localPosition = new Vector3(); } } }
//Constructor function for this class public PartySaveData(PartyGroup groupToSave_) { this.combatDist = groupToSave_.combatDistance; CreateTileGrid.TileColRow tileLocation = CreateTileGrid.globalReference.GetTileCoords(groupToSave_.GetComponent <WASDOverworldMovement>().currentTile); this.tileCol = tileLocation.col; this.tileRow = tileLocation.row; //Looping through all of the characters in the given party and getting their save data this.partyCharacters = new List <global::CharacterSaveData>(); for (int c = 0; c < groupToSave_.charactersInParty.Count; ++c) { //If the current character isn't null, we save it's data if (groupToSave_.charactersInParty[c] != null) { CharacterSaveData charData = new CharacterSaveData(groupToSave_.charactersInParty[c]); this.partyCharacters.Add(charData); } //If the current character slot is null, we add the empty slot else { this.partyCharacters.Add(null); } } }
//Constructor function for this class public EnemyTileEncounterInfo(EnemyEncounter encounter_) { //Getting the object prefab for the encounter this.encounterPrefab = encounter_.encounterPrefab; //Getting the tile that this encounter is on CreateTileGrid.TileColRow encounterCoords = CreateTileGrid.globalReference.GetTileCoords(encounter_.GetComponent <Movement>().currentTile); this.encounterTileCol = encounterCoords.col; this.encounterTileRow = encounterCoords.row; }
// Update is called once per frame private void Update() { //Finding the party group's row and col coords in the overworld CreateTileGrid.TileColRow partyColRow = CreateTileGrid.globalReference.GetTileCoords(this.partyMove.currentTile); if (partyColRow != null) { //Setting the anchor position of the player location object relative to the size of this UI object Vector2 anchorPos = new Vector2((partyColRow.col * 1f) / (CreateTileGrid.globalReference.cols * 1f), (partyColRow.row * 1f) / (CreateTileGrid.globalReference.rows * 1f)); this.playerLocationObj.anchorMin = anchorPos; this.playerLocationObj.anchorMax = anchorPos; } }