示例#1
0
        public async Task CharacterArrives(Character CharacterObject)
        {
            CharacterObject.CurrentXYZ = StorageID;
            Occupants.Add(new Occupant()
            {
                DisplayName = CharacterObject.DisplayName, StorageID = CharacterObject.StorageID
            });
            LastVisited   = DateTime.Now;
            LastVisitedBy = CharacterObject.Name;
            var soul          = CharacterObject.ConvertToSoul();
            var nearbyPlayers = GetNearbyPlayers();
            var request       = JSON.Encode(new
            {
                Category = "Events",
                Type     = "CharacterArrives",
                Soul     = soul
            });

            foreach (var player in nearbyPlayers)
            {
                await player.SendString(request);
            }
            foreach (var occupant in Occupants)
            {
                Storage.Current.NPCs.Find(occupant.StorageID)?.CheckAwareness(CharacterObject);
            }
        }
示例#2
0
        public void Occupy(Token TknOccupant)
        {
            Occupants.Add(TknOccupant);
            TknOccupant.TokenPosition = this.fieldId;

            if (IsOccupied == true && Occupants.Count > 1)
            {
                KillEnemy();
            }
        }
示例#3
0
        public void AddEntity(Entity entity)
        {
            if (entity.Cell != null)
            {
                entity.Cell.RemoveEntity(entity);
            }

            entity.Cell = this;
            Occupants.Add(entity);
        }
示例#4
0
 public void Arrive(Player player)
 {
     if (player.Digit != -1)
     {
         // This player is not bankrupt, so they can be added to this tile without problem.
         Occupants.Add(player);
         // We've landed on this tile!
         // Call that abstract void that child classes will implement later.
         Land(player);
         OnPropertyChanged("Occupants");
     }
 }
示例#5
0
 /// <summary>
 /// Adds the character.
 /// </summary>
 /// <param name="character">The character.</param>
 /// <param name="entryDirection">The entry direction.</param>
 public virtual void AddCharacter(IMob character, AvailableTravelDirections entryDirection)
 {
     if (Occupants.Contains(character))
     {
         return;
     }
     else
     {
         Occupants.Add(character);
         OnEnterEvent(character, entryDirection);
     }
 }
示例#6
0
        public Tuple <bool, string> AddClient(Client _client)
        {
            if (Occupants?.Count < MaxOccupancy)
            {
                Occupants?.Add(_client);
                return(Tuple.Create(true, $"Client with ID : {_client.ClientId} was added to Room with RoomId : {RoomId}"));
            }
            if ((bool)Occupants?.Any(occupant => occupant.IsInitiator) && _client.IsInitiator)
            {
                Occupants?.Add(_client);
                return(Tuple.Create(true, $"Client with ID : {_client.ClientId} was added to Room with RoomId : {RoomId} as a participant."));
            }

            return(Tuple.Create(false, $"The Room with ID : {RoomId} has reached MAXIMUM Occupancy of {MaxOccupancy}"));
        }
示例#7
0
        public Tuple <bool, string> UpdateClient(Client _client)
        {
            var isOccupant = IsClientAnOccupant(_client);

            if (isOccupant.Item1)
            {
                var removedCount = (int)Occupants?.RemoveAll(client => client.ClientId == _client.ClientId);
                if (removedCount > 0)
                {
                    Occupants.Add(_client);
                    return(Tuple.Create(true, $"Client with  ID: {_client.ClientId} was updated"));
                }
                return(Tuple.Create(false, $"Client with  ID: {_client.ClientId} was not updated"));
            }

            return(isOccupant);
        }