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); } } }
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); }