Beispiel #1
0
        public void Initialize()
        {
            FarseerPhysics.Settings.ContinuousPhysics = true;
            FarseerPhysics.Settings.AllowSleep        = true;

            ItemFactory.Initialize();

            World     = new World(Vector2.Zero);
            Map       = Map.Current = new Map(Settings.MAP_WIDTH, Settings.MAP_HEIGHT, Vector2.Zero);
            Map.World = World;

            GameObjects.Initialize(Map);

            Map.Generate();

            Player.Current = new Player(Map.RandomHollowCell().Position);
            GameObjects.Add(Player.Current, true);

            Camera.Main        = new Camera(ProjectPivot.Current.GraphicsDevice.Viewport, Player.Current.Position);
            Camera.Main.Target = Player.Current;
            GameObjects.Add(Camera.Main, true);

            Weapons.Initialize();
            Player.Current.TakeWeapon(Weapons.Build("sniper_rifle"));
            GameObjects.Add(Player.Current.Weapon, true);

            Item rock = ItemFactory.Build("rock", Player.Current.Position + new Vector2(40, 50));

            GameObjects.Add(rock);

            Initialized = true;
        }
Beispiel #2
0
        public void BuildOre()
        {
            var itemFactory = new ItemFactory(new IdResolutionContext(new[] { new ItemInfo(ItemCode.Veldnium) }));
            var ore = itemFactory.Build(ItemCode.Veldnium, 10);

            Assert.That(ore.ItemInfo.Code, Is.EqualTo(ItemCode.Veldnium));
            Assert.That(ore.Quantity, Is.EqualTo(10));
        }
        public void ConfigureModifier_Configures_Correctly_For_Fully_Qualified_Pattern_Stats()
        {
            //assemble
            var factory = new ItemFactory();

            factory.ConfigureModifier(2, "stats", "constitution");

            //act
            var result = factory.Build("test-name");

            //assert
            Assert.IsNotNull(result);
        }
        public void ConfigureModifier_Doesnt_Apply_For_Incorrect_Qualified_Pattern()
        {
            //assemble
            var factory = new ItemFactory();

            factory.ConfigureModifier(2, "incorrect", "path");

            //act
            var result = factory.Build("test-name");

            //assert
            Assert.IsNull(result);
        }
        public void ConfigureModifier_Doesnt_Apply_For_Empty_String_Params()
        {
            //assemble
            var factory = new ItemFactory();

            factory.ConfigureModifier(1, string.Empty);

            //act
            var result = factory.Build("test-name");

            //assert
            Assert.IsNull(result);
        }
        public void Build_Returns_Null_For_Empty_Name()
        {
            //assemble
            var factory = new ItemFactory();

            factory.ConfigureModifier(new TestModifier());

            //act
            var result = factory.Build("");

            //assert
            Assert.IsNull(result);
        }
Beispiel #7
0
        public void BuildWeapon()
        {
            var itemFactory = new ItemFactory(new IdResolutionContext(new[] { TestItems.Item(ItemCode.MissileLauncher), TestItems.Weapon(ItemCode.MissileLauncher) }));
            var weaponPacker = new WeaponPacker(new IdGenerator(), itemFactory);
            var itemPacker = new ItemPacker(new[] { weaponPacker });

            var weaponInBox = itemFactory.Build(ItemCode.MissileLauncher, 10);
            var weapon = itemPacker.Unpack<Weapon>(weaponInBox);

            Assert.That(weapon, Is.Not.Null);
            Assert.That(weapon.WeaponInfo.Code, Is.EqualTo(ItemCode.MissileLauncher));
            Assert.That(weapon.Id, Is.Not.EqualTo(0));
            Assert.That(weaponInBox.Quantity, Is.EqualTo(9));
        }
Beispiel #8
0
        public Cell GenerateCellAt(int x, int y)
        {
            int  health = (int)CellHealthFromNoise(x, y);
            Cell c      = cells[new Point(x, y)] = new Cell(x, y, 32, 32, health, offset);

            c.Initialize();
            if (!c.IsHealthy)
            {
                HollowCells.Add(c);
                if (health < 30 && health > 20)
                {
                    GameObjects.Add(ItemFactory.Build("grass", c.Position));
                }
            }
            return(c);
        }