예제 #1
0
        void OnApplicationPause(bool paused)
        {
            m_logger.Debug("OnApplicationPause({0})", paused);

            if (paused)
            {
                CallActions();
            }
            else
            {
                lock (m_playingPlayers) {
                    foreach (UnityAudioPlayer p in m_playingPlayers)
                    {
                        bool srcPlaying = (p.AudioSource)?p.AudioSource.isPlaying:false;

                        m_logger.Debug("Resume: ({0}) src.playing={1} p.playing={2} {3}",
                                       p.Inst, srcPlaying,
                                       p.IsPlaying, p.Source);

                        // This is a hack...
                        if (!p.IsPlaying && srcPlaying)
                        {
                            p.AudioSource.Pause();
                        }
                    }
                }
            }
        }
        void Play(BatchContext context, PlayableContent playable, Action onClose)
        {
            if (!context.ActivationContext.IsClosed)
            {
                // If there's a script timer, use the activation time as a base to
                // play this content later.
                if (playable.Timer != null)
                {
                    // Use clock manager so that we can use debug clock features
                    var fireTime = playable.Timer.GetNextFireTime(context.ActivationContext.ActivationTime);
                    var delta    = ClockManager.Instance.GetTimespanFromNow(fireTime);

                    if (delta.TotalSeconds > 0)
                    {
                        // Actual play time is real Now + delta - this can be different from the
                        // computed fire time above if we're using a debug clock.
                        var actualPlayTime = DateTime.Now + delta;

                        Delegate.Preview(context.ActivationContext, playable, actualPlayTime);
                    }

                    context.Timer = Timer.Call(delta,
                                               () =>
                    {
                        m_logger.Debug("Fired timer!");

                        Delegate.Play(context.ActivationContext, playable, () =>
                        {
                            context.ActivationContext.Close();

                            if (onClose != null)
                            {
                                onClose();
                            }
                        });
                    });
                }
                else
                {
                    Delegate.Play(context.ActivationContext, playable, () =>
                    {
                        context.ActivationContext.Close();

                        if (onClose != null)
                        {
                            onClose();
                        }
                    });
                }
            }
            else
            {
                if (onClose != null)
                {
                    onClose();
                }
            }
        }
예제 #3
0
        void m_videoPlayer_prepareCompleted(VideoPlayer source)
        {
            m_logger.Debug("PrepareCompleted");

            ClipLoaded.Invoke();

            if (m_paused)
            {
                m_videoPlayer.time = m_pauseTime;
            }

            if (m_playOnPrepare)
            {
                m_playOnPrepare = false;
                Play();
            }
        }
예제 #4
0
        void PauseAudio()
        {
            m_logger.Debug("PauseAudio player.isPlaying={0} isPlaying={1}",
                           m_player.IsPlaying, m_isPlaying);

            if (m_player.IsPlaying)
            {
                m_player.Pause();
            }
        }
예제 #5
0
        void CheckForDeviceToken()
        {
            var token = UnityEngine.iOS.NotificationServices.deviceToken;
            var error = UnityEngine.iOS.NotificationServices.registrationError;

            if (count >= 100 || !string.IsNullOrEmpty(error))
            {
                CancelInvoke("CheckForDeviceToken");
                m_logger.Debug("Cancel polling");
                return;
            }

            m_logger.Debug("CheckForDeviceToken: got {0} (err:{1})", token, error);

            if (token != null)
            {
                CancelInvoke("CheckForDeviceToken");

                var tokenStr = System.BitConverter.ToString(token).Replace("-", "");

                var platform = BuildSettings.IsDebug ? AppleSandbox : Apple;

                WebServices.Instance.UserManager.RegisterPushNotifications(platform, tokenStr, (success) =>
                {
                    m_logger.Debug("Register iOS push notifications {0} complete: success={1}", platform, success);
                });
            }

            count++;
        }
