Пример #1
0
        public void UnselectObject()
        {
            if (SelectedObject)
            {
                SelectedObject.transform.SetParent(previousParent);
                SelectedObject.GetComponent <ISelectable>()?.Unselect();

                Unselect?.Invoke(SelectedObject);
                SelectedObject = null;
            }
        }
Пример #2
0
    // change this to return State
    public State SelectTile(State currentState, Tile targetTile)
    {
        Action action    = null;
        var    nextState = currentState;

        // I wonder if I can somehow make this a bit more logical
        // instead of stepping through the conditions and returning an Action/Transition,
        // can I define the conditions for an Action/Transition and return whatever Transition matches the current conditions?
        if (!(currentState is EnemyTurnState))
        {
            if (currentState is NoSelectionState)
            {
                if (targetTile.occupier != null)
                {
                    if (targetTile.occupier.isAllied)
                    {
                        action = new SelectAlly(targetTile.occupier);
                    }
                    else
                    {
                        action = new SelectEnemy(targetTile.occupier);
                    }
                }
                else
                {
                    action = new Unselect();
                }
            }
            if (currentState is AllySelectedState)
            {
                var stateData = (AllySelectedState)currentState;
                // what is the tile they are clicking on? do they want to move? do they want to attack?
                if (targetTile.occupier != null)
                {
                    var target = targetTile.occupier;
                    // clicking on another entity
                    // if entity is enemy: Attack
                    if (target.isHostile && stateData.attackRange.Contains(targetTile))
                    {
                        action = new Attack(stateData.source, target);
                    }
                    // if entity is ally: interact (to be implemented later)
                }
                else if (stateData.moveRange.Contains(targetTile))
                {
                    // if space is empty: move there (if possible)
                    // parent.tilemap.MoveEntity(selectedEntity.tile, targetTile);
                    action = new Move(stateData.source, targetTile);
                }
                else
                {
                    action = new Unselect();
                }
            }
            if (currentState is EnemySelectedState)
            {
                if (targetTile.occupier == null)
                {
                    action = new Unselect();
                }
            }
            if (currentState is SelectSkillActivatedState)
            {
                var stateData    = (SelectSkillActivatedState)currentState;
                var tilesInRange = stateData.validTiles.Union(stateData.selectedTiles);
                if (tilesInRange.Contains(targetTile))
                {
                    action = new SelectSkillTile(stateData.source, targetTile);
                }
            }
            if (currentState is TeleportActivatedState)
            {
                var stateData = (TeleportActivatedState)currentState;
                if (stateData.validTiles.Contains(targetTile))
                {
                    action = new SelectTeleportTile(stateData.source, targetTile);
                }
            }
        }

        if (action != null)
        {
            // remove all instances of parent here
            nextState = action.Transition(currentState, parent.tilemap, parent.dialog);
        }

        return(nextState);
    }
Пример #3
0
    public MainViewModel(MainState state, ICloudFactory factory, CloudViewModelFactory createViewModel)
    {
        _factory = factory;
        Refresh  = ReactiveCommand.Create(state.Clouds.Refresh);

        _isLoading = Refresh
                     .IsExecuting
                     .ToProperty(this, x => x.IsLoading);

        _isReady = Refresh
                   .IsExecuting
                   .Select(executing => !executing)
                   .ToProperty(this, x => x.IsReady);

        state
        .Clouds
        .Connect()
        .Transform(ps => createViewModel(ps, factory.CreateCloud(ps.Parameters)))
        .Sort(SortExpressionComparer <ICloudViewModel> .Descending(x => x.Created))
        .ObserveOn(RxApp.MainThreadScheduler)
        .Bind(out _providers)
        .Subscribe();

        var canRemove = this
                        .WhenAnyValue(x => x.SelectedProvider)
                        .Select(provider => provider != null);

        Remove = ReactiveCommand.Create(
            () => state.Clouds.RemoveKey(SelectedProvider.Id),
            canRemove);

        var canAddProvider = this
                             .WhenAnyValue(x => x.SelectedSupportedType)
                             .Select(type => Enum.IsDefined(typeof(CloudType), type));

        Add = ReactiveCommand.Create(
            () => state.Clouds.AddOrUpdate(new CloudState {
            Type = SelectedSupportedType
        }),
            canAddProvider);

        _welcomeScreenVisible = this
                                .WhenAnyValue(x => x.SelectedProvider)
                                .Select(provider => provider == null)
                                .ToProperty(this, x => x.WelcomeScreenVisible);

        _welcomeScreenCollapsed = this
                                  .WhenAnyValue(x => x.WelcomeScreenVisible)
                                  .Select(visible => !visible)
                                  .ToProperty(this, x => x.WelcomeScreenCollapsed);

        var canUnselect = this
                          .WhenAnyValue(x => x.SelectedProvider)
                          .Select(provider => provider != null);

        Unselect = ReactiveCommand.Create(() => Unit.Default, canUnselect);
        Unselect.Subscribe(unit => SelectedProvider = null);

        var outputCollectionChanges = Clouds
                                      .ToObservableChangeSet(x => x.Id)
                                      .Publish()
                                      .RefCount();

        outputCollectionChanges
        .Filter(provider => provider.Id == state.SelectedProviderId)
        .ObserveOn(RxApp.MainThreadScheduler)
        .OnItemAdded(provider => SelectedProvider = provider)
        .Subscribe();

        outputCollectionChanges
        .OnItemRemoved(provider => SelectedProvider = null)
        .Subscribe();

        this.WhenAnyValue(x => x.SelectedProvider)
        .Skip(1)
        .Select(provider => provider?.Id ?? Guid.Empty)
        .Subscribe(id => state.SelectedProviderId = id);

        SelectedSupportedType = state.SelectedSupportedType ?? SupportedTypes.First();
        this.WhenAnyValue(x => x.SelectedSupportedType)
        .Subscribe(type => state.SelectedSupportedType = type);
    }
Пример #4
0
        //
        // GET: /AjaxInfo/
        //修改是否加入数据分析的产品id
        public JsonResult ModifyUnselected(string unids, string uid, string pageno)
        {
            UnselectDao usdao = new UnselectDao();
            Hashtable htparm = new Hashtable();
            htparm["page"] = Int32.Parse(pageno);
            htparm["uid"] = Int32.Parse(uid);
            Unselect us = EnterpriseopenBidDBMapper.Get().QueryForObject<Unselect>("Unselect.ByPage", htparm);
            try
            {

                if (us == null)
                {
                    Unselect newus = new Unselect();
                    newus.Userid = Int32.Parse(uid);
                    newus.Unselected = unids;
                    newus.PageNo = Int32.Parse(pageno);
                    usdao.Insert(newus);
                }
                else
                {
                    htparm["unselected"] = unids;
                    EnterpriseopenBidDBMapper.Get().Update("Unselect.myupdate", htparm);
                }
            }
            catch (Exception e)
            {
                return Json("修改失败");
            }
            return Json("修改失败");
        }
Пример #5
0
 /// <summary>
 /// This is called when an option is unhighlighted (another option is selected) in the
 /// ListMenu.
 /// </summary>
 public virtual void OnUnselected()
 {
     IsSelected = false;
     Unselect?.Invoke(this, EventArgs.Empty);
 }