// Scene: Introduction!


class SceneIntroduction extends Scene {
  int id = SCENE_INTRODUCTION;
  SceneIntroduction() {
    super();
    
    // Initial setup
    beep.goTo(110,groundY);
    boop.goTo(width-110,groundY);
    camera.zoom = camera.zoomTarget = 0.5;
    camera.targetSprite = player;
    camera.goToTarget();
    
    sequenceController.addLinear("playerAnnounceSelf1", "mousePressed");
    sequenceController.addLinear("playerAnnounceSelf2", "mousePressed");
    sequenceController.addLinear("sidenote1", "mousePressed");
    sequenceController.addLinear("playerAnnounceSelf3", "mousePressed");
    sequenceController.addLinear("beepBoopGoToPlayer", "BeepReachedPlayer");
    sequenceController.addLinear("pollBestEver", "playerChoice");
    sequenceController.addLinear("pollBestEverResponse", "mousePressed");
    sequenceController.addLinear("pollBreakFourthWall", "playerChoice");
    sequenceController.addLinear("pollBreakFourthWallResponse", "mousePressed");
    sequenceController.addLinear("pollMenialChoices", "playerChoice");
    sequenceController.addLinear("pollMenialChoicesResponse", "mousePressed");
    sequenceController.addLinear("revealDoors", "mousePressed");
    sequenceController.addLinear("boopScary", "mousePressed");
    sequenceController.addLinear("doYouKnowWhichDoor", "mousePressed");
    sequenceController.addLinear("ofCourseIKnowWhichDoor", "mousePressed");
    sequenceController.addLinear("illTakeYouThereNow", "doorOpened");
    sequenceController.addLinear("advanceToNextScene");
    
    
//    sequenceController.addLinear("playerChoice");
//    sequenceController.addBranches(
//      ["beepSaysResponseA", "responseA"],
//      ["beepSaysResponseB", "responseB"],
//      ["beepSaysResponseC", "responseC"]
//    );
    
  }
  
  
  void executeEventByName(String name, String howLastEventEnded) {
    super.executeEventByName(name, howLastEventEnded);
    
    if (name == "playerAnnounceSelf1") {
      player.isMovementLocked = true;
      player.speak("Ahh, this is the life! Being the captain in an ambiguously styled environment.");
    }
    else if (name == "playerAnnounceSelf2") {
      player.speak("Game-jam quality? Pah! 48 hours is no match for the Captain.");
    }
    else if (name == "sidenote1") {
      screenTextOverlay = "DEVELOPER'S NOTE:\nI bit off so much more than I could chew. I built all of the systems and ran out of time to make content.\nWell, whatever.\n-Brett\n";
    }
    else if (name == "playerAnnounceSelf3") {
      player.speak("Yep! What an incredible, finished product we have here.");
    }
    else if (name == "beepBoopGoToPlayer") {
      camera.zoomTarget = 0.75;
      camera.targetSprite = null;
      beep.setState(beep.STATE_FOLLOWING_PLAYER);
      boop.setState(beep.STATE_FOLLOWING_PLAYER);
    }
    else if (name == "pollBestEver") {
      beep.setState(beep.STATE_IDLE);
      boop.setState(beep.STATE_IDLE);
      beep.speak("Captain! Captain! Will this game be the best ever??");
      poll = new Poll("Yes", "Absolutely");
    }
    
    else if (name == "pollBestEverResponse") {
      if (howLastEventEnded == "optionA") executeEventByName("pBER_A", null);
      else if (howLastEventEnded == "optionB") executeEventByName("pBER_A", null);
    }
    else if (name == "pBER_A") {
      beep.speak("You're so cool! Of COURSE it will be!!");
    }
    
    else if (name == "pollBreakFourthWall") {
      beep.speak("Will this game break the fourth wall?");
      poll = new Poll("Yes", "No");
    }
    else if (name == "pollBreakFourthWallResponse") {
      if (howLastEventEnded == "optionA") executeEventByName("pBFWR_A", null);
      else if (howLastEventEnded == "optionB") executeEventByName("pBFWR_A", null);
    }
    else if (name == "pBFWR_A") {
      beep.speak("Wow, I can't wait to see the repercussions of THAT response!");
    }
    
    else if (name == "pollMenialChoices") {
      boop.speak("Wait. Is this game all about menial choices like these, and your input irrelevant?");
      poll = new Poll("Let's go on an adventure!", "Who wants ice cream?", "Video games are the new black!");
    }
    else if (name == "pollMenialChoicesResponse") {
      if (howLastEventEnded == "optionA") executeEventByName("pollMenialResponse_A", null);
      else if (howLastEventEnded == "optionB") executeEventByName("pollMenialResponse_B", null);
      else if (howLastEventEnded == "optionC") executeEventByName("pollMenialResponse_C", null);
    }
    else if (name == "pollMenialResponse_A") {
      beep.speak("Yay, yay!");
      boop.speak("I LOVE adventures!!");
      makeBeepAndBoopExcited();
    }
    else if (name == "pollMenialResponse_B") {
      beep.speak("Yummmmm!");
      boop.speak("Ice cream is my favorite flavor!!!");
      makeBeepAndBoopExcited();
    }
    else if (name == "pollMenialResponse_C") {
      beep.speak("Profound!");
      boop.speak("Captain, you're the real trendsetter!");
      makeBeepAndBoopExcited();
    }
    
    else if (name == "revealDoors") {
      camera.zoomTarget = 1;
      doors.add(new Door(0, 100,groundY-30));
      doors.add(new Door(1, width-100,groundY-30));
      player.speak("Look out! One of these doors leads to FUN ADVENTURES, while the other leads to IMMEDIATE PERIL.");
      beep.setState(beep.STATE_IDLE);
      boop.setState(beep.STATE_IDLE);
    }
    else if (name == "boopScary") {
      boop.speak("Scary!");
      boop.setState(beep.STATE_EXCITED);
    }
    else if (name == "doYouKnowWhichDoor") {
      beep.speak("Captain! Do you know which door is which??");
      boop.setState(beep.STATE_IDLE);
    }
    else if (name == "ofCourseIKnowWhichDoor") {
      player.speak("Ha! Of course I know which door leads to the fun!");
    }
    else if (name == "illTakeYouThereNow") {
      player.isMovementLocked = false;
      player.speak("I'll take you there now!");
      beep.setState(beep.STATE_FOLLOWING_PLAYER);
      boop.setState(beep.STATE_FOLLOWING_PLAYER);
    }
    else if (name == "advanceToNextScene") {
      loadScene(SCENE_TBC);
    }
    
    else {
      println("ERROR! We tried to execute an event that we didn't specify the outcome for: " + name);
    }
  }
  
}



