//Make pick affect preceding pins private void CollectPrecedingPins() { var children = SelectedPin.GetComponentsInChildren <Transform>(); foreach (var child in children) { if (child.name == "LowerPinEnd") { pick.SetParent(child); pick.anchoredPosition = Vector2.zero; } } PrecedingAnims = new List <Animator>(); HoldPinResidue = new List <Behaviour_LockPin>(); var index = pinsLeft.FindIndex(x => x == SelectedPin) + 1; var precedingPins = pinsLeft.GetRange(index, pinsLeft.Count - index); precedingPins.ForEach(x => PrecedingAnims.Add(x.GetComponent <Animator>())); foreach (var holdPin in HoldPins) { if (UI_Lock.ActivePins.FindIndex(x => x == holdPin) > UI_Lock.ActivePins.FindIndex(x => x == SelectedPin)) { HoldPinResidue.Add(holdPin.GetComponent <Behaviour_LockPin>()); } } }
//Check if pin is ready to be unlocked private IEnumerator CheckPin() { checkingPin = true; yield return(new WaitForSecondsRealtime(0.1f)); float currentState = SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime; float sweetSpot = SelectedPin.GetComponent <Behaviour_LockPin>().Fraction; if (Mathf.Abs(sweetSpot - currentState) < 0.01f) { sweetSpotReached = true; } else { sweetSpotReached = false; } checkingPin = false; }
private void HandlerPinsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null && e.NewItems.Cast <Pin>().Any(pin => pin.Label == null)) { throw new ArgumentException("Pin must have a Label to be added to a map"); } if (e.OldItems != null) { foreach (var item in e.OldItems) { // Remove old pins from layer if (item is Pin pin) { HideCallout(pin.Callout); pin.Callout = null; pin.PropertyChanged -= HandlerPinPropertyChanged; if (SelectedPin.Equals(pin)) { SelectedPin = null; } } } } if (e.NewItems != null) { foreach (var item in e.NewItems) { // Add new pins to layer var pin = item as Pin; if (pin != null) { pin.PropertyChanged += HandlerPinPropertyChanged; } } } Refresh(); }
//Lock pin state and exclude from selectable pins private void HoldPin() { Behaviour_LockPin controls = SelectedPin.GetComponent <Behaviour_LockPin>(); controls.dropped = true; controls.holding = true; pinsLeft = new List <GameObject>(); pinsLeft.AddRange(UI_Lock.ActivePins.Except(HoldPins)); HoldPins.Add(SelectedPin); var tempSelectedPin = SelectedPin; if (SelectedPin != pinsLeft[pinsLeft.Count - 1]) { SelectedPin = pinsLeft[pinsLeft.FindIndex(x => x == SelectedPin) + 1]; } else if (SelectedPin != pinsLeft[0]) { SelectedPin = pinsLeft[pinsLeft.FindIndex(x => x == SelectedPin) - 1]; } pinsLeft.Remove(tempSelectedPin); CollectPrecedingPins(); currentPosition += 1; if (currentPosition >= UI_Lock.ActivePins.Count) { if (!UI_Lock.currentLock.unlocked) { UI_Lock.currentLock.unlocked = true; } else { UI_Lock.currentLock.unlocked = false; } SelectedAnim.Rebind(); gameObject.SetActive(false); } }
public FestaMapRootPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, IShowFestaMap showFesta, IMapAssociated mapParam) { _eventAggregator = eventAggregator; _navigationService = navigationService; showFestaUsecase = showFesta; _mapParams = mapParam; InfoWindowClickedCommand = new DelegateCommand <InfoWindowClickedEventArgs>(async(pin) => { var region = pin.Pin.Tag as MapRegion; if (region == null) { return; } if (IsGlobalMap) { if (region.MapObjectType.HasFlag(MapObjectEnum.STAGE)) { await _navigationService.NavigateAsync( nameof(StageEventListRootPageViewModel).GetViewNameFromRule(), StageEventListRootPageViewModel.GetNavigationParameter(region.Id, region.Name)); } else { var type = region.MapObjectType.HasFlag(MapObjectEnum.EXHIBITION) ? PlanningTypeEnum.EXHIBITION : PlanningTypeEnum.STALL; await _navigationService.NavigateAsync( "RegionSpecificPlanningListPage", PlanningListRootPageViewModel.GetNavigationParameter(region.Id, region.Name, type)); } } }); _eventAggregator.GetEvent <PolygonClickedEvent>().Subscribe((pin) => { SelectedPin.Value = pin.Tag as Pin; MoveToRegionRequest.MoveToRegion( MapSpan.FromCenterAndRadius(SelectedPin.Value.Position, Distance.FromMeters(100))); }).AddTo(this.Disposable); showFesta.Pins.ToCollectionChanged <Pin>() .Subscribe(change => { switch (change.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: Pins?.Add(change.Value); break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: Pins?.Remove(change.Value); break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: Pins?.Clear(); break; } }).AddTo(this.Disposable); showFesta.Polygons.ToCollectionChanged <Polygon>() .Subscribe(change => { switch (change.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: Polygons?.Add(change.Value); break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: Polygons?.Remove(change.Value); break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: Polygons?.Clear(); break; } }).AddTo(this.Disposable); // For iOS _eventAggregator.GetEvent <TabbedPageOpendEvent>().Subscribe((ev) => { if (ev.Name != this.GetType().Name.Replace("ViewModel", "")) { return; } IsShowingUser.Value = true; showFestaUsecase.InitializeAllMapObjects(); if (IsGlobalMap) { MoveToRegionRequest.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(_mapParams.MapCenterLangitude, _mapParams.MapCenterLongitude), Distance.FromMeters(185))); } }).AddTo(this.Disposable); _eventAggregator.GetEvent <LocationPermissionRequestResultEvent>() .Subscribe((ev) => { IsShowingUser.Value = ev.Granted; }); Title.AddTo(this.Disposable); SelectedPin.AddTo(this.Disposable); IsShowingUser.AddTo(this.Disposable); }