void AddNewObjective() { Array values = Objectives.GetValues(typeof(Objectives)); Objectives randomObjective = (Objectives)values.GetValue(UnityEngine.Random.Range(0, values.Length)); // var randomObjective = Objectives.MoveToArea; switch (randomObjective) { case Objectives.MoveToArea: objectiveManager.AddObjective(gameObject.AddComponent <MoveToArea>()); break; case Objectives.ActivateTarget: objectiveManager.AddObjective(gameObject.AddComponent <ActivateTarget>()); break; case Objectives.SurviveLasers: objectiveManager.AddObjective(gameObject.AddComponent <SurviveLasers>()); break; case Objectives.ActivateSafeZone: objectiveManager.AddObjective(gameObject.AddComponent <ActivateSafeZone>()); break; } }
public void OnTrigger() { if (triggerType == TriggerType.NewObjective) { if (objectivesID.Length > 1) { int[] result = objectiveManager.ReturnNonExistObjectives(objectivesID); if (result.Length > 1) { objectiveManager.AddObjectives(result, showTime); } else if (result.Length == 1) { objectiveManager.AddObjective(result[0], showTime); } } else { if (!objectiveManager.ContainsObjective(objectivesID[0])) { objectiveManager.AddObjective(objectivesID[0], showTime); } } isTriggered = true; } else if (triggerType == TriggerType.Complete) { if (objectiveManager.ContainsObjective(objective)) { objectiveManager.CompleteObjective(objective); isTriggered = true; } else if (preComplete) { objectiveManager.PreCompleteObjective(objective); isTriggered = true; } } else if (triggerType == TriggerType.CompleteAndNew) { bool contains = newWhenContains ? false : true; if (objectiveManager.ContainsObjective(objective)) { objectiveManager.CompleteObjective(objective); contains = true; isTriggered = true; } else if (preComplete) { objectiveManager.PreCompleteObjective(objective); contains = true; isTriggered = true; } if (contains) { if (objectivesID.Length > 1) { objectiveManager.AddObjectives(objectivesID, showTime, false); } else { objectiveManager.AddObjective(objectivesID[0], showTime, false); } } } }