Пример #1
0
 public static void ShowTutorialTopic(TutorialTopic topicId)
 {
     UiSystems.HelpManager.ShowTutorialTopic(topicId);
 }
        public static void LoadOptions()
        {
            if (!File.Exists("options.txt"))
            {
                return;
            }
            StreamReader file = new StreamReader("options.txt");
            string       s    = "";

            while (s.Length < 2 || s.Substring(0, 2) != "--")
            {
                s = file.ReadLine();
                if (s.Length >= 2 && s.Substring(0, 2) == "--")
                {
                    break;
                }
                string[] tokens = s.Split(' ');
                if (tokens[0].Length == 1)
                {
                    char c = Char.ToUpper(tokens[0][0]);
                    if (c == 'F' || c == 'T')
                    {
                        OptionType option = (OptionType)Enum.Parse(typeof(OptionType), tokens[1], true);
                        if (c == 'F')
                        {
                            Options[option] = false;
                        }
                        else
                        {
                            Options[option] = true;
                        }
                    }
                }
            }
            s = "";
            while (s.Length < 2 || s.Substring(0, 2) != "--")
            {
                s = file.ReadLine();
                if (s.Length >= 2 && s.Substring(0, 2) == "--")
                {
                    break;
                }
                string[] tokens = s.Split(' ');
                if (tokens[0].Length == 1)
                {
                    char c = Char.ToUpper(tokens[0][0]);
                    if (c == 'F' || c == 'T')
                    {
                        TutorialTopic topic = TutorialTopic.Movement;
                        bool          valid = true;
                        try{
                            topic = (TutorialTopic)Enum.Parse(typeof(TutorialTopic), tokens[1], true);
                        }
                        catch (ArgumentException e) {
                            valid = false;
                        }
                        if (valid)
                        {
                            if (c == 'F' || Global.Option(OptionType.ALWAYS_RESET_TIPS))
                            {
                                Help.displayed[topic] = false;
                            }
                            else
                            {
                                Help.displayed[topic] = true;
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
		public static async Task TutorialTip(TutorialTopic topic){
			if(Global.Option(OptionType.NEVER_DISPLAY_TIPS) || displayed[topic]){
				return;
			}
			Color box_edge_color = Color.Blue;
			Color box_corner_color = Color.Yellow;
			Color first_line_color = Color.Yellow;
			Color text_color = Color.Gray;
			string[] text = TutorialText(topic);
			int stringwidth = 27; // length of "[Press any key to continue]"
			foreach(string s in text){
				if(s.Length > stringwidth){
					stringwidth = s.Length;
				}
			}
			stringwidth += 4; //2 blanks on each side
			int boxwidth = stringwidth + 2;
			int boxheight = text.Length + 5;
			//for(bool done=false;!done;){
			colorstring[] box = new colorstring[boxheight]; //maybe i should make this a list to match the others
			box[0] = new colorstring("+",box_corner_color,"".PadRight(stringwidth,'-'),box_edge_color,"+",box_corner_color);
			box[text.Length + 1] = new colorstring("|",box_edge_color,"".PadRight(stringwidth),Color.Gray,"|",box_edge_color);
            box[text.Length + 2] = new colorstring("|", box_edge_color) + ("[Press any key to continue]".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here
            box[text.Length + 3] = new colorstring("|", box_edge_color) + ("[=] Stop showing tips".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here
			box[text.Length + 4] = new colorstring("+",box_corner_color,"".PadRight(stringwidth,'-'),box_edge_color,"+",box_corner_color);
			int pos = 1;
			foreach(string s in text){
                box[pos] = new colorstring("|", box_edge_color) + (s.PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here
				if(pos == 1){
					box[pos] = new colorstring();
					box[pos].strings.Add(new cstr("|",box_edge_color));
                    box[pos].strings.Add(new cstr(s.PadOuter(stringwidth), first_line_color)); //PadOuter originally here
					box[pos].strings.Add(new cstr("|",box_edge_color));
				}
				++pos;
			}
			int y = (Global.SCREEN_H - boxheight) / 2;
			int x = (Global.SCREEN_W - boxwidth) / 2;
			colorchar[,] memory = Screen.GetCurrentRect(y,x,boxheight,boxwidth);
			List<List<colorstring>> frames = new List<List<colorstring>>();
			frames.Add(BoxAnimationFrame(boxheight-2,FrameWidth(boxheight,boxwidth)));
			for(int i=boxheight-4;i>0;i-=2){
				frames.Add(BoxAnimationFrame(i,FrameWidth(frames.Last().Count,frames.Last()[0].Length())));
			}
			for(int i=frames.Count-1;i>=0;--i){ //since the frames are in reverse order
				int y_offset = i + 1;
				int x_offset = (boxwidth - frames[i][0].Length()) / 2;
				Screen.WriteList(y+y_offset,x+x_offset,frames[i]);
                await Task.Delay(20);
			}
			foreach(colorstring s in box){
				Screen.WriteString(y,x,s);
				++y;
			}
			Actor.player.DisplayStats(false);
			if(topic != TutorialTopic.Feats){ //hacky exception - don't get rid of the line that's already there.
				Actor.B.DisplayNow();
			}
			Game.Console.CursorVisible = false;
            await Task.Delay(500);
			Global.FlushInput();
			/*	switch(Game.Console.ReadKey(true).KeyChar){
				case 'q':
					box_edge_color = NextColor(box_edge_color);
					break;
				case 'w':
					box_corner_color = NextColor(box_corner_color);
					break;
				case 'e':
					first_line_color = NextColor(first_line_color);
					break;
				case 'r':
					text_color = NextColor(text_color);
					break;
				default:
					done=true;
					break;
				}
			}*/
			if((await Game.Console.ReadKey(true)).KeyChar == '='){
				Global.Options[OptionType.NEVER_DISPLAY_TIPS] = true;
			}
			Screen.WriteArray((Global.SCREEN_H - boxheight) / 2,x,memory);
			if(topic != TutorialTopic.Feats){ //another exception
				Actor.player.DisplayStats(true);
			}
			displayed[topic] = true;
			Game.Console.CursorVisible = true;
		}
Пример #4
0
		public static string[] TutorialText(TutorialTopic topic){
			switch(topic){
			case TutorialTopic.Movement:
				return new string[]{
					"Moving around",
					"",
					"Use the numpad [1-9] to move. Press",
					"[5] to wait.",
					"",
					"If you have no numpad, you can use",
					"the arrow keys or [hjkl] to move,",
					"using [yubn] for diagonal moves.",
					"",
					"This tip won't appear again. If you",
					"wish to view all tips, you can find",
					"them by pressing [?] for help."};
			case TutorialTopic.Attacking:
				return new string[]{
					"Attacking enemies",
					"",
					"To make a melee attack, simply try to",
					"move toward an adjacent monster."};
			case TutorialTopic.Torch:
				return new string[]{
					"Using your torch",
					"",
					"You carry a torch that illuminates",
					"your surroundings, but its light makes",
					"your presence obvious to enemies.",
					"",
					"To put your torch away (or bring it",
					"back out), press [t].",
					"",
					"You won't be able to see quite as far without",
					"your torch (and you'll have a harder time",
					"spotting hidden things), but you'll be able",
					"to sneak around without automatically",
					"alerting monsters."};
			case TutorialTopic.Resistance:
				return new string[]{
					"Resisted!",
					"",
					"Some monsters take half damage from certain",
					"attack types. If a monster resists one of your",
					"attacks, you can switch to a different",
					"weapon by pressing [e] to access the",
					"equipment screen.",
					"",
					"For example, skeletons resist several types of",
					"damage, but are fully vulnerable to maces."};
			case TutorialTopic.RangedAttacks:
				return new string[]{
					"Ranged attacks",
					"",
					"There are some monsters that are best dispatched",
					"at a safe distance. You can switch to your bow",
					"by pressing [e] to access the equipment screen.",
					"",
					"Once you've readied your bow, press [s] to shoot."};
			case TutorialTopic.Feats:
				return new string[]{
					"Feats",
					"",
					"Feats are special abilities",
					"you can learn at shrines.",
					"",
					"You need to put ALL of the required",
					"points into a feat before you can",
					"use it."};
			case TutorialTopic.Armor:
				return new string[]{
					"Armor",
					"",
					"Armor helps you to avoid taking damage from",
					"attacks, but heavy armor also interferes with",
					"both stealth and magic spells.",
					"",
					"If you don't need stealth or magic, wear",
					"full plate for the best protection."};
			case TutorialTopic.Fire:
				return new string[]{
					"You're on fire!",
					"",
					"You'll take damage each turn",
					"until you put it out.",
					"",
					"Stand still by pressing [.] and",
					"you'll try to put out the fire."};
			case TutorialTopic.Recovery:
				return new string[]{
					"Recovering health",
					"",
					"Take advantage of your natural recovery. Your",
					"health will slowly return until your HP reaches",
					"a multiple of 10 (so if your health is 74/100,",
					"it'll go back up to 80/100, and then stop).",
					"",
					"If that isn't enough, you can restore more HP by",
					"resting. Press [r], and if you're undisturbed for",
					"10 turns, you'll regain half of your missing HP",
					"(and restore your magic reserves, if applicable).",
					"",
					"You can rest only once per dungeon level, but your",
					"natural recovery always works."};
			case TutorialTopic.HealingPool:
				return new string[]{
					"Healing pools",
					"",
					"Perhaps a relative of wishing wells, healing",
					"pools are a rare feature of the dungeon that",
					"can fully restore your health.",
					"",
					"To activate a healing pool, drop in an item",
					"by pressing [d]."};
			case TutorialTopic.Consumables:
				return new string[]{
					"Using consumable items",
					"",
					"Sometimes death is unavoidable.",
					"",
					"However, consumable items can",
					"get you out of some desperate",
					"situations.",
					"",
					"When all hope seems lost, be sure to",
					"check your inventory."};
			default:
				return new string[0]{};
			}
		}
Пример #5
0
        public static async Task TutorialTip(TutorialTopic topic)
        {
            if (Global.Option(OptionType.NEVER_DISPLAY_TIPS) || displayed[topic])
            {
                return;
            }
            Color box_edge_color   = Color.Blue;
            Color box_corner_color = Color.Yellow;
            Color first_line_color = Color.Yellow;
            Color text_color       = Color.Gray;

            string[] text        = TutorialText(topic);
            int      stringwidth = 27;        // length of "[Press any key to continue]"

            foreach (string s in text)
            {
                if (s.Length > stringwidth)
                {
                    stringwidth = s.Length;
                }
            }
            stringwidth += 4;             //2 blanks on each side
            int boxwidth  = stringwidth + 2;
            int boxheight = text.Length + 5;

            //for(bool done=false;!done;){
            colorstring[] box = new colorstring[boxheight];             //maybe i should make this a list to match the others
            box[0] = new colorstring("+", box_corner_color, "".PadRight(stringwidth, '-'), box_edge_color, "+", box_corner_color);
            box[text.Length + 1] = new colorstring("|", box_edge_color, "".PadRight(stringwidth), Color.Gray, "|", box_edge_color);
            box[text.Length + 2] = new colorstring("|", box_edge_color) + ("[Press any key to continue]".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here
            box[text.Length + 3] = new colorstring("|", box_edge_color) + ("[=] Stop showing tips".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color);       //PadOuter originally here
            box[text.Length + 4] = new colorstring("+", box_corner_color, "".PadRight(stringwidth, '-'), box_edge_color, "+", box_corner_color);
            int pos = 1;

            foreach (string s in text)
            {
                box[pos] = new colorstring("|", box_edge_color) + (s.PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here
                if (pos == 1)
                {
                    box[pos] = new colorstring();
                    box[pos].strings.Add(new cstr("|", box_edge_color));
                    box[pos].strings.Add(new cstr(s.PadOuter(stringwidth), first_line_color)); //PadOuter originally here
                    box[pos].strings.Add(new cstr("|", box_edge_color));
                }
                ++pos;
            }
            int y = (Global.SCREEN_H - boxheight) / 2;
            int x = (Global.SCREEN_W - boxwidth) / 2;

            colorchar[,] memory = Screen.GetCurrentRect(y, x, boxheight, boxwidth);
            List <List <colorstring> > frames = new List <List <colorstring> >();

            frames.Add(BoxAnimationFrame(boxheight - 2, FrameWidth(boxheight, boxwidth)));
            for (int i = boxheight - 4; i > 0; i -= 2)
            {
                frames.Add(BoxAnimationFrame(i, FrameWidth(frames.Last().Count, frames.Last()[0].Length())));
            }
            for (int i = frames.Count - 1; i >= 0; --i)     //since the frames are in reverse order
            {
                int y_offset = i + 1;
                int x_offset = (boxwidth - frames[i][0].Length()) / 2;
                Screen.WriteList(y + y_offset, x + x_offset, frames[i]);
                await Task.Delay(20);
            }
            foreach (colorstring s in box)
            {
                Screen.WriteString(y, x, s);
                ++y;
            }
            Actor.player.DisplayStats(false);
            if (topic != TutorialTopic.Feats)             //hacky exception - don't get rid of the line that's already there.
            {
                Actor.B.DisplayNow();
            }
            Game.Console.CursorVisible = false;
            await Task.Delay(500);

            Global.FlushInput();

            /*	switch(Game.Console.ReadKey(true).KeyChar){
             *      case 'q':
             *              box_edge_color = NextColor(box_edge_color);
             *              break;
             *      case 'w':
             *              box_corner_color = NextColor(box_corner_color);
             *              break;
             *      case 'e':
             *              first_line_color = NextColor(first_line_color);
             *              break;
             *      case 'r':
             *              text_color = NextColor(text_color);
             *              break;
             *      default:
             *              done=true;
             *              break;
             *      }
             * }*/
            if ((await Game.Console.ReadKey(true)).KeyChar == '=')
            {
                Global.Options[OptionType.NEVER_DISPLAY_TIPS] = true;
            }
            Screen.WriteArray((Global.SCREEN_H - boxheight) / 2, x, memory);
            if (topic != TutorialTopic.Feats)             //another exception
            {
                Actor.player.DisplayStats(true);
            }
            displayed[topic]           = true;
            Game.Console.CursorVisible = true;
        }
Пример #6
0
        public static string[] TutorialText(TutorialTopic topic)
        {
            switch (topic)
            {
            case TutorialTopic.Movement:
                return(new string[] {
                    "Moving around",
                    "",
                    "Use the numpad [1-9] to move. Press",
                    "[5] to wait.",
                    "",
                    "If you have no numpad, you can use",
                    "the arrow keys or [hjkl] to move,",
                    "using [yubn] for diagonal moves.",
                    "",
                    "This tip won't appear again. If you",
                    "wish to view all tips, you can find",
                    "them by pressing [?] for help."
                });

            case TutorialTopic.Attacking:
                return(new string[] {
                    "Attacking enemies",
                    "",
                    "To make a melee attack, simply try to",
                    "move toward an adjacent monster."
                });

            case TutorialTopic.Torch:
                return(new string[] {
                    "Using your torch",
                    "",
                    "You carry a torch that illuminates",
                    "your surroundings, but its light makes",
                    "your presence obvious to enemies.",
                    "",
                    "To put your torch away (or bring it",
                    "back out), press [t].",
                    "",
                    "You won't be able to see quite as far without",
                    "your torch (and you'll have a harder time",
                    "spotting hidden things), but you'll be able",
                    "to sneak around without automatically",
                    "alerting monsters."
                });

            case TutorialTopic.Resistance:
                return(new string[] {
                    "Resisted!",
                    "",
                    "Some monsters take half damage from certain",
                    "attack types. If a monster resists one of your",
                    "attacks, you can switch to a different",
                    "weapon by pressing [e] to access the",
                    "equipment screen.",
                    "",
                    "For example, skeletons resist several types of",
                    "damage, but are fully vulnerable to maces."
                });

            case TutorialTopic.RangedAttacks:
                return(new string[] {
                    "Ranged attacks",
                    "",
                    "There are some monsters that are best dispatched",
                    "at a safe distance. You can switch to your bow",
                    "by pressing [e] to access the equipment screen.",
                    "",
                    "Once you've readied your bow, press [s] to shoot."
                });

            case TutorialTopic.Feats:
                return(new string[] {
                    "Feats",
                    "",
                    "Feats are special abilities",
                    "you can learn at shrines.",
                    "",
                    "You need to put ALL of the required",
                    "points into a feat before you can",
                    "use it."
                });

            case TutorialTopic.Armor:
                return(new string[] {
                    "Armor",
                    "",
                    "Armor helps you to avoid taking damage from",
                    "attacks, but heavy armor also interferes with",
                    "both stealth and magic spells.",
                    "",
                    "If you don't need stealth or magic, wear",
                    "full plate for the best protection."
                });

            case TutorialTopic.Fire:
                return(new string[] {
                    "You're on fire!",
                    "",
                    "You'll take damage each turn",
                    "until you put it out.",
                    "",
                    "Stand still by pressing [.] and",
                    "you'll try to put out the fire."
                });

            case TutorialTopic.Recovery:
                return(new string[] {
                    "Recovering health",
                    "",
                    "Take advantage of your natural recovery. Your",
                    "health will slowly return until your HP reaches",
                    "a multiple of 10 (so if your health is 74/100,",
                    "it'll go back up to 80/100, and then stop).",
                    "",
                    "If that isn't enough, you can restore more HP by",
                    "resting. Press [r], and if you're undisturbed for",
                    "10 turns, you'll regain half of your missing HP",
                    "(and restore your magic reserves, if applicable).",
                    "",
                    "You can rest only once per dungeon level, but your",
                    "natural recovery always works."
                });

            case TutorialTopic.HealingPool:
                return(new string[] {
                    "Healing pools",
                    "",
                    "Perhaps a relative of wishing wells, healing",
                    "pools are a rare feature of the dungeon that",
                    "can fully restore your health.",
                    "",
                    "To activate a healing pool, drop in an item",
                    "by pressing [d]."
                });

            case TutorialTopic.Consumables:
                return(new string[] {
                    "Using consumable items",
                    "",
                    "Sometimes death is unavoidable.",
                    "",
                    "However, consumable items can",
                    "get you out of some desperate",
                    "situations.",
                    "",
                    "When all hope seems lost, be sure to",
                    "check your inventory."
                });

            default:
                return(new string[0] {
                });
            }
        }