Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        foreach (ZoneData zoneData in zones.Values)
        {
            zoneData.Update(player.transform.position);
        }

        if (GPSManager.IsReady)
        {
            ZoneID zoneID = GetZoneID(GPSManager.position);

            if (zoneID != playerZone || forceOnEnter)
            {
                playerZone = zoneID;

                if (!PosHasZone(GPSManager.position))
                {
                    ZoneData zone = new ZoneData(zoneID);
                    zone.SetActive(true, originZone);
                    zones.Add(zoneID, zone);
                    forceOnEnter = true;
                }

                EnterZone(zoneID, forceOnEnter);

                if (forceOnEnter)
                {
                    RepositionPlayer(zoneID);
                    CenterCameraOnPlayer(player.transform.position);
                }

                forceOnEnter = false;
            }
            else
            {
                RepositionPlayer(zoneID);
            }

            //Track position changes
            UpdatePoints();
        }
    }