Esempio 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());
        }
Esempio 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;
        }
Esempio 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();
     }
 }
Esempio n. 4
0
 public virtual void onNotAvailable()
 {
     if (notavailableMessageAction == null)
     {
         CIO.PrintError("not avaulable");
     }
     else
     {
         CIO.PrintError(notavailableMessageAction());
     }
 }
Esempio 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");
     }
 }
Esempio n. 6
0
 public virtual void onFailure()
 {
     if (OnFailure == null)
     {
         CIO.PrintError("Failed (generic)");
     }
     else
     {
         foreach (Action a in OnFailure)
         {
             a();
         }
     }
 }
Esempio 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();
        }
Esempio 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();
                }
            }
        }
Esempio 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;
        }
Esempio 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);
        }
Esempio 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();
        }
Esempio n. 12
0
 public override void onFailure()
 {
     CIO.Print("the guard doesnt accept your bribe");
 }
Esempio n. 13
0
 public override void onNotAvailable()
 {
     CIO.Print("Not Enough money");
 }
Esempio 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);
 }