public void AddSurvivor(Survivor survivor)
        {
            if (Survivors.Any(s => s.Name == survivor.Name))
            {
                return;
            }

            Survivors.Add(survivor);
            History.LogEvent(new HistoryEvent(survivor.Name, nameof(Survivor), "ADDED_TO_GAME"));
        }
Пример #2
0
        public bool AddSurvivorToGame(Survivor newSurvivor)
        {
            var retVal          = false;
            var newSurvivorName = newSurvivor.Name;

            if (!Survivors.Any(s => s.Name.Equals(newSurvivorName)))
            {
                newSurvivor.Notifier = _notifier;
                Survivors.Add(newSurvivor);
                Notify($"Survivor {newSurvivor.Name} was added to the game");

                retVal = true;
            }

            return(retVal);
        }
Пример #3
0
        /// <summary>
        /// Retrieves patients from queue and adds them to IVA, Sanatorium,
        /// or Survivors if their sickness level is 0, or to Afterlife if they are dead
        /// </summary>
        private async Task FillHospital()
        {
            while (queue.Length != 0)
            {
                if (!queue.Peek().IsAlive) // Adds the first person in line to Afterlife if it is dead
                {
                    while (afterlife.Saving || queue.Saving)
                    {
                        await Task.Delay(1);
                    }
                    afterlife.Add(queue.GetNextPatient());
                    continue;
                }
                else if (queue.Peek().SicknessLevel == 0) // Adds the first person in line to survive if it has already recovered
                {
                    while (survivors.Saving || queue.Saving)
                    {
                        await Task.Delay(1);
                    }
                    survivors.Add(queue.GetNextPatient());
                    continue;
                }

                if (!iva.IsFull) // Adds the first person in line to IVA if there is room
                {
                    while (iva.Saving || queue.Saving)
                    {
                        await Task.Delay(1);
                    }
                    iva.CheckIn(queue.GetNextPatient());
                }
                else if (!sanatorium.IsFull) // Adds the first person in line to Sanatorium if there is room
                {
                    while (sanatorium.Saving || queue.Saving)
                    {
                        await Task.Delay(1);
                    }
                    sanatorium.CheckIn(queue.GetNextPatient());
                }
                else // If both IVA and Sanatorium are full no more patients can be reitreved from the queue
                {
                    break;
                }
            }
        }
Пример #4
0
        public bool Repair(Survivor survivor)
        {
            if (Survivors.Contains(survivor))
            {
                return(false);
            }
            if (Progress == 100)
            {
                return(false);
            }

            Survivors.Add(survivor);
            if (RepairThread == null)
            {
                var thread = new Thread(new ThreadStart(DoRepair));
                thread.IsBackground = true;
                thread.Start();
            }

            LastUsed       = DateTime.Now;
            HasBeenTouched = true;

            return(true);
        }