Пример #1
0
        public GameSession()
        {
            #region Initialize Player

            CurrentPlayer = new Player("Scott", "Fighter", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(2001));
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(1));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3002));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3003));

            #endregion Initialize Player

            #region Initialize World

            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);

            #endregion Initialize World
        }
Пример #2
0
        public GameSession()
        {
            // Create message log
            messageLog = new MessageLog();

            // Populate player object
            CurrentPlayer = new Player("Dom", 500, 500, 0, 1, 0);

            // Create new GUI dimensions
            gui = new GUI(100, 30);

            // Create new WorldFactory
            WorldFactory worldFactory = new WorldFactory();

            // Put it into CurrentWorld property
            CurrentWorld    = worldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.GetLocation(0, 0);

            // Create new ActionFactory
            ActionFactory actionFactory = new ActionFactory();

            action       = actionFactory.CreateAction();
            battleAction = actionFactory.CreateBattleAction();


            CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(2001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(2002));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(2003));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(1001));

            CurrentPlayer.CurrentWeapon = CurrentPlayer.Inventory.Where(i => i.Type == Item.ItemType.Weapon).FirstOrDefault();
        }
Пример #3
0
        public GameSessionViewModel(IDialogService dialogService)
        {
            this.dialogService = dialogService;

            CurrentWorld = WorldFactory.CreateWorld();

            // initialise new player
            CurrentPlayer = new Player
            {
                Name             = "Naohtest",
                CharacterClass   = "Mage",
                HitPoints        = 100,
                Gold             = 10,
                ExperiencePoints = 0,
                Level            = 1,
                CurrentLocation  = CurrentWorld.LocationAt(1, -1)
            };

            CurrentPlayer.PlayerMoved += player_PlayerMoved;

            CurrentPlayer.Inventory.Add(ItemFactory.CreateGameItem(1001));
            CurrentPlayer.Inventory.Add(ItemFactory.CreateGameItem(1002));
            CurrentPlayer.Inventory.Add(ItemFactory.CreateGameItem(1003));

            #region Commands
            CommandAddExp       = new RelayCommand(AddExpExecute, AddExpCanExecute);
            CommandMoveNorth    = new RelayCommand(MoveNorthExecute, MoveNorthCanExecute);
            CommandMoveWest     = new RelayCommand(MoveWestExecute, MoveWestCanExecute);
            CommandMoveEast     = new RelayCommand(MoveEastExecute, MoveEastCanExecute);
            CommandMoveSouth    = new RelayCommand(MoveSouthExecute, MoveSouthCanExecute);
            CommandShowInfo     = new RelayCommand(ShowInfoExecute, null);
            CommandShowWorldMap = new RelayCommand(ShowWorldMapExecute, null);
            CommandShowInventar = new RelayCommand(ShowInventarExecute, null);
            #endregion
        }
Пример #4
0
        public void TestEmpty()
        {
            var dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "EmptyDir"));

            if (dir.Exists)
            {
                dir.Delete(true);
            }

            dir.Create();

            var f = new WorldFactory()
            {
                ResourcesDirectory = dir.FullName
            };

            f.Create();

            var v = new WorldValidator();

            v.Validate(f);
            Assert.IsEmpty(v.Errors.ToString());
            Assert.IsEmpty(v.Warnings.ToString());
            Assert.AreEqual(0, v.ErrorCount);
            Assert.AreEqual(0, v.WarningCount);
        }
Пример #5
0
        public GameSession()
        {
            CurrentPlayer = new Player("Chad", "Magic User?", 0, 20, 20, 10, 10, 101);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1005));
            }

            if (!CurrentPlayer.MagicList.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(7001));
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(7002));
            }

            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(8001));

            // Legendary Sword
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(1));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3000));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3002));

            // Prison Key
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(2));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3003));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3004));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3005));

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(-3, 1);
        }
