public static void addNewEggToCheckinnables(OwnedEgg egg)
 {
     foreach (GenericLocation loc in egg.GenericLocationsToTake)
     {
         if (loc.needToBeVisited())
         {
             if (!placeTypes.ContainsKey(loc.LocationType))
             {
                 placeTypes[loc.LocationType] = new Dictionary <OwnedEgg, HashSet <GenericLocation> >();
             }
             if (!placeTypes[loc.LocationType].ContainsKey(egg))
             {
                 placeTypes[loc.LocationType][egg] = new HashSet <GenericLocation>();
             }
             placeTypes[loc.LocationType][egg].Add(loc);
         }
     }
     foreach (HatchLocationMarker hlm in egg.MarkersToTake)
     {
         if (hlm.needToBeVisited())
         {
             if (!idMarkers.ContainsKey(hlm.Id))
             {
                 idMarkers[hlm.Id] = new Dictionary <OwnedEgg, HatchLocationMarker>();
             }
             idMarkers[hlm.Id][egg] = hlm;
         }
     }
 }
Example #2
0
    public static IEnumerator createEggForSelf(GameObject eggMenuItemPrefab, Transform eggMenuContentPanel, int imageIndex, string eggName = "")
    {
        if (SpatialClient2.single.isLoggedIn())
        {
            List <SpatialMarker> markersAround  = new List <SpatialMarker>();
            CoroutineResponse    markerResponse = new CoroutineResponse();
            yield return(SpatialClient2.single.GetMarkersByDistance(Input.location.lastData.longitude, Input.location.lastData.latitude, UserMetadata.KAIJU_MARKER_RADIUS, true, markersAround, markerResponse));

            // assign the hexadecimal representation of the egg creation number as custom part of id
            Debug.Log("hell yeah");
            List <HatchLocationMarker> markersToTake          = new List <HatchLocationMarker>();
            List <GenericLocation>     genericLocationsToTake = new List <GenericLocation>();
            yield return(SpatialClient2.single.getLocationsForEgg(SpatialClient2.single.randomLocationFromMarkers(markersAround), markersToTake, genericLocationsToTake));

            OwnedEgg egg = new OwnedEgg(imageIndex, SpatialClient2.single.newEggIdForSelf(), new LocationCombination(markersToTake, genericLocationsToTake), eggName, SpatialClient2.single.randomKaijuFromMarkers(markersAround));
            yield return(egg.initializeSprite(new CoroutineResponse())); // sprite should already be there since we are coming from the egg screen, but just checking

            GameObject eggMenuItem = GameObject.Instantiate(eggMenuItemPrefab);
            eggMenuItem.transform.SetParent(eggMenuContentPanel, false);
            eggMenuItem.GetComponent <OwnEggMenuItem>().Egg = egg; // also updates the egg menu item's view
            MainMenuScript.addNewEggToCheckinnables(egg);
            yield return(SpatialClient2.single.addEggToSelf(egg));

            Debug.Log("egg created");
        }
        else
        {
            Debug.Log("tried to create egg while not logged in");
        }
    }
Example #3
0
    /**********************************
    *
    *           Button Callbacks
    *
    * ********************************/

    public void closeEggCanvas()
    {
        findEggCanvas.SetActive(false);
        editEggNameCanvas.SetActive(false);
        GameObject inputName = editEggNameCanvas.transform.FindChild("InputEggName").gameObject;

        eggName = inputName.GetComponent <InputField> ().text;
        Debug.Log(eggName);
        StartCoroutine(OwnedEgg.createEggForSelf(mainController.GetComponent <MainMenuScript> ().EggMenuItemPrefab,
                                                 mainController.GetComponent <MainMenuScript> ().EggMenuContentPanel, eggIndex, eggName));
    }
Example #4
0
    public void updateCheckins(OwnedEgg egg)
    {
        Dictionary <string, HatchLocationMarker> idHlmDict = new Dictionary <string, HatchLocationMarker>();

        foreach (HatchLocationMarker marker in MarkersToTake)
        {
            idHlmDict[marker.Id] = marker;
        }
        foreach (HatchLocationMarker marker in egg.MarkersToTake)
        {
            if (!marker.needToBeVisited())
            {
                idHlmDict[marker.Id].markVisited();
            }
        }

        Dictionary <GenericLocation.GooglePlacesType, GenericLocation> typeGlDict = new Dictionary <GenericLocation.GooglePlacesType, GenericLocation>();

        foreach (GenericLocation location in GenericLocationsToTake)
        {
            typeGlDict[location.LocationType] = location;
        }
        foreach (GenericLocation location in egg.GenericLocationsToTake)
        {
            typeGlDict[location.LocationType].updateVisits(location);
        }
        foreach (string friendUserId in egg._kaiju.Helpers)
        {
            _kaiju.addHelper(friendUserId);
        }
        foreach (CheckInPlace place in PlacesToTake)
        {
            if (place.needToBeVisited())
            {
                return;
            }
        }
        _hatchable = true;
    }
Example #5
0
    public static IEnumerator createEggForFriend(FriendData friend, int imageIndex, string eggName = "")
    {
        if (SpatialClient2.single.isLoggedIn())
        {
            List <SpatialMarker> markersAround  = new List <SpatialMarker>();
            CoroutineResponse    markerResponse = new CoroutineResponse();
            yield return(SpatialClient2.single.GetMarkersByDistance(Input.location.lastData.longitude, Input.location.lastData.latitude, UserMetadata.KAIJU_MARKER_RADIUS, true, markersAround, markerResponse));

            List <HatchLocationMarker> markersToTake          = new List <HatchLocationMarker>();
            List <GenericLocation>     genericLocationsToTake = new List <GenericLocation>();
            yield return(SpatialClient2.single.getLocationsForEgg(SpatialClient2.single.randomLocationFromMarkers(markersAround), markersToTake, genericLocationsToTake));

            OwnedEgg egg = new OwnedEgg(imageIndex, SpatialClient2.single.newEggIdForFriend(friend), new LocationCombination(markersToTake, genericLocationsToTake), eggName, SpatialClient2.single.randomKaijuFromMarkers(markersAround));
            yield return(egg.initializeSprite(new CoroutineResponse())); // sprite should already be there since we are coming from the egg screen, but just checking

            MainMenuScript.addNewEggToCheckinnables(egg);
            yield return(SpatialClient2.single.addOrUpdateEggInFriendsEggs(egg));
        }
        else
        {
            Debug.Log("tried to create egg while not logged in");
        }
    }
 public static void removeEntryFromPlaceTypes(GenericLocation.GooglePlacesType type, OwnedEgg egg)
 {
     placeTypes[type].Remove(egg);
     if (placeTypes[type].Count == 0)
     {
         placeTypes.Remove(type);
         googleMarkers.Remove(type);
     }
 }
 public static void removeEntryFromIdMarkers(string id, OwnedEgg egg)
 {
     idMarkers[id].Remove(egg);
 }
Example #8
0
 // TODO implement this
 public void sendToFriendButtonHandler()
 {
     eggToSend = _egg;
     MainMenuScript.EggsCanvas.enabled    = false;
     MainMenuScript.FriendsCanvas.enabled = true;
 }