public void Update(float deltaTime) { if (!IsStarted) { return; } for (int i = 0; i < pendingGoals.Count;) { var goal = pendingGoals[i]; goal.Update(deltaTime); if (!goal.IsCompleted) { ++i; } else { completedGoals.Add(goal); pendingGoals.RemoveAt(i); if (GameMain.Server != null) { Traitor.SendChatMessage(goal.CompletedText(Traitor), Traitor.Mission?.Identifier); if (pendingGoals.Count > 0) { Traitor.SendChatMessageBox(goal.CompletedText(Traitor), Traitor.Mission?.Identifier); } Traitor.UpdateCurrentObjective(GoalInfos, Traitor.Mission?.Identifier); } } } }
public void End(bool displayMessage) { if (displayMessage) { Traitor.SendChatMessageBox(EndMessageText); } }
public bool Start(Traitor traitor) { Traitor = traitor; activeGoals.Clear(); pendingGoals.Clear(); completedGoals.Clear(); var allGoalsCount = allGoals.Count; var indices = allGoals.Select((goal, index) => index).ToArray(); if (shuffleGoalsCount > 0) { for (var i = allGoalsCount; i > 1;) { int j = TraitorManager.RandomInt(i--); var temp = indices[j]; indices[j] = indices[i]; indices[i] = temp; } } for (var i = 0; i < allGoalsCount; ++i) { var goal = allGoals[indices[i]]; if (goal.Start(traitor)) { activeGoals.Add(goal); pendingGoals.Add(goal); if (shuffleGoalsCount > 0 && pendingGoals.Count >= shuffleGoalsCount) { break; } } else { completedGoals.Add(goal); } } if (pendingGoals.Count <= 0 && completedGoals.Count < allGoals.Count) { return(false); } IsStarted = true; traitor.SendChatMessageBox(StartMessageText, traitor.Mission?.Identifier); traitor.UpdateCurrentObjective(GoalInfos, traitor.Mission?.Identifier); return(true); }
public void EndMessage() { Traitor.SendChatMessageBox(EndMessageText, Traitor.Mission?.Identifier); Traitor.SendChatMessage(EndMessageText, Traitor.Mission?.Identifier); }