Пример #6
0
        public void TestCustomCSharpAction_InSeperateAssembly()
        {
            var old = Compiler.Instance.TypeFactory;

            try
            {
                // Setup the TypeFactory to use both the main Wanderer assembly and our assembly
                Compiler.Instance.TypeFactory = new TypeCollectionFactory(typeof(Compiler).Assembly, typeof(TestAction).Assembly);

                var blue = Compiler.Instance.Deserializer.Deserialize <ActionBlueprint>(yaml);

                var dir = Path.Combine(TestContext.CurrentContext.TestDirectory, "EmptyFolder");
                Directory.CreateDirectory(dir);

                var wf = new WorldFactory()
                {
                    ResourcesDirectory = dir
                };
                var world = wf.Create();

                var f      = new ActionFactory();
                var action = f.Create(world, world.Player, blue);

                Assert.IsInstanceOf(typeof(TestAction), action);
            }
            finally
            {
                Compiler.Instance.TypeFactory = old;
            }
        }
Пример #7
0
        //-------------------------------------------------------------------------------------------
        public GameSession()
        {
            int dexterity = RandomNumberGenerator.SimpleNumberBetween(3, 40);

            CurrentPlayer = new Player
                            (
                "Player",
                "Paladin",
                15,
                10,
                10,
                20,
                dexterity
                            );

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddWeaponToWeapons(WeaponFactory.CreateWeapon(1001));
            }
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(6001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4000), 4);
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4001), 4);
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4002), 4);
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4003), 4);
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(1));
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(2));

            CurrentWorld    = WorldFactory.CreateWorld(CurrentPlayer.Name);
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
Пример #8
0
        public void TestWorldValidator_DialogueOptionWithNoText()
        {
            var world =
                new WorldFactory {
                ResourcesDirectory = EmptyDir
            }
            .Create();

            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Body       = new List <TextBlock>
                {
                    new TextBlock("I dare say")
                },
                Options = { new DialogueOption() }
            };

            world.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(world, world.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, world.Player.CurrentLocation);

            StringAssert.Contains("A Dialogue Option of Dialogue '1cf15faf-837b-4629-84c5-bdfa7631a905' has no Text", v.Errors.ToString());
        }
Пример #9
0
        public GameSession()
        {
            #region Create player

            var dex = RandomNumberGenerator.NumberBetween(3, 18);
            CurrentPlayer = new Player("Scott", "Fighter", 0, dex, 10, 10, 1000);

            #endregion

            if (CurrentPlayer.Inventory.Weapons.Any() == false)
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(2001));
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(1));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3002));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3003));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(4002));

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
Пример #10
0
        public void TestWorldValidator_DialogueOptionWithMissingDestination()
        {
            var w = new WorldFactory {
                ResourcesDirectory = EmptyDir
            }.Create();
            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Body       = new List <TextBlock>
                {
                    new TextBlock("I dare say")
                },
                Options =
                {
                    new DialogueOption()
                    {
                        Text = "Rather!",

                        //This is missing
                        Destination = new Guid("d7bcff5f-31a4-41ad-a71e-9b51a6565fc3")
                    }
                }
            };

            w.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(w, w.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, w.Player.CurrentLocation);

            StringAssert.Contains("Could not find Dialogue 'd7bcff5f-31a4-41ad-a71e-9b51a6565fc3", v.Errors.ToString());
        }
Пример #11
0
        public void TestWorldValidator_BadYaml()
        {
            var dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "BadYamlDir"));

            if (dir.Exists)
            {
                dir.Delete(true);
            }

            dir.Create();

            var f = new WorldFactory()
            {
                ResourcesDirectory = dir.FullName
            };

            File.WriteAllText(Path.Combine(dir.FullName, "rooms.yaml"), "ffffff");

            var v = new WorldValidator();

            v.Validate(f);
            StringAssert.Contains("Error Creating World", v.Errors.ToString());
            StringAssert.Contains("Error loading RoomBlueprint in file", v.Errors.ToString());
            StringAssert.Contains("rooms.yaml", v.Errors.ToString());


            Assert.IsEmpty(v.Warnings.ToString());
            Assert.AreEqual(1, v.ErrorCount);
            Assert.AreEqual(0, v.WarningCount);
        }
Пример #12
0
        public GameSession()
        {
            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(-1, 0);
            CurrentPlayer   = PlayerFactory.CreatePlayer("Turtle", "Dan");
        }
