Esempio n. 1
0
    //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 = PartyGroup.globalReference.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
            TileColRow newTileColRow = TileMapManager.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) / (TileMapManager.globalReference.cols * 1f),
                                            (newTileColRow.row * 1f) / (TileMapManager.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();
            }
        }
    }
Esempio n. 2
0
    //Function called externally to get the column and row for a given tile
    public TileColRow GetTileCoords(TileInfo tileToSearchFor_)
    {
        //The coordinates that we'll return
        TileColRow tileCoord = null;

        //Looping through all of the tiles connected to the tile we're searching for
        for (int ct = 0; ct < tileToSearchFor_.connectedTiles.Count; ++ct)
        {
            //If this current tile connection isn't empty and one of its tile connections is the tile we're searching for
            if (tileToSearchFor_.connectedTiles[ct] != null && tileToSearchFor_.connectedTiles[ct].connectedTiles.Contains(tileToSearchFor_))
            {
                //Getting the index of the tile we're searching for in the connected tile's list of connected tiles
                int ourTileIndex = tileToSearchFor_.connectedTiles[ct].connectedTiles.IndexOf(tileToSearchFor_);

                //Returning the tile coordinates using the index of the tile we're searching for
                GridCoordinates coords = tileToSearchFor_.connectedTiles[ct].connectedTileCoordinates[ourTileIndex];

                tileCoord     = new TileColRow();
                tileCoord.col = coords.col;
                tileCoord.row = coords.row;
                return(tileCoord);
            }
        }

        //Returning the empty tile coordinates
        Debug.LogError("TileMapManager.GetTileCoords >>> NULL RETURN");
        return(tileCoord);
    }
    //Constructor function for this class
    public PartySaveData(PartyGroup groupToSave_)
    {
        this.combatDist = groupToSave_.combatDistance;

        TileColRow tileLocation = TileMapManager.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);
            }
        }

        //Looping through all of the party inventory items to save their object references
        this.inventorySlots = new List <string>();
        this.stackedItems   = new List <string>();
        for (int i = 0; i < groupToSave_.inventory.itemSlots.Count; ++i)
        {
            //Making sure the current inventory object isn't null
            if (groupToSave_.inventory.itemSlots[i] != null)
            {
                //Reference to the item's IDTag component
                IDTag itemTag = groupToSave_.inventory.itemSlots[i].GetComponent <IDTag>();

                //Saving the IDTag info
                this.inventorySlots.Add(JsonUtility.ToJson(new PrefabIDTagData(itemTag)));

                //If the current item is a stack
                if (groupToSave_.inventory.itemSlots[i].currentStackSize > 1)
                {
                    //Creating a new InventoryItemStackData class to store the item stack
                    InventoryItemStackData stack = new InventoryItemStackData(i, itemTag, groupToSave_.inventory.itemSlots[i].currentStackSize);
                    //Adding a serialized version of the stack data to our list of stacked items
                    this.stackedItems.Add(JsonUtility.ToJson(stack));
                }
            }
            //If the current item is null, we set a null slot to keep the empty space
            else
            {
                this.inventorySlots.Add("");
            }
        }
    }
Esempio n. 4
0
    //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
        TileColRow encounterCoords = TileMapManager.globalReference.GetTileCoords(encounter_.GetComponent <Movement>().currentTile);

        this.encounterTileCol = encounterCoords.col;
        this.encounterTileRow = encounterCoords.row;
    }
Esempio n. 5
0
        public TileColRow WorldToTilePos(double lon, double lat, int zoom)
        {
            TileColRow p = new TileColRow();

            p.Column = Convert.ToInt32(Math.Floor((lon + 180.0) / 360.0 * (1 << zoom)));
            p.Row    = Convert.ToInt32(Math.Floor((1.0 - Math.Log(Math.Tan(lat * Math.PI / 180.0) +
                                                                  1.0 / Math.Cos(lat * Math.PI / 180.0)) / Math.PI) / 2.0 * (1 << zoom)));

            return(p);
        }
    // Update is called once per frame
    private void Update()
    {
        //Finding the party group's row and col coords in the overworld
        TileColRow partyColRow = TileMapManager.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) / (TileMapManager.globalReference.cols * 1f),
                                            (partyColRow.row * 1f) / (TileMapManager.globalReference.rows * 1f));

            this.playerLocationObj.anchorMin = anchorPos;
            this.playerLocationObj.anchorMax = anchorPos;
        }
    }
Esempio n. 7
0
        private List <MapTile> GetTiles()
        {
            TileColRow tileColRow = WorldToTilePos(App.CurrentCentre.Longitude, App.CurrentCentre.Latitude, App.ZoomLevel);

            if (lastTileColRow != null)
            {
                if (lastTileColRow.Column == tileColRow.Column && lastTileColRow.Row == tileColRow.Row)
                {
                    return(null);
                }
            }
            lastTileColRow = tileColRow;
            int colFrom = tileColRow.Column - 3;
            int colTo   = tileColRow.Column + 3;
            int rowFrom = tileColRow.Row - 3;
            int rowTo   = tileColRow.Row + 3;

            string[] param = { App.ZoomLevel.ToString(), colFrom.ToString(), colTo.ToString(), rowFrom.ToString(), rowTo.ToString() };

            String         query = "SELECT * FROM maptiles WHERE zoom_level = ? AND (tile_column BETWEEN ? AND ?) AND (tile_row BETWEEN ? AND ?) ORDER BY tile_column, tile_row";
            List <MapTile> tiles = App.mapDB.Query <MapTile>(query, param);

            return(tiles);
        }