예제 #6
0
            public void OnStop(Action <bool> onComplete)
            {
                m_logger.Debug("OnStop ({0}) {1}", Inst, Source);

                m_channel.RemovePlayingPlayer(this);

                m_sampleTime = null;

                IsPlaying = false;

                m_samplePosition = 0;

                DidStartPlaying = false;

                if (Loader != null)
                {
                    WWW www = Loader;
                    Loader = null;
                    www.Dispose();
                }

                if (AudioSource)
                {
                    AudioSource.Stop();
                }

                if (onComplete != null)
                {
                    onComplete(true);
                }

                if (m_audioEnded != null)
                {
                    m_audioEnded(this, EventArgs.Empty);
                }
            }
예제 #7
0
 public void Initialize()
 {
     try
     {
         Platform.Instance.LocalNotificationManager.CancelAllNotifications();
         m_notifications = new Dictionary <string, LocalNotification>();
     }
     catch (Exception e)
     {
         m_logger.Debug("Background Notifier failed to initialize.: \n{0}", e.Message);
     }
 }
예제 #8
0
        public override bool CheckState(FrameOperationContext fop, VisualMarkerTrackingCondition condition, out object[] results)
        {
            bool met = true;

            List <IVisualMarker> matching = null;

            if (condition.VisualMarkers != null)
            {
                foreach (var vm in condition.VisualMarkers.OfType <IVisualMarker>())
                {
                    var isTracking = false;

                    if (vm != null)
                    {
                        m_logger.Debug("Checking tracking for marker {0}", vm.GetIdentifier());

                        isTracking = ARMarkerManager.Instance.IsTracking(vm);

                        if (isTracking)
                        {
                            if (matching == null)
                            {
                                matching = new List <IVisualMarker>();
                            }

                            matching.Add(vm);
                        }
                    }

                    met &= isTracking;
                }
            }

            if (matching != null)
            {
                results = matching.ToArray();
            }
            else
            {
                results = null;
            }

            return(met);
        }
예제 #9
0
        public void Activate()
        {
            if (Adapter)
            {
                IsActive = true;

                m_logger.Debug("Activate IsInitialized={0}", IsInitialized);

                if (InitializingPane)
                {
                    InitializingPane.SetActive(true);
                }

                Adapter.Activate();
            }
        }
예제 #10
0
        void RenderTile(TileInfo info, int ox, int oy, int x, int y, int z)
        {
            m_logger.Debug("Render tile {0} ox={1} oy={2} x={3} y={4} z={5}",
                           info.TileId, ox, oy, x, y, z);

            /*
             * var parameters = new Tile.Parameters
             * {
             *  Fs = m_fileSource,
             *  Id = new CanonicalTileId(z, (int)x, (int)y)
             * };*/

            // Check to see if we need to render a new tile.

            if (//info.UnityTile != null &&
                info.UnityTile &&
                info.TileId.Z == z &&
                (int)info.TileId.X == x &&
                (int)info.TileId.Y == y)
            {
                m_logger.Debug("Place existing tile {0}", info.TileId);

                PlaceTile(info.UnityTile, ox, oy, x, y);

                /*
                 * ?? who owns what here?
                 * info.TileObj.transform.localScale = new Vector3(1 / info.UnityTile.Rect.width * sx, 1 / info.UnityTile.Rect.width * sy, 1 / info.UnityTile.Rect.height * sx);
                 * info.TileObj.transform.localPosition = new Vector3((x - ox) * sx - (PlaneSize.x - sx) / 2 - BoundaryTiles * sx, 0, (y - oy) * sy - (PlaneSize.y - sy) / 2 - BoundaryTiles * sy);
                 */
            }
            else
            {
                m_logger.Debug("Load tile {0}", info.TileId);

                if (info.UnityTile)
                {
                    m_logger.Debug("Disposing current tile {0} (canonical id={1}, name={2})", info.TileId, info.UnityTile.CanonicalTileId, info.UnityTile.gameObject.name);

                    MapVisualizer.DisposeTile(info.TileId);
                    info.UnityTile = null;
                }

                info.TileId = new Mapbox.Map.UnwrappedTileId(z, x, y);

                //MapVisualizer.LoadTile(info.TileId);

                /*
                 * info.TileObj = Instantiate(TilePrefab);
                 */
                info.UnityTile = MapVisualizer.LoadTile(info.TileId); //info.TileObj.AddComponent<UnityTile>();

                //info.UnityTile.Zoom = z;
                //info.UnityTile.RelativeScale = Conversions.GetTileScaleInMeters(0, z) / Conversions.GetTileScaleInMeters((float)MapController.Instance.MapView.CenterCoordinates.Latitude, z);
                //info.UnityTile.TileCoordinate = new Vector2(x, y);
                //info.UnityTile.Rect = Conversions.TileBounds(info.UnityTile.TileCoordinate, z);

                //info.TileObj.transform.SetParent(this.transform, false);
                //info.TileObj.transform.localScale = new Vector3(1 / info.UnityTile.Rect.width * sx, 1 / info.UnityTile.Rect.width * sy, 1 / info.UnityTile.Rect.height * sx);
                //info.TileObj.transform.localPosition = new Vector3((x - ox) * sx - (PlaneSize.x - sx) / 2 - BoundaryTiles * sx, 0, (y - oy) * sy - (PlaneSize.y - sy) / 2 - BoundaryTiles * sy);

                //info.UnityTile.transform.localScale = new Vector3(1 / info.UnityTile.Rect.width * sx, 1 / info.UnityTile.Rect.width * sy, 1 / info.UnityTile.Rect.height * sx);
                PlaceTile(info.UnityTile, ox, oy, x, y);

                //MapVisualization.ShowTile(info.UnityTile);
            }
        }