Пример #13
0
        public void Test_Serialization_OfActor()
        {
            var world1 = new WorldFactory()
            {
                ResourcesDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources")
            }.Create();

            var omg = new Npc("omgz", world1.Player.CurrentLocation);

            omg.BaseBehaviours.Add(new ForbidBehaviour <LeaveAction>(new ConditionCode("return Frame.LeaveDirection == Direction.Down"), omg));

            var behaviour = omg.GetFinalBehaviours().OfType <ForbidBehaviour <LeaveAction> >().Single();

            //we don't forbid going north
            Assert.IsFalse(behaviour.Condition.IsMet(world1, GetArgs(world1.Player, world1, new LeaveFrame(omg, new LeaveAction(omg), Direction.North, 0))));
            //we DO forbid going down
            Assert.IsTrue(behaviour.Condition.IsMet(world1, GetArgs(world1.Player, world1, new LeaveFrame(omg, new LeaveAction(omg), Direction.Down, 0))));

            var config = World.GetJsonSerializerSettings();

            var json = JsonConvert.SerializeObject(omg, config);

            var omg2 = (Actor)JsonConvert.DeserializeObject(json, typeof(Actor), config);

            var behaviour2 = omg2.GetFinalBehaviours().OfType <ForbidBehaviour <LeaveAction> >().Single();

            //we don't forbid going north
            Assert.IsFalse(behaviour2.Condition.IsMet(world1, GetArgs(world1.Player, world1, new LeaveFrame(omg, new LeaveAction(omg), Direction.North, 0))));
            //we DO forbid going down
            Assert.IsTrue(behaviour2.Condition.IsMet(world1, GetArgs(world1.Player, world1, new LeaveFrame(omg, new LeaveAction(omg), Direction.Down, 0))));
        }
Пример #14
0
    void Update()
    {
        if (!worldFactoryScript)
        {
            //Get world factory script
            GameObject worldFactory = null;
            worldFactory = GlobalOptions.GetWorldFactory();
            if (worldFactory)
            {
                worldFactoryScript = worldFactory.GetComponent <WorldFactory>();
            }
        }

        if (!worldFactoryScript)
        {
            return;
        }

        timeleft -= Time.deltaTime;

        // Interval ended - update GUI text and start new interval
        if (timeleft <= 0.0)
        {
            timeleft = updateInterval;
            string format = worldFactoryScript.GetCurrentObstacleSet();
            guiText.text           = format;
            guiText.material.color = Color.blue;
        }
    }
Пример #15
0
        protected You YouInARoom(out IWorld world)
        {
            var room = InARoom(out world);
            var you  = new You("Test Wanderer", room);

            WorldFactory.AddDefaults(world, you);
            return(you);
        }
Пример #16
0
        static async Task Main(string[] args)
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;

                _cts.Cancel();

                Console.WriteLine("Cancellation requested...");
            };

            //Create the random number generator
            var randomNumberGenerator = new RandomNumberGenerator();

            //Create the world factory
            var worldFactory = new WorldFactory(randomNumberGenerator);

            Entity[] survivingEntities = null;

            for (int generationIndex = 0; generationIndex < 100; generationIndex++)
            {
                Console.WriteLine($"=== Generation {generationIndex} ===");

                var parameters = new WorldCreationParameters
                {
                    ExistingEntities = survivingEntities?
                                       .Select(e => e.Metadata)
                                       .ToArray(),
                    NumberOfEntities     = 1000,
                    NumberOfInstructions = 8
                };

                //Create the world
                var world = worldFactory.Create(parameters);

                Console.WriteLine($"World created. Food location: ({world.WorldState.Food.X}, {world.WorldState.Food.Y})");

                if (_cts.IsCancellationRequested)
                {
                    Console.WriteLine("Cancelled.");

                    return;
                }

                survivingEntities = await ExecuteGenerationAsync(world, _cts.Token);

                //Print out the survivors
                if (survivingEntities != null)
                {
                    foreach (var aliveEntity in survivingEntities)
                    {
                        var distance = aliveEntity.StartLocation.GetDistance(aliveEntity.Location);

                        Console.WriteLine($"  Entity traveled {distance:0.00}: Gen [{aliveEntity.Metadata.Generation}]");
                    }
                }
            }
        }
