Ejemplo n.º 1
0
        public static void LoadAll()
        {
            void AddCheat(string s, Action a)
            {
                s = s.ToLower();
                if (commands.ContainsKey(s))
                {
                    commands[s].Add(a);
                }
                else
                {
                    commands.Add(s, new List <Action>());
                    commands[s].Add(a);
                }
            }

            AddCheat("give gold", () => GlobalCommands.GiveGold());
            AddCheat("i", () => Player.getInstance().OpenInventory());
            AddCheat("s", () => Player.getInstance().OpenSpellbook());
            AddCheat("Attack", () => Attack());
            AddCheat("h", () => Help());
            AddCheat("help", () => Help());
            AddCheat("give sword", () => GiveSword());
            AddCheat("give xp", () => GiveXP());
            AddCheat("debug", () => CIO.ToggleDebugging());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Print the enter-message
        /// </summary>
        public virtual Boolean OnEnter()
        {
            /// This function gets called when the Room is Entered
            /// The magic stuff happens here: sub classes implement their story in this Func
            CIO.Print("you entered " + name);

            return true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// reprints the current top-Context below
 /// </summary>
 public static void ReEnterCurrentContext()
 {
     CIO.Clear();
     if (lastContexts.Count > 0)
     {
         lastContexts[lastContexts.Count - 1].Enter();
     }
 }
Ejemplo n.º 4
0
 public virtual void onNotAvailable()
 {
     if (notavailableMessageAction == null)
     {
         CIO.PrintError("not avaulable");
     }
     else
     {
         CIO.PrintError(notavailableMessageAction());
     }
 }
Ejemplo n.º 5
0
 public static void Help()
 {
     if (CIO.GetCurrentContext().name == "Inventory.Category")
     {
         CIO.PrintHelp("help for Inventory");
     }
     else
     {
         CIO.PrintHelp("type i for inventory");
         CIO.PrintHelp("type s for Spellbook");
         CIO.PrintHelp("type Attack to attack an NPC");
     }
 }
Ejemplo n.º 6
0
 public virtual void onFailure()
 {
     if (OnFailure == null)
     {
         CIO.PrintError("Failed (generic)");
     }
     else
     {
         foreach (Action a in OnFailure)
         {
             a();
         }
     }
 }
Ejemplo n.º 7
0
        public static void Attack()
        {
            CIO.Print("Which NPC?");
            string input = CIO.ReadLine();

            if (wannaExit(input))
            {
                return;
            }
            Character enemy = Program.currentRoom.getNPCByName(input);
            Fight     f     = new Fight(enemy);

            f.startFight();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            player = Player.getInstance();

            createStartRoom();
            CIO.Initialize();
            currentRoom = Room.AllRooms[typeof(GameContent.Rooms.Forest_start)];
            GlobalCommands.GiveSword();
            player.LearnSpell(Spell.Flames);


            while (true)
            {
                Console.WriteLine("#########################");
                Room r = currentRoom;
                if (r.OnEnter())
                {
                    Room nextroom = null;
                    while (nextroom == null)
                    {
                        Optionhandler h;
                        if (r.ActivitiesInRoom != null)//print activities if there are any
                        {
                            h = new Optionhandler(r.name + ". Activities:");
                            h.AddOptions(r.ActivitiesInRoom);
                            h.AddHeading("Next Rooms:");
                        }
                        else
                        {
                            h = new Optionhandler(r.name + ". next room?");
                        }
                        h.AddOptions(Optionhandler.RoomsToOption(r.nextRooms));
                        Option selectedOpt = h.selectOption();
                        if (selectedOpt.GetType().IsSubclassOf(typeof(Room)))
                        {
                            nextroom = (Room)selectedOpt;
                        }
                    }
                    CIO.Clear();
                    currentRoom.OnExit();
                    currentRoom = nextroom;
                }
                else
                {
                    CIO.Clear();
                    r.OnExit();
                }
            }
        }
Ejemplo n.º 9
0
        public static void executeCheat(string s)
        {
            if (!commands.ContainsKey(s))
            {
                return;
            }
            Console.ForegroundColor = ConsoleColor.White;

            foreach (Action a in commands[s])
            {
                a();
            }
            CIO.ReEnterCurrentContext();
            Console.ForegroundColor = ConsoleColor.Blue;
        }
Ejemplo n.º 10
0
        public static void GiveXP()
        {
            int amount = -1;

            while (amount == -1)
            {
                CIO.Print("How much?");
                string input = CIO.ReadLine();
                if (wannaExit(input))
                {
                    return;
                }
                Int32.TryParse(input, out amount);
            }
            Player.getInstance().GiveXP(amount);
        }
Ejemplo n.º 11
0
        public static void GiveGold()
        {
            CIO.StartNewContext(new Handlers.IO.Context("How much?"));
            int amount = -1;

            while (amount == -1)
            {
                CIO.Print("How much?");
                string input = CIO.ReadLine();
                if (wannaExit(input))
                {
                    return;
                }
                Int32.TryParse(input, out amount);
            }
            Player.getInstance().AddGold(amount);
            CIO.EndContextWithoutReEnter();
        }
Ejemplo n.º 12
0
 public override void onFailure()
 {
     CIO.Print("the guard doesnt accept your bribe");
 }
Ejemplo n.º 13
0
 public override void onNotAvailable()
 {
     CIO.Print("Not Enough money");
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Print the leave-message
 /// </summary>
 public virtual void OnExit()
 {
     // This function gets called when the Room is Exited
     CIO.Print("you left " + name);
 }