示例#1
0
    private void updateBase()
    {
        GameObject baseObject = GameObject.FindGameObjectWithTag("Base");

        if (baseObject == null || PetKeeper.pet.Base.longLat == null)
        {
            return;
        }

        string[] parts       = PetKeeper.pet.Base.longLat.Split(',');
        float    longitude   = float.Parse(parts[0]);
        float    latitude    = float.Parse(parts[1]);
        Vector3  fromLongLat = VectorExtensions.AsUnityPosition(
            new Vector2(latitude, longitude),
            Map.GetComponent <BasicMap>().CenterMercator,
            Map.GetComponent <BasicMap>().WorldRelativeScale
            );

        Debug.LogWarning("House pos updated");

        baseObject.transform.position = fromLongLat;
    }
示例#2
0
    public Vector3 getUnityPos(double lat, double lon)
    {
        Vector2 latlon = new Vector2((float)(lat), (float)(lon));

        return(VectorExtensions.AsUnityPosition(latlon, abstractMap.CenterMercator, (abstractMap.WorldRelativeScale)));         //* 1.5f
    }
示例#3
0
    private void initBase()
    {
        if (PetKeeper.pet.Base.longLat == null)
        {
            moveBaseButton.SetActive(false);
            buildBaseButton.SetActive(true);
            return;
        }
        else
        {
            moveBaseButton.SetActive(true);
        }

        buildBaseButton.SetActive(false);

        GameObject Map = GameObject.FindGameObjectWithTag("Map");

        string[] parts       = PetKeeper.pet.Base.longLat.Split(',');
        float    longitude   = float.Parse(parts[0]);
        float    latitude    = float.Parse(parts[1]);
        Vector3  fromLongLat = VectorExtensions.AsUnityPosition(new Vector2(latitude, longitude), Map.GetComponent <BasicMap>().CenterMercator, Map.GetComponent <BasicMap>().WorldRelativeScale);

        GameObject newBase = (GameObject)Instantiate(P_Base, fromLongLat, Quaternion.identity);

        newBase.transform.SetParent(Map.transform, false);
        newBase.transform.localScale = Vector3.one;

        foreach (GardenCrop crop in PetKeeper.pet.Base.gardenCrops)
        {
            parts       = crop.longLat.Split(',');
            longitude   = float.Parse(parts[0]);
            latitude    = float.Parse(parts[1]);
            fromLongLat = VectorExtensions.AsUnityPosition(
                new Vector2(latitude, longitude),
                Map.GetComponent <BasicMap>().CenterMercator,
                Map.GetComponent <BasicMap>().WorldRelativeScale
                );

            GameObject newPlot = (GameObject)Instantiate(P_FarmPlots[(int)crop.seedType], fromLongLat + (Vector3.up * 0.4f), Quaternion.identity);
            newPlot.transform.SetParent(Map.transform, false);
            newPlot.transform.localScale = Vector3.one;

            newPlot.GetComponent <FarmPlot>().init(Inventory.getSeedTypeInfo(crop.seedType), crop, this, false);
        }

        foreach (BaseGardenDecor decor in PetKeeper.pet.Base.baseGardenDecors)
        {
            parts       = decor.longLat.Split(',');
            longitude   = float.Parse(parts[0]);
            latitude    = float.Parse(parts[1]);
            fromLongLat = VectorExtensions.AsUnityPosition(
                new Vector2(latitude, longitude),
                Map.GetComponent <BasicMap>().CenterMercator,
                Map.GetComponent <BasicMap>().WorldRelativeScale
                );

            GameObject newDecor = (GameObject)Instantiate(P_GardenDecors[(int)decor.gardenDecorType], fromLongLat + (Vector3.up * (0.2f + decor.yOffset)), Quaternion.identity);
            newDecor.transform.SetParent(Map.transform, false);
            newDecor.transform.localScale    = Vector3.zero;
            newDecor.transform.localRotation = Quaternion.Euler(0, decor.yRotation, 0);

            newDecor.GetComponent <GardenDecorWorld>().init(decor);
        }
    }