예제 #1
0
 protected override void Update(GameTime gameTime)
 {
     for (int i = 0; i < activeNewDayProcesses.Count; i++)
     {
         KeyValuePair <Game1, IEnumerator <int> > active_new_days = activeNewDayProcesses[i];
         Game1 instance = activeNewDayProcesses[i].Key;
         LoadInstance(instance);
         if (!active_new_days.Value.MoveNext())
         {
             instance.isLocalMultiplayerNewDayActive = false;
             activeNewDayProcesses.RemoveAt(i);
             i--;
             Utility.CollectGarbage();
         }
         SaveInstance(instance);
     }
     while (startButtonState.Count < 4)
     {
         startButtonState.Add(-1);
     }
     for (PlayerIndex player_index = PlayerIndex.One; player_index <= PlayerIndex.Four; player_index++)
     {
         if (GamePad.GetState(player_index).IsButtonDown(Buttons.Start))
         {
             if (startButtonState[(int)player_index] >= 0)
             {
                 startButtonState[(int)player_index]++;
             }
         }
         else if (startButtonState[(int)player_index] != 0)
         {
             startButtonState[(int)player_index] = 0;
         }
     }
     for (int j = 0; j < gameInstances.Count; j++)
     {
         Game1 instance2 = gameInstances[j];
         LoadInstance(instance2);
         if (j == 0)
         {
             PlayerIndex start_player_index = PlayerIndex.Two;
             if (instance2.instanceOptions.gamepadMode == Options.GamepadModes.ForceOff)
             {
                 start_player_index = PlayerIndex.One;
             }
             for (PlayerIndex player_index2 = start_player_index; player_index2 <= PlayerIndex.Four; player_index2++)
             {
                 bool fail = false;
                 foreach (Game1 gameInstance in gameInstances)
                 {
                     if (gameInstance.instancePlayerOneIndex == player_index2)
                     {
                         fail = true;
                         break;
                     }
                 }
                 if (!fail && instance2.IsLocalCoopJoinable() && IsStartDown(player_index2) && instance2.ShowLocalCoopJoinMenu())
                 {
                     InvalidateStartPress(player_index2);
                 }
             }
         }
         else
         {
             Game1.options.gamepadMode = Options.GamepadModes.ForceOn;
         }
         instance2.Instance_Update(gameTime);
         SaveInstance(instance2);
     }
     if (gameInstancesToRemove.Count > 0)
     {
         foreach (Game1 instance3 in gameInstancesToRemove)
         {
             LoadInstance(instance3);
             instance3.exitEvent(null, null);
             gameInstances.Remove(instance3);
             Game1.game1 = null;
         }
         for (int k = 0; k < gameInstances.Count; k++)
         {
             gameInstances[k].instanceIndex = k;
         }
         if (gameInstances.Count == 1)
         {
             Game1 game = gameInstances[0];
             LoadInstance(game, force: true);
             game.staticVarHolder = null;
             Game1.EndLocalMultiplayer();
         }
         bool controller_1_assigned = false;
         if (gameInstances.Count > 0)
         {
             foreach (Game1 gameInstance2 in gameInstances)
             {
                 if (gameInstance2.instancePlayerOneIndex == PlayerIndex.One)
                 {
                     controller_1_assigned = true;
                     break;
                 }
             }
             if (!controller_1_assigned)
             {
                 gameInstances[0].instancePlayerOneIndex = PlayerIndex.One;
             }
         }
         gameInstancesToRemove.Clear();
         _windowSizeChanged = true;
     }
     base.Update(gameTime);
 }