예제 #11
0
        public void LoadCatalog <T>(string spaceName, string catalogName, Action <Catalog <T> > onLoad, bool?useDevCatalogs = null)
        {
            if (string.IsNullOrEmpty(catalogName))
            {
                return;
            }

            var fileName = StorageManager.GetCatalogFileName(spaceName, catalogName + ".json");

            // If the caller has specified a preference for using dev catalogs, use that,
            // otherwise defer to the setting here | the debug setting
            bool useDev = useDevCatalogs ??
                          (ShouldUseDevCatalogs || SettingsHelper.IsDebugSet("Debug_UseDevCatalogs"));

            if (InternetReachability == NetworkReachability.NotReachable)
            {
                if (RequireNetworkConnection)
                {
                    SetDownloadError(WebServicesDownloadErrorCode.NoNetworkConnection);
                }
                else
                {
                    var catalog = CatalogLoader.LoadCatalogFromCache <T>(fileName);

                    if (catalog == null)
                    {
                        if (m_completeFailHandler != null)
                        {
                            m_completeFailHandler("Please connect to the network and re-try");
                        }
                    }
                    else
                    {
                        MediaDownloadManager.AddMediaItemProvider(catalog);

                        onLoad(catalog);
                    }
                }
            }
            else
            {
                CatalogLoader.LoadCatalog <T>(fileName, spaceName, catalogName, useDev,
                                              (status, catalog) =>
                {
                    if (status == ServiceCallLoadStatus.Success)
                    {
                        m_logger.Debug("Loaded catalog {0} with {1} item(s)",
                                       catalogName, catalog.Items == null ? 0 : catalog.Items.Length);

                        // This callback happens outside of the Unity thread,
                        // use the Thread Helper to move into the Unity context
                        ThreadHelper.Instance.CallOnMainThread(() =>
                        {
                            MediaDownloadManager.AddMediaItemProvider(catalog);

                            onLoad(catalog);

                            // Since we're in the Unity thread here we don't need
                            // to protect this in a critical section
                        });
                    }
                    else
                    {
                        m_logger.Error("Error loading catalog {0}", catalogName);

                        SetDownloadError(status);

                        if (m_completeFailHandler != null)
                        {
                            ThreadHelper.Instance.CallOnMainThread(() =>
                            {
                                m_completeFailHandler("Error loading catalog " + catalogName);
                            });
                        }
                    }
                });
            }
        }
