Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- public Program(String sav)
- {
- this.save = sav;
- }
- public Player p = new Player();
- public String save;
- public void game()
- {
- try{
- string option = mainScreen();
- if (option == "new game")
- {
- Program.Main(null);
- }
- else if (option == "level up")
- {
- if (p.lastLevel > 0)
- {
- levelUp();
- }
- else
- {
- game();
- }
- }
- else if (option == "fight")
- {
- try
- {
- new Fight(this, p, new Monster(p.level));
- }
- catch (Exception e)
- {
- error(this);
- }
- }
- else if (option == "hp potion")
- {
- p.useHp();
- game();
- }
- else if (option.StartsWith("save"))
- {
- try
- {
- string[] split = option.Split(' ');
- if (split.Length > 0)
- {
- FileManager.save(this, split[1], false);
- }
- else
- {
- FileManager.save(this, save, false);
- }
- game();
- }
- catch (Exception e)
- {
- error(this);
- }
- }
- else if (option.StartsWith("load"))
- {
- string[] split = option.Split(' ');
- FileManager.load(split[1]).game();
- }
- else if (option.StartsWith("delete"))
- {
- if (option.StartsWith("delete "))
- {
- string[] split = option.Split(' ');
- FileManager.delete(split[1]);
- if (split[1] == save)
- {
- Program.Main(null);
- }
- else
- {
- game();
- }
- }
- else if (option == "delete")
- {
- {
- FileManager.delete(save);
- Program.Main(null);
- }
- }
- }
- else if(option.StartsWith("rename")) {
- string[] split = option.Split(' ');
- if (split.Length == 2) {
- FileManager.save(this, split[1], false);
- FileManager.delete(save);
- save = split[1];
- game();
- }else if (split.Length == 3) {
- Program p = FileManager.load(split[1]);
- FileManager.save(p, split[2], false);
- FileManager.delete(split[1]);
- game();
- }else{
- game();
- }
- }
- else
- {
- game();
- }
- }catch(Exception e){
- error(this);
- }
- }
- public String mainScreen()
- {
- Console.Clear();
- p.check(this);
- String levelup = "none";
- if (p.lastLevel > 0)
- {
- levelup = p.lastLevel.ToString();
- }
- Console.WriteLine("");
- Console.WriteLine("----Monster-Game---V1----");
- Console.WriteLine("== Save: "+save);
- Console.WriteLine("-------------------------");
- Console.WriteLine("== HEALTH: "+p.hp.ToString()+"/"+p.maxHP);
- Console.WriteLine("== SWORD: "+p.sd.ToString());
- Console.WriteLine("== MAGIC: "+p.md.ToString());
- Console.WriteLine("== BOW: "+p.bd.ToString());
- Console.WriteLine("-------------------------");
- Console.WriteLine("== HP-MULTIPLIER: "+p.hmulti.ToString());
- Console.WriteLine("== DMG-MULTIPLIER: " + p.hmulti.ToString());
- Console.WriteLine("== HP-POTIONS: "+p.hpotions);
- Console.WriteLine("-------------------------");
- Console.WriteLine("== LEVEL: "+p.level.ToString());
- Console.WriteLine("== XP: "+p.xp.ToString());
- Console.WriteLine("== LEVEL UPS: "+levelup.ToString());
- Console.WriteLine("-------------------------");
- Console.WriteLine("-- FIGHT |LEVEL UP --");
- Console.WriteLine("-- NEW GAME|HP POTION --");
- Console.WriteLine("-- SAVE |LOAD --");
- Console.WriteLine("-- DELETE |RENAME --");
- Console.WriteLine("-------------------------");
- Console.WriteLine("");
- String option = Console.ReadLine().ToLower();
- return option;
- }
- public void levelUp()
- {
- Console.Clear();
- Console.WriteLine("");
- Console.WriteLine("----Monster-Game---V1----");
- Console.WriteLine("== Save: " + save);
- Console.WriteLine("-------------------------");
- Console.WriteLine("== LEVEL UPS: " + p.lastLevel);
- Console.WriteLine("-------------------------");
- Console.WriteLine("-- LEVEL UP --");
- Console.WriteLine("-------------------------");
- Console.WriteLine("-- CANCEL --");
- Console.WriteLine("-- SWORD BOW MAGIC HP --");
- Console.WriteLine("-------------------------");
- Console.WriteLine("");
- String option = Console.ReadLine().ToLower();
- if (option == "cancel")
- {
- game();
- }
- else if (option == "sword")
- {
- p.sd = p.sd + 1;
- p.lastLevel = p.lastLevel - 1;
- p.level = p.level + 1;
- }
- else if (option == "bow")
- {
- p.bd = p.bd + 1;
- p.lastLevel = p.lastLevel - 1;
- p.level = p.level + 1;
- }
- else if (option == "magic")
- {
- p.md = p.md + 1;
- p.lastLevel = p.lastLevel - 1;
- p.level = p.level + 1;
- }
- else if (option == "hp")
- {
- p.maxHP = p.maxHP + 1;
- p.hp = p.maxHP;
- p.lastLevel = p.lastLevel - 1;
- p.level = p.level + 1;
- }
- game();
- }
- public void gameover()
- {
- Console.Clear();
- Console.WriteLine("");
- Console.WriteLine("----Monster-Game---V1----");
- Console.WriteLine("== Save: " + save);
- Console.WriteLine("-------------------------");
- Console.WriteLine("-- GAME OVER --");
- Console.WriteLine("-------------------------");
- Console.WriteLine("");
- Console.ReadLine();
- FileManager.delete(save);
- Program.Main(null);
- }
- public static void error(Program pr)
- {
- Console.Clear();
- Console.WriteLine("==ERROR==");
- try
- {
- FileManager.save(pr, pr.save, true);
- }
- catch (Exception e)
- {
- }
- Console.ReadLine();
- if (pr != null)
- {
- pr.game();
- }
- else
- {
- Program.Main(null);
- }
- }
- static void Main(string[] args)
- {
- Console.Clear();
- Console.WriteLine("");
- Console.WriteLine("----Monster-Game---V1----");
- Console.WriteLine("-- START LOAD LIST --");
- Console.WriteLine("-------------------------");
- Console.WriteLine("");
- String option = Console.ReadLine();
- option = option.ToLower();
- if (option.StartsWith("start"))
- {
- try
- {
- string[] split = option.Split(' ');
- Program pg = new Program(split[1]);
- pg.game();
- FileManager.save(pg, pg.save, false);
- }
- catch (Exception e)
- {
- Program.error(null);
- }
- }
- else if (option == "list")
- {
- Console.Clear();
- String op = FileManager.listSaves();
- if (op.StartsWith("load"))
- {
- try
- {
- string[] split = op.Split(' ');
- FileManager.load(split[1]).game();
- }
- catch (Exception e)
- {
- Program.error(null);
- }
- }
- else if (op == "back")
- {
- Program.Main(null);
- }
- else
- {
- Program.Main(null);
- }
- }
- else if (option.StartsWith("load"))
- {
- try
- {
- string[] split = option.Split(' ');
- FileManager.load(split[1]).game();
- }
- catch (Exception e)
- {
- Program.error(null);
- }
- }
- else
- {
- Program.Main(null);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment