Exemplo n.º 1
0
 public void RemoveCreateInteraction(CreateInteraction group)
 {
     group.SetAllPlayersCreating(false);
     group.ResetAllPlayersFriendCounters();
     Destroy(group.GetPreview().gameObject);
     createInteractionList.Remove(group);
     Destroy(group.gameObject);
 }
Exemplo n.º 2
0
    /**Updates the current interacting groups as soon as any player sends a triggerExit event with another player*/

    /*
     * Handles player trigger exiting in creating groups
     * Player trigger exit in moveinteraction takes no effect, since this should be handled via GripPoints Trigger exit
     **/
    //TODO check if above comment is coded correctly
    public void GroupInteractionOnPlayerCollisionExit(Player player1, Player player2)
    {
        CreateInteraction groupInteraction1 = FindPlayerInGroups(player1);

        if (groupInteraction1 != null)
        {
            CreateInteraction groupInteraction2 = FindPlayerInGroups(player2);
            if (groupInteraction2 != null)
            {
                //both players are in the same group
                if (groupInteraction1 == groupInteraction2)
                {
                    //if player1 is still connected to the group
                    if (player1.GetFriendCounter() > 1)
                    {
                        //both players are still connected to the group
                        if (player2.GetFriendCounter() > 1)
                        {
                            //do nothing because the group is the same as before
                        }
                        //only player1 is connected, player2 is leaving
                        else
                        {
                            groupInteraction1.RemovePlayer(player2);
                        }
                    }
                    //only player2 is connected, player1 is leaving
                    else if (player2.GetFriendCounter() > 1)
                    {
                        groupInteraction2.RemovePlayer(player1);
                    }
                    //player1 and player2 are the two players left in the creating group
                    else
                    {
                        groupInteraction1.ResetAllPlayersFriendCounters();
                        RemoveCreateInteraction(groupInteraction1);
                    }
                }
                //players are in different groups (e.g. 2 and 3 players walk over each others triggers)
                else
                {
                    //TODO: handle this or do nothing
                }
            }
            //player1 is part of a "full" group. player2 is not in a group and leaves group from p1
            //else {//do nothing}
        }
        //player1 is not in a group and leaves from WHERE?? is this even possible?
        //else {//do nothing}
    }
Exemplo n.º 3
0
        public AppointmentListViewModel(Cache cache, CalendarProxy proxy, IMapper mapper)
        {
            CreateCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var id   = Guid.NewGuid();
                var name = await CreateInteraction.Handle(Unit.Default);
                if (name != null)
                {
                    await proxy.AddToDoTask(id, name);
                    var dto = await proxy.GetAppointment(id);
                    var dvo = mapper.Map <AppointmentDvo>(dto);
                    cache.Get <AppointmentDvo>().AddOrUpdate(dvo);
                    MessageBus.Current.OpenAppointment(dvo.Id);
                }
            });
            EditCommand = ReactiveCommand.Create <AppointmentDvo>(
                toDoTask => MessageBus.Current.OpenAppointment(toDoTask.Id),
                this.WhenAnyValue(x => x.SelectedToDoTask).Select(d => d != null));
            DeleteCommand = ReactiveCommand.Create <AppointmentDvo>(async toDoTask =>
            {
                await proxy.DeleteToDoTask(toDoTask.Id);
                cache.Get <AppointmentDvo>().Remove(toDoTask);
                MessageBus.Current.CloseAllPanelsWithKey(toDoTask.Id.ToString());
            }, this.WhenAnyValue(x => x.SelectedToDoTask).Select(d => d != null));
            RefreshCommand = ReactiveCommand.CreateFromTask(async cancellationToken =>
            {
                cache.Get <AppointmentDvo>().EditDiff(
                    mapper.Map <IEnumerable <AppointmentDto>, IList <AppointmentDvo> >(await proxy.GetAppointments()),
                    // TODO - Implementar un mecanismo para detectar los cambios basado en un timestamp o similar
                    (t1, t2) => t1.Name == t2.Name);
            });
            cache.Get <AppointmentDvo>()
            .Connect()
            .OnItemRemoved(toDoTask => MessageBus.Current.CloseAllPanelsWithKey(toDoTask.Id.ToString()))
            .OnItemUpdated((updatedToDoTask, _) => MessageBus.Current.SendMessage(new UpdatePanelMessage(updatedToDoTask)))

            //.AutoRefresh(_ => _.Name)
            .AutoRefresh()

            //.Filter(_ => _.Name != null)

            .Sort(new GenericComparer <AppointmentDvo>((t1, t2) => StringComparer.CurrentCulture.Compare(t1.Name, t2.Name)))
            .Page(this.WhenAnyValue(_ => _.PageRequest))

            .ObserveOnDispatcher()
            .Bind(out var list)
            .DisposeMany()
            .Subscribe();
            ToDoTasks = list;

            cache.Get <AppointmentDvo>()
            .Connect()
            .ObserveOnDispatcher()
            .Bind(out var allList)
            .DisposeMany()
            .Subscribe();
            AllToDoTasks = allList;

            // TODO - Cancel in progress command https://github.com/reactiveui/ReactiveUI/issues/1536
            RefreshCommand.Execute().Subscribe();
            //RefreshCommand.Execute().Subscribe();
        }