Пример #17
0
 public GameStateManager(OurMarioGame game)
 {
     isBlack          = false;
     state            = new MenuState(this);
     world            = WorldFactory.CreateWorldDeveloper();
     CheatCodeManager = new AllCheatCodesManager(this);
     GameClass        = game;
     Totaltimer       = Util.Instance.TotalTimer;
 }
Пример #18
0
        /// <summary>
        /// Default constructor for a GameSession object.
        /// </summary>
        public GameSession()
        {
            // Create the world
            CurrentWorld = WorldFactory.CreateWorld();

            CurrentPlayer = new Player();

            CurrentLocation = CurrentWorld.GetLocation(0, 0);
        }
Пример #19
0
        public void TestYaml_ActorFiles()
        {
            var f = new WorldFactory()
            {
                ResourcesDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources")
            };

            f.Create();
        }
Пример #20
0
        public GameSession()
        {
            this.worldFactory = new WorldFactory();

            this.CurrentPlayer = new Player("Kristiyan The Great",
                                            "Magician", 25, 10, 1, 1500);
            this.CurrentWorld    = worldFactory.CreateWorld();
            this.CurrentLocation = this.CurrentWorld.LocationAt(0, 0);
        }
Пример #21
0
        //public EventNode FailureNode;
        public void Show(Size size)
        {
            WorldFactory worldFactory = new WorldFactory(this.randomGenerator);

            this.worldLoader = worldFactory.Build(this.difficulty, size);
            LevelPlayer levelPlayer = this.player.PrepareForNewLevel();

            this.worldLoader.addItemAndDisableUnloading(levelPlayer);
            this.screen = new WorldScreen(size, levelPlayer, this.worldLoader);
        }
Пример #22
0
        public void CreateWorldInvalid()
        {
            Mock <IExecutableContext> execContextMock = new Mock <IExecutableContext>();
            ConfigManager             config          = new ConfigManager();

            config.Init(".\\TestConfig");
            execContextMock.Setup(f => f.ConfigManager).Returns(config);

            WorldFactory.CreateWorld("FakeName", execContextMock.Object);
        }
Пример #23
0
        public GameSession()
        {
            CurrentPlayer = new Player {
                Name = "Melvin", CharacterClass = "Knight", ExperiencePoints = 0, Gold = 0, HitPoints = 100, Level = 0
            };

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
Пример #24
0
        public GameSession()
        {
            curPlayer = new Player {
                PlayerName = "Jerry", Gold = 100500, CharacterClass = "Hunter",
                HitPoints  = 10, ExperiencePoints = 0, Level = 1
            };

            curWorld = WorldFactory.CreateWorld();

            curLocation = curWorld.LocationAt(0, -1);
        }
Пример #25
0
        static void Main(string[] args)
        {
            var worldFactory = new WorldFactory();

            Application.Init();

            var ui = new MainWindow(worldFactory);

            Application.Top.Add(ui);
            Application.Run();
        }
Пример #26
0
        public void WorldLoadedEvent()
        {
            World world = WorldFactory.Create();

            world.LoadedEvent += new LoadedEventHandler <LoadedEventArgs <IWorld> >(DetectWorldEvent);
            world.Load();
            bool found = worldLoadedDetected;

            worldLoadedDetected = false;
            Assert.AreEqual(true, found);
        }
Пример #27
0
        public GameSession()
        {
            //---Player Info---
            CurrentPlayer = new Player {
                Name = "Patrick", CharacterClass = "Fighter", HitPoints = 10, Gold = 100, ExperiencePoints = 0, Level = 1
            };

            //---Location Info---
            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
Пример #28
0
        public GameSession(string characterName)
        {
            CurrentPlayer = new Player(characterName, "Hardcoded", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld    = WorldFactory.CreateWorld();    // Stvori world
            CurrentLocation = CurrentWorld.LocationAt(0, 0); // Trenutna lokacija
        }
Пример #29
0
        public GameSession()
        {
            CurrentPlayer = new Player("Vincent", "Azure Administrator", 0, 10, 10, 0, 0);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
Пример #30
0
        public GameSession()
        {
            CurrentPlayer = new Player("Auston", "Fighter", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
Пример #31
0
 public Client( WorldFactory factory )
 {
     _character = factory.CreateCharacter();
     _monster = factory.CreateMonster();
 }