Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public static class Game
- {
- public static bool Ended = false;
- }
- public class State
- {
- public State(string message, params string[] options)
- {
- Message = message;
- Options = options;
- }
- public string Message { get; private set; }
- public string[] Options { get; private set; }
- public string Theme { get; private set; }
- }
- public static class Choice
- {
- public static int Taken { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- // Console Runner
- foreach (var state in Play())
- {
- Prompt(state);
- }
- // For XNA/MonoGame
- /*
- var e = Play().GetEnumerator();
- while (e.MoveNext())
- {
- State state = e.Current;
- Prompt(state);
- }
- */
- }
- private static void Prompt(State state)
- {
- Console.WriteLine(state.Message);
- int n = 1;
- foreach (var option in state.Options)
- {
- Console.WriteLine(string.Format("{0}: {1}", n, option));
- ++n;
- }
- if (state.Options.Length == 0)
- {
- Console.WriteLine("THE END");
- Console.ReadLine();
- return;
- }
- Choice.Taken = 0;
- do {
- Console.Write("> ");
- var s = Console.ReadLine();
- n = 0;
- Int32.TryParse(s, out n);
- Choice.Taken = n;
- } while (Choice.Taken < 1 || Choice.Taken > state.Options.Length);
- Console.WriteLine();
- }
- public static IEnumerable<State> Play()
- {
- Game.Ended = false;
- foreach (var state in RansomNote()) yield return state;
- foreach (var state in BankRobbery()) yield return state;
- if (Game.Ended) yield break;
- foreach (var state in Assignment()) yield return state;
- if (Game.Ended) yield break;
- foreach (var state in Rookie()) yield return state;
- if (Game.Ended) yield break;
- foreach (var state in DropOff()) yield return state;
- if (Game.Ended) yield break;
- foreach (var state in Chase()) yield return state;
- if (Game.Ended) yield break;
- yield return new State(
- "Your last assignment is complete.\r\n" +
- "You receive a badge of honour and a full police pension!\r\n" +
- "Case closed."
- );
- }
- public static IEnumerable<State> RansomNote()
- {
- yield return new State(
- "You arrive at the murder scene on the top of a tower.\r\n" +
- "There's a dead girl in the pool.\r\n",
- "Search the scene");
- yield return new State(
- "You find a ransom note:\r\n" +
- "\"To the City of San Francisco, I will enjoy killing one person " +
- "every day until you pay me one hundred thousand dollars ($100,000).\r\n" +
- "If you agree say so tomorrow morning in Personal Column San Francisco Chronicle " +
- "and I will set up meeting.\r\n" +
- "If I do not hear from you it will be my next pleasure to kill " +
- "a Catholic priest.\"",
- "Sh*t"
- );
- }
- public static IEnumerable<State> BankRobbery()
- {
- // Hot dog
- yield return new State(
- "Your park up near Pine Street in front of an adult book shop, and saunter into the local Burger Den." +
- "You order",
- "Big Mac fries to go",
- "A jumbo hot dog");
- if (Choice.Taken == 1) yield break;
- // Bank robbery
- yield return new State(
- "From the bank across the street you hear a gun shot.",
- "You unholster your gun and head towards the bank",
- "Call and wait for backup");
- if (Choice.Taken == 2) yield break;
- // First robber
- yield return new State(
- "The first armed robber leaves the bank",
- "You shoot",
- "Take cover");
- if (Choice.Taken == 2) goto wounded;
- // Car
- yield return new State(
- "The second robber drives towards you",
- "You shoot",
- "Take cover");
- if (Choice.Taken == 2) goto wounded;
- yield return new State(
- "You missed.",
- "Shoot again",
- "Take cover");
- if (Choice.Taken == 2) goto wounded;
- yield return new State(
- "You fire twice.\r\n" +
- "The car veers off and hits a fire hydrant and flips over.\r\n" +
- "A third robber appears from the bank.",
- "You shoot",
- "Take cover"
- );
- // Wounded
- if (Choice.Taken == 2) goto wounded;
- yield return new State(
- "The shot robber lies wounded with a gun next to him." +
- "\"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum, the most powerful handgun in the world, and would blow your head clean off, you've got to ask yourself one question: Do I feel lucky? Well, do ya punk?\"",
- "He goes for the gun",
- "He pushes the gun away"
- );
- if (Choice.Taken == 2) yield break;
- // Bang bang
- yield return new State(
- "You blow his brains out.\r\n" +
- "The police arrive, you are arrested and discharged.");
- goto ended;
- wounded:
- yield return Shot();
- ended:
- Game.Ended = true;
- }
- public static State Shot()
- {
- return new State(
- "You awake in a white room with a nurse leaning over you." +
- "You were shot." +
- "The case has been reassigned");
- }
- public static IEnumerable<State> Assignment()
- {
- yield return new State(
- "You're sat outside the major's office.\r\n" +
- "They've kept you waiting for 45 minutes.",
- "You storm in",
- "Keep waiting");
- if (Choice.Taken == 1) goto kicked;
- yield return new State(
- "The major wants to pay the ransom and asks you to do the drop off.",
- "You don't do deals with criminals",
- "Tacitaly accept"
- );
- if (Choice.Taken == 2) yield break;
- kicked:
- Game.Ended = true;
- yield return new State(
- "It's the last straw for the major.\r\n" +
- "You're off the case!");
- }
- public static IEnumerable<State> Rookie()
- {
- yield return new State(
- "One way or another this will be your last assignment.\r\n" +
- "Just 2 weeks left on the force before you retire.\r\n" +
- "Back at the police station",
- "You get a black coffee and a donut",
- "A chai latte and a cup cake");
- if (Choice.Taken == 2) goto imposter;
- yield return new State(
- "Your new partner introduces himself.",
- "You give him a stern look",
- "Ignore him");
- yield return new State(
- "\"Why do they call ya 'Dirty Harry'?\"",
- "Make up your own mind kid",
- "Turn up your eye brow"
- );
- yield break;
- imposter:
- Game.Ended = true;
- yield return new State(
- "You have been exposed as an imposter.\r\n" +
- "Cops don't drink coffee, keep it real!");
- }
- public static IEnumerable<State> DropOff()
- {
- yield return new State(
- "Time for the drop off.\r\n" +
- "The lieutenant tells you no funny business.",
- "Go unarmed",
- "Pick up a wire, pack a knife and hide old faithfull (.44 Magnum)"
- );
- var unarmed = (Choice.Taken == 1);
- yield return new State(
- "You arrive at the drop off point with $100,000.",
- "Drop the bag in the bin"
- );
- yield return new State(
- "You turn the corner",
- "Carry on walking",
- "Wait and watch");
- if (Choice.Taken == 1) goto shot;
- var combatOptions =
- unarmed
- ? new[] { "Freeze", "Use your elbow"}
- : new[] { "Freeze", "Use the knife"};
- yield return new State(
- "You feel a gun against the back of your head",
- combatOptions
- );
- if (Choice.Taken == 1)
- foreach (var state in Taken()) yield return state;
- else
- yield return new State(
- "You wake up on the ground.\r\n" +
- "You feel a lump on the back of your head.",
- "Get up"
- );
- yield break;
- shot:
- Game.Ended = true;
- yield return new State(
- "You fall.\r\n" +
- "The sniper got you");
- }
- public static IEnumerable<State> Taken()
- {
- yield return new State(
- "\"Walk on\"",
- "You walk on",
- "\"Go on shoot me, ya know ya want to punk\""
- );
- if (Choice.Taken == 2) goto shot;
- yield break;
- shot:
- Game.Ended = true;
- yield return Shot();
- }
- public static IEnumerable<State> Chase()
- {
- yield return new State(
- "Your partner catches up with you.\r\n" +
- "\"I tailed that punk, he's hiding out at Ugly Mug Joe's\"\r\n",
- "\"What are you waiting for kid, lets go?\"",
- "\"Wait here kid\"");
- var partnerTaken = (Choice.Taken == 1);
- yield return new State(
- "Ugly Mug Joe's is a downtown dive bar full of low lifes.\r\n" +
- "As you enter the bar you are spotted.\r\n" +
- "He makes a run for it.",
- "Take a shot",
- "Chase after him"
- );
- if (Choice.Taken == 1)
- {
- if (partnerTaken)
- {
- yield return new State(
- "He turns and shoots.\r\n" +
- "Your partner is down.",
- "Chase after him"
- );
- }
- else goto dead;
- }
- yield return new State(
- "He slides into his car and takes off.",
- "Shoot",
- "Hot pursuit");
- if (Choice.Taken == 1) goto dead;
- yield return new State(
- "Your gaining on him.",
- "Shoot",
- "Ram him"
- );
- if (Choice.Taken == 1) goto dead;
- yield return new State(
- "He crashes into a fire hydrant.\r\n" +
- "You approach and find him unconcious.\r\n",
- "You read him his rights");
- yield break;
- dead:
- Game.Ended = true;
- yield return new State(
- "You miss.\r\n" +
- "He turns and shoots back.\r\n" +
- "Game Over"
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement