public override Boolean OnKeyMenu(GameObject go) { if (base.OnKeyMenu(go) && !_hidingHud && ButtonGroupState.ActiveGroup == CommandGroupButton) { if (ReadyQueue.Count > 1) { Int32 num = ReadyQueue[0]; ReadyQueue.RemoveAt(0); ReadyQueue.Add(num); using (List <Int32> .Enumerator enumerator = ReadyQueue.GetEnumerator()) { while (enumerator.MoveNext()) { Int32 current = enumerator.Current; if (!InputFinishList.Contains(current) && !_unconsciousStateList.Contains(current) && current != CurrentPlayerIndex) { if (ReadyQueue.IndexOf(current) > 0) { ReadyQueue.Remove(current); ReadyQueue.Insert(0, current); } SwitchPlayer(current); break; } } } } else if (ReadyQueue.Count == 1) { SwitchPlayer(ReadyQueue[0]); } } return(true); }
/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("Gantt Chart"); Console.WriteLine("_________________________________________________________________"); double _tat = 0; double _wt = 0; while (ReadyQueue.Count > 0) { Process _tempProcess = ReadyQueue[0] as Process; double _originalBurst = _tempProcess.Burst; if (_tempProcess.RRStart.Equals(0) && _tempProcess.RRBurst.Equals(0)) { _tempProcess.RRStart = Counter; } if (_tempProcess.RRBurst.Equals(0)) { _tempProcess.RRBurst = _originalBurst; } _tempProcess.Burst = Quanta; ExecuteProcess(_tempProcess); _tempProcess.Burst = _originalBurst - Quanta; if (_tempProcess.Burst <= 0) { _tempProcess.IsCompleted = true; _tempProcess.Burst = _tempProcess.RRBurst; _tempProcess.StartTime = _tempProcess.RRStart; _tempProcess.EndTime = Counter; _tempProcess.WaitTime = _tempProcess.TurnAroundTime - _tempProcess.Burst; PreviousProcessEndTime = _tempProcess.EndTime; _tat += _tempProcess.TurnAroundTime; _wt += _tempProcess.WaitTime; ReadyQueue.Remove(_tempProcess); CompletedQueue.Add(_tempProcess); } else { PreviousProcessEndTime = Counter; ReadyQueue = ReadyQueue.Skip(1).Concat(ReadyQueue.Take(1)).ToList(); } } TotalTurnAroundTime = _tat; TotalWaitTime = _wt; Console.WriteLine("_________________________________________________________________"); }
public void RemovePlayerFromAction(Int32 btlId, Boolean isNeedToClearCommand) { Int32 num = 0; while (1 << num != btlId) { ++num; } if (InputFinishList.Contains(num) && isNeedToClearCommand) { InputFinishList.Remove(num); } if (!ReadyQueue.Contains(num) || !isNeedToClearCommand) { return; } ReadyQueue.Remove(num); }