Beispiel #1
0
        public void Update(GameLocation location)
        {
            FarmerCollection farmers = location.farmers;

            if (farmers.Contains(Game1.player) && localJobs.Count > 0)
            {
                requests[Game1.player.UniqueMultiplayerID] = true;
            }
            else
            {
                requests.Remove(Game1.player.UniqueMultiplayerID);
            }
            if (Game1.IsMasterGame)
            {
                requests.Filter((KeyValuePair <long, bool> kv) => farmers.FirstOrDefault((Farmer f) => f.UniqueMultiplayerID == kv.Key) != null);
                if (!requests.ContainsKey(currentOwner))
                {
                    currentOwner.Value = -1L;
                }
            }
            if ((long)currentOwner == Game1.player.UniqueMultiplayerID)
            {
                foreach (T job in localJobs)
                {
                    Processor(job);
                }
                localJobs.Clear();
                requests.Remove(Game1.player.UniqueMultiplayerID);
                currentOwner.Value = -1L;
            }
            if (Game1.IsMasterGame && (long)currentOwner == -1 && requests.Count() > 0)
            {
                currentOwner.Value = requests.Keys.ElementAt(Game1.random.Next(requests.Count()));
            }
        }
Beispiel #2
0
 public void Update(FarmerCollection farmers)
 {
     lockRequest.Poll();
     if (owner.Value != prevOwner)
     {
         if (owner.Value == Game1.player.UniqueMultiplayerID && onLockAcquired != null)
         {
             onLockAcquired();
         }
         if (owner.Value != Game1.player.UniqueMultiplayerID && onLockFailed != null)
         {
             onLockFailed();
         }
         onLockAcquired = null;
         onLockFailed   = null;
         prevOwner      = owner.Value;
     }
     if (Game1.IsMasterGame && owner.Value != -1 && farmers.FirstOrDefault((Farmer f) => f.UniqueMultiplayerID == owner.Value) == null)
     {
         ReleaseLock();
     }
 }