コード例 #1
0
        void m_spawnItemDriver_ItemsRemoved(object sender, LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
        {
            var drivers = GetDrivers(e.Results.SpawnItem);

            if (drivers != null)
            {
                foreach (var driver in drivers)
                {
                    driver.Key.RemoveItem(e);
                }
            }
        }
コード例 #2
0
        void m_spawnItemDriver_ItemsSpawned(object sender, LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
        {
            var drivers = GetDrivers(e.Results.SpawnItem);

            if (drivers != null)
            {
                ThreadHelper.Instance.CallOnMainThread(() =>
                {
                    foreach (var kv in drivers)
                    {
                        kv.Key.SpawnItem(e, kv.Value);
                    }
                });
            }
        }
コード例 #3
0
        public void SpawnItem(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e, ILocationCollectionMechanic m)
        {
            var  arMechanic     = m as ARLocationCollectionMechanic;
            bool showAnnotation = arMechanic != null && arMechanic.ShowMapAnnotation;

            var collectible = ValuablesCollection.GetFirstCollectible(e.Results.SpawnItem.ValuablesCollection);

            var options = GetOptions(e.Results.SpawnItem, m as ARLocationCollectionMechanic);

            if (collectible != null)
            {
                ThreadHelper.Instance.CallOnMainThread(() =>
                {
                    LocationARWorldObject worldObj = null;

                    if (collectible.AssetInstance != null &&
                        collectible.AssetInstance.Asset != null)
                    {
                        worldObj = ARWorld.Instance.AddLocationARAsset(
                            e.Results.SourceLocation,
                            0,
                            collectible.AssetInstance,
                            options);
                    }

                    if (worldObj == null)
                    {
                        worldObj = ARWorld.Instance.
                                   AddLocationARImage(e.Results.SourceLocation, 0, collectible.ImageUrl, options);
                    }

                    worldObj.Clicked += (sender, args) =>
                    {
                        RewardManager.Instance.ShowRewards(e.Results.SpawnItem.ValuablesCollection);

                        WorldValuablesManager.Instance.Collect(e);
                    };

                    m_worldObjects[e.Results.SourceLocation.Id] = worldObj;
                });

                if (showAnnotation && MapLocationCollectionDriver)
                {
                    MapLocationCollectionDriver.AddARCollectAnnotation(e);
                }
            }
        }
コード例 #4
0
        public void RemoveItem(LocationSpawnItemDriverEventArgs <Motive.AR.Models.LocationValuablesCollection> e)
        {
            if (m_worldObjects.ContainsKey(e.Results.SourceLocation.Id))
            {
                var obj = m_worldObjects[e.Results.SourceLocation.Id];

                ThreadHelper.Instance.CallOnMainThread(() =>
                {
                    ARWorld.Instance.RemoveWorldObject(obj);

                    if (MapLocationCollectionDriver)
                    {
                        MapLocationCollectionDriver.RemoveAnnotation(e);
                    }
                });
            }
        }
コード例 #5
0
        /// <summary>
        /// Currently only used by AR collector, to make sure we use the same code path to show the
        /// location. Ultimately the goal here is to make sure we don't double-up the annotations
        /// for this location.
        /// </summary>
        /// <param name="e"></param>
        public void AddARCollectAnnotation(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
        {
            MapAnnotation ann = new MapAnnotation(e.Results.SourceLocation);

            var         options     = e.Results.SpawnItem.CollectOptions;
            DoubleRange actionRange = new DoubleRange(0, AutoCollectDistance);

            if (options != null && options.CollectRange != null)
            {
                actionRange = options.CollectRange;
            }

            ann.Delegate = new MapAnnotationDelegate
            {
                OnSelect = (_ann) =>
                {
                    if (ValuablesCollectionPanel)
                    {
                        ValuablesCollectionPanel.ValuablesCollection = e.Results.SpawnItem.ValuablesCollection;

                        SelectedLocationPanelHandler.Instance.ShowSelectedLocationPanel(ValuablesCollectionPanel, _ann);

                        ValuablesCollectionPanel.ShowARCollect(actionRange);
                    }
                },
                OnDeselect = (_ann) =>
                {
                    base.DeselectAnnotation(_ann);
                },
                OnGetObjectForAnnotation = (_ann) =>
                {
                    return(CreateAnnotationObject(e.Results.SpawnItem));
                }
            };

            AddAnnotation(e.Results.SourceLocation.Id, ann);
        }
コード例 #6
0
 public void RemoveAnnotation(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
 {
     RemoveAnnotation(e.Results.SourceLocation.Id);
 }
コード例 #7
0
        public void RemoveItem(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
        {
            m_triggerPool.StopWatching(GetTriggerRequestId(e));

            RemoveAnnotation(e.Results.SourceLocation.Id);
        }
コード例 #8
0
        public void SpawnItem(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e, ILocationCollectionMechanic mechanic)
        {
            MapAnnotation ann = new MapAnnotation(e.Results.SourceLocation);

            var mapMechanic = mechanic as MapLocationCollectionMechanic;

            var options = e.Results.SpawnItem.CollectOptions;
            var action  = mapMechanic == null ? null : mapMechanic.CollectAction;

            DoubleRange actionRange = new DoubleRange(0, AutoCollectDistance);

            if (options != null && options.CollectRange != null)
            {
                actionRange = options.CollectRange;
            }

            var actionType = (action == null) ? null : action.Type;

            bool collectWithPanel = false;

            // if no actionType is specified, defer to the AutoCollect setting
            if ((actionType == null && AutoCollectInRange) ||
                (actionType != null && actionType == "motive.ar.inRangeLocationCollectionAction"))
            {
                m_triggerPool.WatchLocation(GetTriggerRequestId(e), e.Results.SourceLocation, () =>
                {
                    PlayCollectSound(mapMechanic);

                    WorldValuablesManager.Instance.Collect(e);
                }, actionRange);
            }
            else
            {
                collectWithPanel = true;
            }

            ann.Delegate = new MapAnnotationDelegate
            {
                OnSelect = (_ann) =>
                {
                    if (ValuablesCollectionPanel)
                    {
                        ValuablesCollectionPanel.ValuablesCollection = e.Results.SpawnItem.ValuablesCollection;
                        ValuablesCollectionPanel.OnAction            = () =>
                        {
                            RewardManager.Instance.ShowRewards(e.Results.SpawnItem.ValuablesCollection);

                            PlayCollectSound(mapMechanic);

                            WorldValuablesManager.Instance.Collect(e);
                        };

                        SelectedLocationPanelHandler.Instance.ShowSelectedLocationPanel(ValuablesCollectionPanel, _ann);

                        //if (collectWithPanel)
                        {
                            ValuablesCollectionPanel.ShowMapCollect(actionRange);
                        }
                    }
                },
                OnDeselect = (_ann) =>
                {
                    base.DeselectAnnotation(_ann);
                },
                OnGetObjectForAnnotation = (_ann) =>
                {
                    return(CreateAnnotationObject(e.Results.SpawnItem));
                }
            };

            AddAnnotation(e.Results.SourceLocation.Id, ann);
        }
コード例 #9
0
 string GetTriggerRequestId(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
 {
     return(string.Format("{0}.{1}", e.Results.InstanceId, e.Results.SourceLocation.Id));
 }
コード例 #10
0
 public void Collect(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e)
 {
     Collect(e.Results.InstanceId, e.Results.SourceLocation, e.Results.SpawnItem);
 }