Exemplo n.º 4
0
    /**Updates the current interacting groups as soon as any player sends a triggerEnter event with another player*/
    public void GroupInteractionOnPlayerCollisionEnter(Player player1, Player player2)
    {
        CreateInteraction groupInteraction1 = FindPlayerInGroups(player1);

        if (groupInteraction1 != null)
        {
            CreateInteraction groupInteraction2 = FindPlayerInGroups(player2);
            if (groupInteraction2 != null)
            {
                if (groupInteraction1 == groupInteraction2)
                {
                    //both players are in the same group
                    return;
                }


                if (groupInteraction1.players.Length == 2 && groupInteraction1.players.Length == 2)
                {
                    //merge 4 players from two groups of two
                    foreach (Player player in groupInteraction2.players)
                    {
                        groupInteraction1.AddPlayer(player);
                        RemoveCreateInteraction(groupInteraction2);
                    }
                }
                else
                {
                    //more than four players
                    //TODO: handle this or do nothing
                }
            }
            else
            {
                //player1 is part of a group. player2 has to be added.
                if (groupInteraction1.players.Length < 4)
                {
                    groupInteraction1.AddPlayer(player2);
                }
            }
        }
        else
        {
            CreateInteraction groupInteraction2 = FindPlayerInGroups(player2);
            if (groupInteraction2 != null)
            {
                //player2 is part of a group. player1 has to be added.
                if (groupInteraction2.players.Length < 4)
                {
                    groupInteraction2.AddPlayer(player1);
                }
            }
            else
            {
                //none is part of a group. new Group has to be added.
                CreateInteraction newCreateInteraction = Instantiate(CIPrefab);
                newCreateInteraction.AddPlayer(player1);
                newCreateInteraction.AddPlayer(player2);
                createInteractionList.Add(newCreateInteraction);
            }
        }
    }
Exemplo n.º 5
0
 public void RemoveCreateInteraction(CreateInteraction groupInteraction)
 {
     DestroyImmediate(groupInteraction.GetPreview().gameObject);
     createInteractionList.Remove(groupInteraction);
     DestroyImmediate(groupInteraction.gameObject);
 }
Exemplo n.º 6
0
        //Interactions
        public static async Task <RestInteraction> CreateCommandAsync(IGuild guild, BaseDiscordClient client, CreateInteraction interaction, RequestOptions options)
        {
            Interaction_Json data = await client.ApiClient.CreateGuildCommandAsync(guild.Id, interaction, options).ConfigureAwait(false);

            return(RestInteraction.Create(data));
        }