コード例 #1
0
ファイル: Map.cs プロジェクト: KyraWooders/InventorySystem
 public void Load(string path)
 {
     if (File.Exists(path))
     {
         //create a reader for the file at our path
         StreamReader reader = File.OpenText(path);
         //write to it the same way we read from the console
         CurrentSceneID = Convert.ToInt32(reader.ReadLine());
         int        partySize       = Convert.ToInt32(reader.ReadLine());
         Creature[] loadedCreatures = new Creature[partySize];
         for (int i = 0; i < partySize; i++)
         {
             Character loadedCharacter;
             string    name = reader.ReadLine();
             string    job  = reader.ReadLine();
             if (job == "Knight")
             {
                 loadedCharacter = new Knight(name);
             }
             else if (job == "Rouge")
             {
                 loadedCharacter = new Rouge(name);
             }
             else if (job == "Mage")
             {
                 loadedCharacter = new Mage(name);
             }
             else
             {
                 loadedCharacter = new Character(name);
             }
             int level = Convert.ToInt32(reader.ReadLine());
             int xp    = Convert.ToInt32(reader.ReadLine());
             loadedCharacter.Load(level, xp);
             loadedCreatures[i] = loadedCharacter;
             loadedCharacter.Print();
         }
         //close read
         reader.Close();
     }
     else
     {
         Console.WriteLine("save file can't be found");
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Monster   UwU    = new Monster("UwU", 10, 4);
            Monster   OwO    = new Monster("0w0", 10, 4);
            Monster   VwU    = new Monster("VwU", 5, 6);
            Monster   YwU    = new Monster("YwU", 5, 6);
            Character myself = new Mage("Me ");

            Entity_303[] myTeam = { myself };
            Entity_303[] UwO    = { UwU, OwO };
            Entity_303[] VwY    = { VwU, YwU };
            Entity_303[] empty  = { };

            //0: Courtyard
            //1: Cast;e Gate
            //2: GraveYard
            //3: Village
            //                                           N, S, E, W

            scene courtyard  = new scene("Ze Courtyard", 1, 3, -1, 2, empty, "Ze courtyard is a wide and open to the sky. With a \nsmall garden nearby. There are exits to the north, south, east, and west");
            scene castleGate = new scene("Castle Gate", -1, 0, -1, -1, UwO, "There is a massive gate at the entrance to the \ncastle. It appers to be locked. There is an exit to the south");
            scene graveyard  = new scene("Graveyard", -1, -1, 0, -1, VwY, "The graveyard is pretty spooky. Nonetheless, you pay respects. There is an exit to the east.");
            scene village    = new scene("Village", 0, -1, -1, -1, empty, "This is the village. There are abunch of buildings, I guess. There is an exit to the west.");


            scene[] scenes = { courtyard, castleGate, graveyard, village };
            Map     map    = new Map(0, scenes, myTeam);

            // map.PrintCurrentScene();
            //map.CurrentSceneID = 1;
            //map.PrintCurrentScene();
            //map.CurrentSceneID = 2;
            //map.PrintCurrentScene();
            //map.CurrentSceneID = 3;
            //map.PrintCurrentScene();
            //map.CurrentSceneID = 4;
            //map.PrintCurrentScene();

            map.Menu();

            Console.ReadKey();
            return;



            myself.OpenInventory();

            Encounter encounter = new Encounter(UwO, VwY);

            encounter.Print();
            encounter.Start();


            Console.ReadKey();
            return;


            //Inventory inventory = new Inventory();
            //inventory.Menu();
            string name   = "";
            string choice = "";

            while (choice != "1" && choice != "2")
            {
                Console.WriteLine("Enter name of party member 1:");
                name = Console.ReadLine();
                //display menu]
                Console.WriteLine("\nChoose a job");
                Console.WriteLine("1: Mage");
                Console.WriteLine("2: Rogue");
                choice = Console.ReadLine();
            }
            Character player;

            if (choice == "1")
            {
                player = new Mage(name);
            }
            else if (choice == "2")
            {
                player = new Rogue(name);
            }
            else
            {
                player = new Character(name);
            }
            player.Print();

            player.OpenInventory();

            Rogue Leo   = new Rogue("Leo");
            Mage  Ryobi = new Mage("Ryobi");

            Leo.Print();
            Console.WriteLine("");
            Ryobi.Print();
            Console.WriteLine("");

            choice = "";
            while (choice != "0")
            {
                //display menu]
                Console.WriteLine("\nWhose inventory");
                Console.WriteLine("0: Exit");
                Console.WriteLine("1: " + player.Name());
                Console.WriteLine("2: " + Leo.Name());
                Console.WriteLine("3: " + Ryobi.Name());
                choice = Console.ReadLine();
                if (choice == "1")
                {
                    Console.WriteLine(player.Name());
                    player.OpenInventory();
                }
                else if (choice == "2")
                {
                    Console.WriteLine(Leo.Name());
                    Leo.Print();
                    Leo.OpenInventory();
                }
                else if (choice == "3")
                {
                    Console.WriteLine(Ryobi.Name());
                    Ryobi.Print();
                    Ryobi.OpenInventory();
                }
            }
            player.Experience = 30;
            player.Experience = player.Experience + 50;
            player.Experience++;
            player.Experience += 40;
            player.Experience += 40;
            player.Experience += 100;
            player.Experience += 100;

            int[] testArry = new int[4];

            testArry[0] = 1;
            testArry[1] = 3;
            testArry[2] = 5;
            testArry[3] = 7;

            int[] testArray2 = { 2, 3, 6, 8 };

            string[] stringArry = new string[3];

            Character[] party = { player, Leo, Ryobi, new Character("Like") };



            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Creature Orge = new Monster("Sherk", 100, 20, 20);

            Console.WriteLine("Health: " + Orge.Health);

            Spellbook spellbook = new Spellbook(2);

            spellbook.Page1(Orge);
            Console.WriteLine("Health: " + Orge.Health);
            spellbook.Page2(Orge);
            Console.WriteLine("Health: " + Orge.Health);
            //create a method and assign it to Page1
            void Flame(Creature target)
            {
                target.Health -= 25;
            }

            void Heal(Creature target)
            {
                target.Health += 25;
            }

            spellbook.Page1 = Flame;
            spellbook.Page2 = Heal;
            spellbook.Page1(Orge);
            Console.WriteLine("Health: " + Orge.Health);
            spellbook.Page2(Orge);
            Console.WriteLine("Health: " + Orge.Health);

            spellbook.book[0] = Flame;
            spellbook.book[1] = Heal;
            spellbook.book[0](Orge);
            Console.WriteLine("Health: " + Orge.Health);


            Console.ReadKey();
            return;

            //create a bunch of monsters
            Creature rge    = new Monster("Sherk", 100, 20, 20);
            Creature Donkey = new Monster("Donkey!!!", 100, 20, 30);
            Creature Porge  = new Monster("Fiona", 100, 30, 10);
            Creature PC     = new Monster("Prince Charming", 100, 2, 30);
            Creature Gin    = new Monster("Gingy", 100, 5, 60);
            Creature Puss   = new Monster("Puss in Boots", 100, 70, 40);
            Creature Fairy  = new Monster("Fairy Godmother", 100, 90, 100);
            Creature Pin    = new Monster("Pinocchio", 100, 30, 20);


            string name = "";

            Console.WriteLine("Enter name of party member 1:");
            name = Console.ReadLine();
            string choice = "";

            while (choice != "1" && choice != "2")
            {
                //display menu
                Console.WriteLine("\nChoose a job:");
                Console.WriteLine("1: Knight");
                Console.WriteLine("2: Rouge");
                Console.WriteLine("3: Mage");
                choice = Console.ReadLine();
            }
            Character player;

            if (choice == "1")
            {
                player = new Knight(name);
            }
            else if (choice == "2")
            {
                player = new Rouge(name);
            }
            else if (choice == "3")
            {
                player = new Mage(name);
            }
            else
            {
                player = new Character(name);
            }
            //create two arrays and place the monsters into them
            Creature[] goodTeam  = { player, Orge, Porge };
            Creature[] badTeam   = { Donkey, PC };
            Creature[] babeTeam  = { Gin, Puss };
            Creature[] queenTeam = { Fairy, Pin };
            Creature[] empty     = { };

            Scene courtyard  = new Scene("Courtyard", 1, 3, -1, 2, empty, "You're in the courtyard. There's a Graveyard to the North, the Castle Gate in the South, and a village in the West.");
            Scene graveyard  = new Scene("Graveyard", -1, 0, -1, -1, badTeam, "You're in the spooky Graveyard. There's a Courtyard to the South.");
            Scene village    = new Scene("Village", -1, -1, 0, -1, babeTeam, "You're in a nice small village. There's a Courtyard to the East.");
            Scene castlegate = new Scene("Castlegate", 0, -1, -1, -1, queenTeam, "You're at the Castle Gate. The evil queen lives in there. There's a Courtyard to the North.");


            Scene[] scenes = { courtyard, graveyard, village, castlegate };
            Map     map    = new Map(0, scenes, goodTeam);

            map.Menu();

            Console.ReadKey();



            //create an encounter from the two arrays of monsters
            Encounter encounter = new Encounter(goodTeam, badTeam);

            encounter.Print();
            player.OpenInventory();

            encounter.Start();
            Console.ReadKey();



            return;


            //string name = "";
            //string choice = "";
            //Console.WriteLine("Enter name of party member 1:");
            //name = Console.ReadLine();
            //while (choice != "1" && choice != "2")
            //{

            //    //display menu
            //    Console.WriteLine("/nChoose a job:");
            //    Console.WriteLine("1: Knight");
            //    Console.WriteLine("2: Rouge");
            //    choice = Console.ReadLine();
            //}
            //Character play;
            //if (choice == "1")
            //{
            //    player = new Knight(name);
            //}
            //else if (choice == "2")
            //{
            //    player = new Rouge(name);
            //}
            //else
            //{
            //    player = new Character(name);
            //}
            player.Print();
            player.OpenInventory();
            Character UwU = new Rouge("UwU");
            Character TwT = new Mage("TwT");
            Character OmO = new Knight("OmO");

            TwT.Print();
            UwU.Print();

            while (choice != "0")
            {
                //display menu
                Console.WriteLine("/nWhoose inventorey?");
                Console.WriteLine("0: Exit");
                Console.WriteLine("1: " + player.GetName());
                Console.WriteLine("2: " + TwT.GetName());
                Console.WriteLine("3: " + UwU.GetName());

                choice = Console.ReadLine();

                if (choice == "1")
                {
                    Console.WriteLine(player.GetName());
                    player.Print();
                }
                else if (choice == "2")
                {
                    Console.WriteLine(TwT.GetName());
                    TwT.Print();
                }
                else if (choice == "3")
                {
                    Console.WriteLine(UwU.GetName());
                    UwU.Print();
                }

                int[] testArray = new int[4];

                testArray[0] = 1;
                testArray[1] = 3;
                testArray[2] = 5;
                testArray[3] = 7;

                int[] testArray2 = { 2, 4, 6, 8 };

                string[] stringArray = new string[3];

                Character[] party = { player, UwU, TwT, new Character("OmO") };


                Console.ReadKey();
            }
        }