예제 #12
0
        void PopPanel(PanelStack panelStack, Panel p, bool animate = true, RuntimeAnimatorController animController = null)
        {
            bool isTop = (p == panelStack.CurrentPanel);

            // Can only call PopPanel on the top panel

            /* rc - 11/28/2017: let panels get "popped" from
             * the middle of a stack. Most of the time the opposite
             * behaviour is unwanted (a middle panel taking anything that was
             * pushed after with it)
             * if (p != panelStack.CurrentPanel)
             * {
             *  return;
             * }*/

            AnalyticsHelper.FireEvent("PopPanel", new Dictionary <string, object>
            {
                { "Name", p.GetType().ToString() }
            });

            m_logger.Debug("PopPanel {0} ({1}) stack={2} start", p.name, p.GetType().Name, panelStack.m_stackName);

            panelStack.Remove(p);

            m_pushedPanelStacks.Remove(p);
            m_showPanels.Remove(p);

            var curr = panelStack.CurrentPanel;

            var onClose = p.OnClose;

            p.OnClose = null;

            if (onClose != null)
            {
                onClose();
            }

            if (!isTop)
            {
                // Skip animations, etc. The code
                // after this conditional is only
                // applicable when popping the top
                // panel
                SetPanelActive(p, false);

                p.DidPop();

                return;
            }

            // If the current top panel is the one that we remembered
            // from before. This handles the case that "onClose" caused
            // the same panel to be pushed again (e.g. screen message ->
            // screen message)
            if (panelStack.CurrentPanel && (panelStack.CurrentPanel == curr))
            {
                m_logger.Verbose("PopPanel from {0} -> {1} is ready={2}",
                                 p.GetType().Name, panelStack.CurrentPanel.GetType().Name, panelStack.CurrentPanel.IsReady);

                SetPanelActive(panelStack.CurrentPanel, true);
                panelStack.CurrentPanel.DidRegainTop();
            }

            SetPanelOrientation(curr);

            // Hide this panel last

            // We might be re-showing the same panel as part of the onClose flow,
            // if so, don't tell the panel it hid because this will shut the panel down.
            if (panelStack.CurrentPanel != p)
            {
                Action doPop = () =>
                {
                    var animCtl = animController ?? p.PopAnimation;

                    if (animCtl && animate)
                    {
                        p.DoAnimation(animCtl);
                    }
                    else
                    {
                        SetPanelActive(p, false);
                    }

                    p.DidPop();
                };

                if (panelStack.CurrentPanel && !panelStack.CurrentPanel.IsReady)
                {
                    m_logger.Verbose("Current panel {0} is not ready!", panelStack.CurrentPanel.name);

                    p.transform.SetAsLastSibling();

                    StartCoroutine(CallWhenReady(panelStack.CurrentPanel, () =>
                    {
                        // Make sure the panel we're disabling didn't become the
                        // current panel
                        if (p != panelStack.CurrentPanel)
                        {
                            doPop();
                        }
                    }));
                }
                else
                {
                    m_logger.Verbose("Current panel {0} is ready!", panelStack.CurrentPanel ? panelStack.CurrentPanel.name : null);

                    doPop();
                }
            }

            if (m_showPanels.Count == 0)
            {
                ObjectHelper.SetObjectsActive(ShowWhenPanelsShowing, false);
                ObjectHelper.SetObjectsActive(ShowWhenNoPanelsShowing, true);
            }

            m_logger.Verbose("PopPanel {0} end", p.GetType().Name);
        }
        public void BuyProductID(string productId)
        {
            // If Purchasing has been initialized ...
            if (IsInitialized)
            {
                // ... look up the Product reference with the general product identifier and the Purchasing
                // system's products collection.
                Product product = m_StoreController.products.WithID(productId);

                // If the look up found a product for this device's store and that product is ready to be sold ...
                if (product != null && product.availableToPurchase)
                {
                    m_Logger.Debug(string.Format("PurchaseManager Purchasing product asychronously: '{0}'", product.definition.id));
                    // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed
                    // asynchronously.
                    m_StoreController.InitiatePurchase(product);
                }
                // Otherwise ...
                else
                {
                    // ... report the product look-up failure situation
                    m_Logger.Debug("PurchaseManager BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                }
            }
            // Otherwise ...
            else
            {
                // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
                // retrying initiailization.
                m_Logger.Debug("PurchaseManager BuyProductID FAIL. Not initialized.");
            }
        }
        void UpdateCache(Coordinates origin)
        {
            var originTile = MapTools.GetTileVector(origin.Latitude, origin.Longitude, TileZoomLevel);

            var minX = (int)(originTile.X - TileSpan / 2 + 1);
            var minY = (int)(originTile.Y - TileSpan / 2 + 1);
            var maxX = minX + TileSpan;
            var maxY = minY + TileSpan;

            if (minX == m_currMinX && minY == m_currMinY)
            {
                return;
            }

            m_currMinX = minX;
            m_currMinY = minY;

            List <Location> toAdd    = new List <Location>();
            List <Location> toRemove = new List <Location>();

            BatchProcessor iter = new BatchProcessor(TileSpan * TileSpan, () =>
            {
                LocationCache.Instance.UpdateCache(toAdd, toRemove);
            });

            for (int x = minX; x < minX + TileSpan; x++)
            {
                for (int y = minY; y < minY + TileSpan; y++)
                {
                    var ix = x % TileSpan;
                    var iy = y % TileSpan;

                    var info = m_tileInfos[ix, iy];

                    if (info == null || info.X != x || info.Y != y)
                    {
                        // Create a new one
                        if (info != null)
                        {
                            lock (info)
                            {
                                if (info.ServiceCall != null)
                                {
                                    info.ServiceCall.Abort();
                                }

                                info.ServiceCall = null;

                                if (info.Locations != null)
                                {
                                    lock (toRemove)
                                    {
                                        toRemove.AddRange(info.Locations);
                                    }
                                }
                            }
                        }
                        else
                        {
                            info = new TileInfo();
                        }

                        info.X = x;
                        info.Y = y;

                        m_tileInfos[ix, iy] = info;

                        var _info = info;
                        var _x    = x;
                        var _y    = y;

                        m_logger.Debug("Requesting locations for tile {0},{1},{2}",
                                       x, y, TileZoomLevel);

                        Action <byte[]> processData = (data) =>
                        {
                            // Since we're sharing the infos, these values could change
                            lock (_info)
                            {
                                if (_info.X != _x || _info.Y != _y)
                                {
                                    return;
                                }

                                if (data != null)
                                {
                                    _info.Locations = GetLocations(data, _x, _y, TileZoomLevel);

                                    if (_info.Locations != null)
                                    {
                                        lock (toAdd)
                                        {
                                            toAdd.AddRange(_info.Locations);
                                        }
                                    }
                                }
                            }

                            iter++;
                        };

                        var cacheBytes = m_tileCache.GetTileData(TileSource, _x, _y, TileZoomLevel);

                        if (cacheBytes != null)
                        {
                            processData(cacheBytes);
                        }
                        else
                        {
                            var serviceCall = GetServiceCall(x, y, TileZoomLevel);
                            info.ServiceCall = serviceCall;

                            serviceCall.Connect(() =>
                            {
                                var data = serviceCall.ResponseBuffer;

                                if (data != null)
                                {
                                    processData(serviceCall.ResponseBuffer);

                                    m_tileCache.StoreTile(TileSource, _x, _y, TileZoomLevel, data);
                                }
                            });
                        }
                    }
                    else
                    {
                        iter++;
                    }
                }
            }
        }
예제 #15
0
        public void StartCollecting()
        {
            m_logger.Debug("StartCollecting");

            m_spawnItemDriver.Start();
        }