Example #1
0
 public async static Task AddNewSentence(Prison prison)
 {
     using (var db = new Database()) {
         db.Prison.Add(prison);
         await db.SaveChangesAsync();
     }
 }
Example #2
0
 public async static Task RemoveSentence(Prison prison)
 {
     using (var db = new Database()) {
         db.Prison.Attach(prison);
         db.Prison.Remove(prison);
         await db.SaveChangesAsync();
     }
 }
Example #3
0
        // --- Methods

        public static void LoadPrisonSentenceForPlayer(Player player)
        {
            Prison sentence = PrisonRepository.GetPrisonSentenceByCharacterID(player.Id);

            if (sentence == null)
            {
                return;
            }

            activeSentences.Add(player, sentence);
        }
Example #4
0
 public async static void EndSentence(Prison sentence, Player player)
 {
     if (!sentence.IsPrison)
     {
         CellManager.StartCellExitSequenceForPlayer(player);
     }
     else
     {
         //StartPrisonExitSequenceForPlayer(player);
     }
     await PrisonRepository.RemoveSentence(sentence);
 }
Example #5
0
        public static void TickPrisonSentences()
        {
            for (int i = 0; i < activeSentences.Count; ++i)
            {
                Prison sentence = activeSentences.ElementAt(i).Value;
                if (sentence == null)
                {
                    continue;
                }
                sentence.Time -= 1;

                if (sentence.Time == 0)
                {
                    EndSentence(sentence, activeSentences.ElementAt(i).Key);
                }
            }
        }