daily pastebin goal
57%
SHARE
TWEET

Police Chase Programming

a guest May 20th, 2016 15 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class TextController : MonoBehaviour {
  6.  
  7.     public Text text;
  8.  
  9.     private enum States {running, attack, corner, building, sewer, helicopter, stay, base_good, base_bad, game_complete};
  10.     private States myState;
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.         myState = States.running;
  15.    
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.         print (myState);
  21.         if (myState == States.running) {
  22.             running ();
  23.         } else if (myState == States.corner) {
  24.             corner ();
  25.         } else if (myState == States.building) {
  26.             building ();
  27.         } else if (myState == States.helicopter) {
  28.             helicopter ();
  29.         } else if (myState == States.base_good) {
  30.             base_good ();
  31.         } else if (myState == States.game_complete) {
  32.             game_complete ();
  33.         } else if (myState == States.attack) {
  34.             attack ();
  35.         } else if (myState == States.sewer) {
  36.             sewer ();
  37.         } else if (myState == States.stay) {
  38.             stay ();
  39.         } else if (myState == States.base_bad) {
  40.             base_bad ();
  41.         }
  42.     }
  43.  
  44.  
  45.     void running () {
  46.         text.text = "You're running from the police, and you don't want to get caught. " +
  47.                     "The government is corrupt, and you are fighting against it. " +
  48.                     "You find a bat on the street. There is also a corner. Will you " +
  49.                     "continue to run or attack the police?\n\n" +
  50.                     "Press A to attack the police and R to run around the corner.";
  51.         if (Input.GetKeyDown(KeyCode.R)) {
  52.             myState = States.corner;
  53.         }
  54.         if (Input.GetKeyDown (KeyCode.A)) {
  55.             myState = States.attack;
  56.         }
  57.     }
  58.  
  59.     void corner () {
  60.         text.text = "You run around the corner, but you can hear the police say " +
  61.                     "''He's around the corner!'' You find a hatch to the sewer and " +
  62.                     "an easy to climb building. Will you go into the sewer or climb the building?\n\n" +
  63.                     "Press S to go into the sewer and B to climb the building.";
  64.         if (Input.GetKeyDown(KeyCode.B)) {
  65.             myState = States.building;
  66.         }
  67.         if (Input.GetKeyDown (KeyCode.S)) {
  68.             myState = States.sewer;
  69.         }
  70.     }
  71.     void building () {
  72.             text.text = "You climb up the building and hear the police say ''He must be in the sewer!'' " +
  73.                         "You Got away, but only for now. The police say ''He might be on the building!'' " +
  74.                         "So you run. A helicopter comes, and tries to shoot you. He is in jumping range " +
  75.                         "of the building. Will you try to board the helicopter or stay where you are?\n\n" +
  76.                         "Press J to jump and S to stay.";
  77.         if (Input.GetKeyDown(KeyCode.J)) {
  78.             myState = States.helicopter;
  79.         }
  80.         if (Input.GetKeyDown (KeyCode.S)) {
  81.             myState = States.stay;
  82.         }
  83.     }
  84.  
  85.     void helicopter () {
  86.         text.text = "You jump onto the helicopter and pull the pilot and gunner out. " +
  87.                     "The police get on top of the building. Will you shoot the police or " +
  88.                     "fly to your base?\n\n" +
  89.                     "Press S to shoot or F to fly to your base?";
  90.         if (Input.GetKeyDown(KeyCode.F)) {
  91.             myState = States.base_good;
  92.         }
  93.         if (Input.GetKeyDown (KeyCode.S)) {
  94.             myState = States.base_bad;
  95.         }
  96.  
  97.     }
  98.  
  99.     void base_good () {
  100.         text.text = "You see Steve, the leader of the Rebels. He says ''Good mission, Captain. " +
  101.                     "You did well.''\n\n" +
  102.                     "Press Space to continue.";
  103.         if (Input.GetKeyDown (KeyCode.Space)) {
  104.             myState = States.game_complete;
  105.         }
  106.     }
  107.  
  108.     void game_complete () {
  109.         text.text = "Congratulations! You have completed Police Chase!";
  110.     }
  111.     void attack () {
  112.         text.text = "You attack the police with the bat. It's 5 on 1, and you lose and get brought " +
  113.                     "to prison.\n\n" +
  114.                     "Game Over, press Space to play again.";
  115.         if (Input.GetKeyDown (KeyCode.Space)) {
  116.             myState = States.running;
  117.         }
  118.     }
  119.  
  120.     void sewer () {
  121.         text.text = "You go into the sewer, but hear the police say ''He must be " +
  122.                     "in the sewer!'' You try to hide, but get caught by the police.\n\n" +
  123.                     "Game Over, press Space to play again.";
  124.         if (Input.GetKeyDown (KeyCode.Space)) {
  125.             myState = States.running;
  126.         }
  127.     }
  128.  
  129.     void stay () {
  130.         text.text = "You stay there, and the police come and take you to prison.\n\n" +
  131.                     "Game Over, press Space to play again.";
  132.         if (Input.GetKeyDown(KeyCode.Space)) {
  133.             myState = States.running;
  134.         }
  135.     }
  136.  
  137.     void base_bad () {
  138.         text.text = "You shoot the police and fly to your base. Steve, the leader of the Rebels, comes over to you and says ''What the heck man! The government may be corrupt, but that doesn't mean you can just kill everyone in it! We only kill if it is nessesary to bring down the government. You could have easily escaped! You are no longer with the Rebels. Go.''\n\n" +
  139.                     "Game Over, press Space to play again.";
  140.         if (Input.GetKeyDown (KeyCode.Space)) {
  141.             myState = States.running;
  142.         }
  143.     }
  144. }
RAW Paste Data
Top