public override void OnAddUser(AgentPrivate agent) { try { if (!PerUserStatus.ContainsKey(agent.AgentInfo.SessionId)) { PerUserStatus[agent.AgentInfo.SessionId] = new Status(); } for (int i = 0; i < Definitions.Count; ++i) { ObjectiveDefinition def = Definitions[i]; if (!def.IsValid || !def.Ready) { Log.Write(LogLevel.Warning, "Error getting quest state for quest for user " + agent.AgentInfo.Name + " : " + agent.AgentInfo.AvatarUuid); } int Index = i; if (agent != null && agent.IsValid) { def.GetObjective(agent, (data) => HandleObjective(data, Index)); } } } catch (Exception) { if (agent != null) { // The following are cached and okay to access as long as agent itself isn't null Log.Write(LogLevel.Warning, "Error getting quest state for quest for user " + agent.AgentInfo.Name + " : " + agent.AgentInfo.AvatarUuid); } else { Log.Write(LogLevel.Warning, "Error getting quest state for quest agent is null"); } } }
public override void InitVisibility() { if (Definitions.Count == 0) { Log.Write(LogLevel.Error, "Must add Objectives to track."); return; } int defCount = 0; for (int i = 0; i < Definitions.Count; ++i) { ObjectiveDefinition def = Definitions[i]; if (def != null) { defCount++; int Index = i; def.Update((data) => { if (!data.Success) { Log.Write(LogLevel.Error, "Error getting objective data."); return; } defCount--; All = All | (uint)(0x1 << Index); if (defCount == 0) { Setup(data); } }); } else { Log.Write(LogLevel.Error, "A definition set on the Visibility script on object " + ObjectPrivate.Name + " is null."); } } }
private void UpdateObjectives() { String description = ""; for (int i = 0; i < objectives.Length; i++) { ObjectiveDefinition objective = objectives[i]; if (objective.IsCompleted) { description += "X"; } description += "Get " + objective.gameObject.name + " to " + objective.goal.gameObject.name; if (i + 1 != objectives.Length) { description += Environment.NewLine; } } objectivesText.text = description; if (Array.TrueForAll <ObjectiveDefinition>(objectives, objective => objective.IsCompleted)) { if (SceneManager.GetActiveScene().buildIndex + 1 < SceneManager.sceneCountInBuildSettings) { Cursor.lockState = CursorLockMode.None; nextLevelButton.gameObject.SetActive(true); completionText.gameObject.SetActive(true); } else { GameFinished(); } } }