예제 #1
0
        public static void PreBattleRoll(Roller roller, PlayerCharacter player, Monster monster, out Character attacker, out Character defender)
        {
            player.Roll  = roller.GetRandomNumber(1, 100);
            monster.Roll = roller.GetRandomNumber(1, 100);

            if (player.Roll > monster.Roll)
            {
                attacker = player;
                defender = monster;
                Console.WriteLine("Player wins the toss and is the Attacker");
                Console.WriteLine("player health   " + player.CurrentHitPoints);
                Console.WriteLine("monster health   " + defender.CurrentHitPoints);
            }
            else
            {
                attacker = monster;
                defender = player;
                Console.WriteLine("Monster wins the toss and is the Attacker");
                Console.WriteLine("player health   " + player.CurrentHitPoints);
                Console.WriteLine("Monster health   " + attacker.CurrentHitPoints);
                Console.WriteLine("");
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            // Fighting things Creation

            var fight = new Fight();
            var playerAttackCalculator = new PlayerAttackCalculator();
            var roller = new Roller();

            // Player Creation

            var player = new PlayerCharacter();

            player.Name             = "Player01";
            player.CurrentHitPoints = 100;
            player.TotalHitPoints   = 100;
            player.WeaponSkill      = 1;

            var stats           = new PlayerStats();
            var playerCreater   = new PlayerCreator();
            var playerInventory = new Inventory();
            var diamondDrive    = new DiamondDrive();


            // Story Creation

            var story = new Story();



            // Factory Creation

            var monsterMaker = new MonsterMaker();
            var weaponMaker  = new WeaponMaker();



            // Solar System Creation

            var alpha = new SolarSystem("Alpha", "Universe");
            ////alpha.Name = "Alpha";
            ////alpha.Location = "Universe";

            // not a constructor but initialization syntax
            var beta = new SolarSystem
            {
                Name     = "Beta",
                Location = "Universe",
            };
            ////alpha.Name = "Beta";
            ////alpha.Location = "Universe";

            var gamma = new SolarSystem();

            alpha.Name     = "Gamma";
            alpha.Location = "Universe";



            // JumpGate Creation

            var jumpGateAlpha = new JumpGate();

            jumpGateAlpha.Name     = "Jump Gate Alpha";
            jumpGateAlpha.Location = "Alpha";

            var jumpGateBeta = new JumpGate();

            jumpGateAlpha.Name     = "Jump Gate Beta";
            jumpGateAlpha.Location = "Beta";

            var jumpGateGamma = new JumpGate();

            jumpGateAlpha.Name     = "Jump Gate Gamma";
            jumpGateAlpha.Location = "Gamma";



            // Planet Creation

            var brettopia = new Planet();

            brettopia.Name     = "Brettopia";
            brettopia.Location = "Alpha";

            var kathaven = new Planet();

            brettopia.Name     = "Kathaven";
            brettopia.Location = "Alpha";

            var libraria = new Planet();

            brettopia.Name     = "Libraria";
            brettopia.Location = "Alpha";


            // SpacePort creation

            var spacePortBrettopia = new SpacePort();

            spacePortBrettopia.Name     = "Space Port Brettopia";
            spacePortBrettopia.Location = "Brettopia";

            var spacePortKathaven = new SpacePort();

            spacePortBrettopia.Name     = "Space Port Kathaven";
            spacePortBrettopia.Location = "Brettopia";

            var spacePortLibraria = new SpacePort();

            spacePortBrettopia.Name     = "Space Port Libraria";
            spacePortBrettopia.Location = "Brettopia";



            // Instance Creation



            // Travel/Map Creation

            var travel         = new Travel();
            var universeMap    = new UniverseMap();
            var playerMap      = new PlayerMap();
            var optionSelector = new OptionSelector();

            // Alpha Maps
            var alphaMap = new Map();

            alphaMap.Name = "Alpha";               // this is the null exception right here
            alphaMap.SolarSystem.Add(alpha);       // this probably, name should be fine.  Did you new up a list before adding a solarsystem?
            alphaMap.JumpGates.Add(jumpGateAlpha); // shit that is probably it.  Forgot I had to new up those damn lists
            alphaMap.Planets.Add(brettopia);       // as a matter of practice I generally just new up a list whenever I make the property.  There is very rarely ever a good reason to have a null list.  A collection is generally empty or not.  I wish they built it into the language actually.
            alphaMap.Planets.Add(kathaven);
            alphaMap.Planets.Add(libraria);
            alphaMap.SpacePorts.Add(spacePortBrettopia);
            alphaMap.SpacePorts.Add(spacePortKathaven);
            alphaMap.SpacePorts.Add(spacePortLibraria);



            // Beta Maps
            var betaMap = new Map();

            betaMap.Name = "Beta";
            betaMap.SolarSystem.Add(beta);
            betaMap.JumpGates.Add(jumpGateBeta);

            // Gamma Maps
            var gammaMap = new Map();

            gammaMap.Name = "Gamma";
            gammaMap.SolarSystem.Add(gamma);
            gammaMap.JumpGates.Add(jumpGateGamma);

            // Universe Map filled out
            universeMap.UniverseMaps.Add(alphaMap);
            universeMap.UniverseMaps.Add(betaMap);
            universeMap.UniverseMaps.Add(gammaMap);

            var selector      = new OptionSelector();
            var selectedMapId = selector.GetOption <Map>(universeMap.UniverseMaps);



            // Monster Creation

            var whiteMonster01 = monsterMaker.CreateWhiteMonster(player);
            var whiteMonster02 = monsterMaker.CreateWhiteMonster(player);
            var whiteMonster03 = monsterMaker.CreateWhiteMonster(player);
            var greenMonster01 = monsterMaker.CreateGreenMonster(player);
            var greenMonster02 = monsterMaker.CreateGreenMonster(player);
            var greenMonster03 = monsterMaker.CreateGreenMonster(player);
            var redMonster01   = monsterMaker.CreateRedMonster(player);
            var redMonster02   = monsterMaker.CreateRedMonster(player);
            var redMonster03   = monsterMaker.CreateRedMonster(player);


            whiteMonster01.Attack = 10;


            // This is the Quality Assurance section for temporary testing

            //Console.WriteLine("monster health" + whiteMonster01.CurrentHitPoints);
            //Console.WriteLine("monster attack" + whiteMonster01.Attack);
            //Console.ReadLine();
            //stats.PrintPlayerStats(player);
            //Console.WriteLine(roller.GetRandomNumber(1, 100));
            //Console.WriteLine(whiteMonster01.CurrentHitPoints);
            //fight.DoFight(player, whiteMonster01, stats);
            //weaponMaker.CreateWeaponBlaster(playerInventory);
            //weaponMaker.CreateWeaponDoubleBlaster(playerInventory);
            //weaponMaker.CreateWeaponPhotonSword(playerInventory);
            //fight.DoFight(player, whiteMonster01, stats, playerInventory);
            //playerInventory.WeaponEnumerator();

            universeMap.EnumerateJumpGates();
            //spacePortBrettopia.SpacePortOptions(player, brettopia, travel, alpha, spacePortBrettopia);



            //Player creation part.
            playerCreater.CreatePlayer(player, stats);



            // The story begins
            story.TheBegining01(player, playerInventory, weaponMaker, playerMap, alphaMap, travel, spacePortBrettopia, alpha, brettopia, jumpGateAlpha);


            Console.WriteLine("Time for your first battle! \n");
            fight.DoFight(player, whiteMonster01, stats, playerInventory);
        }
예제 #3
0
        public void DoFight(PlayerCharacter player, Monster whiteMonster, PlayerStats stats, Inventory playerInventory)
        {
            var       roller    = new Roller();
            var       monster   = whiteMonster;
            var       fightOver = false;
            Character winner    = player;
            Character looser    = player;



            PreBattleRoll(roller, player, monster, out Character attacker, out Character defender);


            while (fightOver == false)
            {
                // Select Weapon
                ChooseWeaponToAttackWith(attacker, player, playerInventory);


                // Rolling
                attacker.Roll = roller.GetRandomNumber(1, 12);
                Console.WriteLine("attacker's roll " + attacker.Roll + "\n");

                // Calculate Damage
                var damage = (attacker.Roll / 10) * attacker.Attack;
                Console.WriteLine("Damage " + (damage) + "\n");

                // Apply damage to defender
                defender.CurrentHitPoints = defender.CurrentHitPoints - damage;
                Console.WriteLine("Defender's HP  " + defender.CurrentHitPoints + "\n");
                Console.ReadLine();

                // End fight and declare winner or switch roles
                if (defender.CurrentHitPoints <= 0)
                {
                    // End the fight
                    fightOver = true;
                    winner    = attacker;
                    looser    = defender;
                }
                else
                {
                    // Switch roles
                    var temporaryCharacter = attacker;
                    attacker = defender;
                    defender = temporaryCharacter;

                    Console.WriteLine("the Attacker is now " + attacker.Name + "\n");
                }
            }

            // Post battle stuff.
            if (winner.Name == player.Name)
            {
                player                  = (PlayerCharacter)winner;
                player.Experience      += looser.TotalHitPoints;
                player.CurrentHitPoints = player.TotalHitPoints;


                Console.WriteLine("YOU ARE A WINNER");
                Console.WriteLine("You received " + looser.TotalHitPoints + " Experience Points.");
                stats.PrintPlayerStats(player);
            }
            else
            {
                player = (PlayerCharacter)looser;



                Console.WriteLine("YOU ARE A LOOSER!");
            }
        }