public float timer = 0f;     //for defend objectives

    void Awake()
    {
        instance = this;

        if (savedObjectiveId == 0)
        {
            savedObjectiveId = startingObjective;
        }

        curObjectiveId = savedObjectiveId;

        winScreen.SetActive(false);
        winText = winScreen.transform.Find("Window").Find("Title").GetComponent <Text>();
        pc      = GameObject.FindObjectOfType <PlayerController> ();

        objectiveEdgeView = EdgeView.Create(false);
        objectiveEdgeView.Hide();

        PrepareObjectives();

        if (gameTimer != null)
        {
            gameTimer.enabled = curObjective.timerActiveState;

            if (timeRemaining > 0)
            {
                gameTimer.Init(timeRemaining);
                return;
            }

            int firstTimerIndex = 0;             //find the first event with a timer
            while (!objectives [firstTimerIndex].timerActiveState)
            {
                firstTimerIndex++;
            }

            if (firstTimerIndex > savedObjectiveId)
            {
                gameTimer.Init(objectives [firstTimerIndex].time);                  //set it to what it will start as
            }
            else
            {
                foreach (GameTimerEvent timerEvent in gameTimer.timerEvents)
                {
                    if (timerEvent.isActivatedOncePassed && savedObjectiveId > timerEvent.objectiveIdsToActivateOn[0])
                    {
                        timerEvent.onTimerEnd.Invoke();                          //we finished the timer so invoke whatever methods we were supposed to invoke
                    }
                }
            }
        }
    }
    IEnumerator InitNextObjective()
    {
        objectiveEdgeView.Hide();
        NotificationManager.instance.HideHelp();

        if (objectives.Count == 0)
        {
            Debug.LogError("No objectives to set up");
            yield break;
        }

        //some UI updates before the initial delay
        timerAnim.SetBool("Open", curObjective.timerActiveState);

        if (firstTime)
        {
            firstTime = false;
            yield return(new WaitForSeconds(curObjective.initialDelay));

            foreach (NotificationManager.SplashData message in curObjective.startingSplashes)
            {
                NotificationManager.instance.ShowSplash(message);
            }
            if (curObjective.startingSplashes.Count > 0)
            {
                SwipeManager.instance.EndSwipe();
            }
        }

        switch (curObjective.type)
        {
        case Objective.Type.Pickup:
            curObjective.objectiveObj.tag = "Pickup";
            Pickup pickup = curObjective.objectiveObj.GetComponent <Pickup> ();
            if (pickup != null)
            {
                pickup.isObjective = true;
            }
            break;

        case Objective.Type.Zone:
            PlayerTrigger trigger = curObjective.objectiveObj.AddComponent <PlayerTrigger> ();
            trigger.enterActions.AddListener(CompleteObjective);
            trigger.oneTime = true;
            break;

        case Objective.Type.Kills:
            StartCoroutine(CheckForEnemyDeaths());
            break;

        case Objective.Type.Vehicle:
            curObjective.objectiveObj.GetComponent <Rideable> ().SetupObjective();
            break;

        case Objective.Type.Camera:
            StartCoroutine(CameraEvent());
            break;

        case Objective.Type.Defend:
            timer = curObjective.time;
            break;
        }

        if (curObjective.animation != null && curObjective.type != Objective.Type.Camera)
        {
            curObjective.animation.SetTrigger("Play");
        }

        if (gameTimer != null)
        {
            gameTimer.enabled = curObjective.timerActiveState;
            if (curObjective.timerActiveState && curObjective.time > 0)
            {
                gameTimer.Init(curObjective.time);
            }
        }

        UpdateObjectiveUI();
    }