Example #1
0
        /// <summary>
        /// Checks if the adding group is an atacker or a deffender and inserts it to
        /// the appropriate group and recalculates it.
        /// </summary>
        /// <param name="group">The inserting group.</param>
        public void AddGroup(GroupMovables group)
        {
            GroupManager groupMgr = Game.GroupManager;

            if (group.Team == groupAttackers.Team)
            {
                // Group is attacker
                int groupCount = group.Count;
                for (int i = 0; i < groupCount; i++)
                {
                    IMovableGameObject temp = group[0];
                    groupMgr.RemoveFromGroup(temp);
                    groupMgr.AddToGroup(groupAttackers, temp);
                    temp.StartAttack(this);
                }
                groupAttackers.Reselect();
                groupMgr.SelectGroup(groupAttackers);
            }
            else
            {
                // Group is deffender
                int groupCount = group.Count;
                for (int i = 0; i < groupCount; i++)
                {
                    IMovableGameObject temp = group[0];
                    groupMgr.RemoveFromGroup(temp);
                    groupMgr.AddToGroup(imgoDeffenders, temp);
                    temp.StartAttack(this);
                }
                groupAttackers.Reselect();
                groupMgr.SelectGroup(imgoDeffenders);
            }
        }
Example #2
0
File: Chat.cs Project: anurse/JabbR
        void INotificationService.JoinRoom(ChatUser user, ChatRoom room)
        {
            var userViewModel = new UserViewModel(user);
            var roomViewModel = new RoomViewModel
            {
                Name    = room.Name,
                Private = room.Private
            };

            var isOwner = user.OwnedRooms.Contains(room);

            // Tell all clients to join this room
            foreach (var client in user.ConnectedClients)
            {
                Clients[client.Id].joinRoom(roomViewModel);
            }

            // Tell the people in this room that you've joined
            Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();

            // Notify users of the room count change
            OnRoomChanged(room);

            foreach (var client in user.ConnectedClients)
            {
                // Add the caller to the group so they receive messages
                GroupManager.AddToGroup(client.Id, room.Name).Wait();
            }
        }
Example #3
0
        private void LogOn(ChatUser user, string clientId)
        {
            // Update the client state
            Caller.id   = user.Id;
            Caller.name = user.Name;
            Caller.hash = user.Hash;

            var userViewModel = new UserViewModel(user);
            var rooms         = new List <RoomViewModel>();

            foreach (var room in user.Rooms)
            {
                var isOwner = user.OwnedRooms.Contains(room);

                // Tell the people in this room that you've joined
                Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();

                // Update the room count
                OnRoomChanged(room);

                // Add the caller to the group so they receive messages
                GroupManager.AddToGroup(clientId, room.Name).Wait();

                // Add to the list of room names
                rooms.Add(new RoomViewModel
                {
                    Name    = room.Name,
                    Private = room.Private
                });
            }

            // Initialize the chat with the rooms the user is in
            Caller.logOn(rooms);
        }
Example #4
0
        /// <summary>
        /// Creates a new <see cref="Entity"/> instance in the world and assigns the provided tag, group and <see cref="IComponent"/> instances to it.
        /// </summary>
        /// <param name="tag">Tag for the new entity.</param>
        /// <param name="group">Group for the new entity.</param>
        /// <param name="components"><see cref="IEnumerable"/> containing all <see cref="IComponent"/> instances to associate with new entity.</param>
        public void LoadEntityState(string tag, string group, IEnumerable <IComponent> components)
        {
            Entity entity;

            if (!string.IsNullOrEmpty(tag))
            {
                entity = CreateEntity(tag);
            }
            else
            {
                entity = CreateEntity();
            }

            if (!string.IsNullOrEmpty(group))
            {
                GroupManager.AddToGroup(group, entity);
            }

            foreach (IComponent component in components)
            {
                entity.AddComponent(component);
            }

            entity.Refresh();
        }
Example #5
0
        /// <summary>
        /// Inserts the given group to attacker group and sends it
        /// to target destination and recalculates the group.
        /// </summary>
        /// <param name="group">The inserting group.</param>
        public void AddGroup(GroupMovables group)
        {
            GroupManager groupMgr = Game.GroupManager;

            Game.IMoveManager.GoToTarget(group, target);
            int groupCount = group.Count;

            for (int i = 0; i < groupCount; i++)
            {
                IMovableGameObject temp = group[0];
                groupMgr.RemoveFromGroup(temp);
                groupMgr.AddToGroup(attackers, temp);
            }
            attackers.Reselect();
            groupMgr.SelectGroup(attackers);
        }
Example #6
0
        public bool CheckStatus()
        {
            bool outOfSync = OutOfSync;

            SetVersion();

            string id = Caller.id;

            ChatUser user = _repository.VerifyUserId(id);

            // Make sure this client is being tracked
            _service.AddClient(user, Context.ConnectionId, UserAgent);

            var currentStatus = (UserStatus)user.Status;

            if (currentStatus == UserStatus.Offline)
            {
                // Mark the user as inactive
                user.Status = (int)UserStatus.Inactive;
                _repository.CommitChanges();

                // If the user was offline that means they are not in the user list so we need to tell
                // everyone the user is really in the room
                var userViewModel = new UserViewModel(user);

                foreach (var room in user.Rooms)
                {
                    var isOwner = user.OwnedRooms.Contains(room);

                    // Tell the people in this room that you've joined
                    Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();

                    // Update the room count
                    OnRoomChanged(room);

                    // Add the caller to the group so they receive messages
                    GroupManager.AddToGroup(Context.ConnectionId, room.Name).Wait();
                }
            }

            return(outOfSync);
        }
Example #7
0
        public async Task <IActionResult> Join(string groupid)
        {
            // Get current user
            User user = await _userManager.GetUserAsync(User);

            // Ensure user is logged in
            if (user == null)
            {
                StatusMessage = $"Error: Please log in!";
                return(RedirectToAction("Index", controllerName: "Home"));
            }

            Group group = await _context.Groups.FindAsync(groupid);

            if (group == null)
            {
                StatusMessage = $"Error: Can't find group {groupid}!";
                return(RedirectToAction("Index", controllerName: "Home"));
            }

            if (await _context.GroupMembers.AnyAsync(x => x.User_Id == user.Id && x.Group_Id == group.Id))
            {
                StatusMessage = $"Error: You already joined {group.Name}!";
                return(RedirectToAction("Index", controllerName: "Home"));
            }

            TaskResult result = await GroupManager.AddToGroup(user, group);

            StatusMessage = result.Info;

            if (!result.Succeeded)
            {
                return(RedirectToAction("Index", controllerName: "Home"));
            }

            return(RedirectToAction(nameof(View), new { groupid = groupid }));
        }