public BouncingLogoWithGravity(Content content, Randomizer random, InputCommands inputCommands)
     : base(content, random)
 {
     inputCommands.Add(Key.Space, () => Reset(random));
     inputCommands.Add(MouseButton.Left, mouse => Reset(random));
     inputCommands.Add((Touch touch) => Reset(random));
 }
Exemplo n.º 2
0
		private Vector2D GetInitialVelocity(Randomizer randomizer)
		{
			var randomizedAxisValue = randomizer.Get(.03f, .15f);
			var randomXAimingForCenter = (Center.X > 0.5f) ? -randomizedAxisValue : randomizedAxisValue;
			var randomYAimingForCenter = (Center.Y > 0.5f) ? -randomizedAxisValue : randomizedAxisValue;
			return new Vector2D(randomXAimingForCenter, randomYAimingForCenter);
		}
Exemplo n.º 3
0
 public void SetUp()
 {
     new Level(new Size(5, 5));
     Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.2f, 0.3f }));
     pig = new PiggyBank();
     pig.PerformAttack(AvatarAttack.PiggyBankCoinMinefield, Vector2D.Unused);
     coins = EntitiesRunner.Current.GetEntitiesOfType <Coin>();
 }
Exemplo n.º 4
0
 public Block(BlocksContent content, Randomizer random, Point topLeft)
 {
     this.random = random;
     CreateBricks(content);
     Left = topLeft.X;
     Top = topLeft.Y;
     RenderLayer = (int)Blocks.RenderLayer.Grid;
 }
Exemplo n.º 5
0
 public void ApplyingIceToMeltedIronCreepMightShatter()
 {
     Randomizer.Use(new FixedRandom(new[] { 0.0f }));
     IronCreepStateChanger.ChangeStatesIfIronCreep(TowerType.Ice, creep);
     IronCreepStateChanger.ChangeStatesIfIronCreep(TowerType.Acid, creep);
     IronCreepStateChanger.ChangeStatesIfIronCreep(TowerType.Ice, creep);
     Assert.AreEqual(0, creep.GetStatValue("Hp"));
 }
Exemplo n.º 6
0
 public BouncingLogo(Content content, Randomizer random)
     : base(content.Load<Image>("DeltaEngineLogo"), Rectangle.One, Color.GetRandomColor())
 {
     DrawArea = Rectangle.FromCenter(Point.Half, new Size(random.Get(0.1f, 0.2f)));
     velocity = new Point(random.Get(-0.4f, +0.4f), random.Get(-0.4f, +0.4f));
     Rotation = random.Get(0, 360);
     rotationSpeed = random.Get(-50, 50);
 }
Exemplo n.º 7
0
		private static Rectangle CreateDrawArea(Randomizer randomizer, int sizeModifier)
		{
			var randomPosition =
				new Vector2D(
					randomizer.Get(-100, 100) > 0 ? ScreenSpace.Current.Left - .1f : ScreenSpace.Current.Right,
					randomizer.Get(-100, 100) > 0 ? ScreenSpace.Current.Top - .1f : ScreenSpace.Current.Bottom);
			var modifiedSize = new Size(.1f / sizeModifier);
			return new Rectangle(randomPosition, modifiedSize);
		}
Exemplo n.º 8
0
 public void GetRandomBrightColorUsingFixedRandomValues()
 {
     using (Randomizer.Use(new FixedRandom(new[] { 0.0f, 0.5f })))
     {
         Assert.AreEqual(0, Randomizer.Current.Get(0, 10));
         Assert.AreEqual(5, Randomizer.Current.Get(0, 10));
         Assert.AreEqual(2, Randomizer.Current.Get(2, 4));
     }
 }
Exemplo n.º 9
0
 public void ParticlesTrackingEmitterUpdatingPosition()
 {
     Randomizer.Use(new FixedRandom());
     CreateDataAndEmitter();
     emitterData.DoParticlesTrackEmitter = true;
     AdvanceTimeAndUpdateEntities(0.1f);
     emitter.Position = Vector2D.One;
     AdvanceTimeAndUpdateEntities(0.1f);
     Assert.AreEqual(new Vector3D(0.9f, 0.9f, 0), emitter.particles[0].Position);
 }
Exemplo n.º 10
0
        public void PerformCarpetBombingAttack()
        {
            new Level(new Size(5, 5));
            Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.2f, 0.1f, 0.2f, 0.1f, 0.2f, 0.3f }));
            var missedCreep = new Creep(CreepType.Paper, new Vector2D(4, 4));
            var hitCreep    = new Creep(CreepType.Paper, new Vector2D(0, 1));

            player.Avatar.PerformAttack(AvatarAttack.PenguinCarpetBombing, Vector2D.Unused);
            Assert.AreEqual(1, missedCreep.GetStatPercentage("Hp"));
            Assert.Less(hitCreep.GetStatPercentage("Hp"), 1);
        }
Exemplo n.º 11
0
 public void GetRandomBrightColorUsingFixedRandomValues()
 {
     using (Randomizer.Use(new FixedRandom(new[] { 0.0f, 0.5f, 0.999f })))
     {
         Color color = Color.GetRandomBrightColor();
         Assert.AreEqual(128, color.R);
         Assert.AreEqual(192, color.G);
         Assert.AreEqual(255, color.B);
         Assert.AreEqual(255, color.A);
     }
 }
        public void ParticlesUpdatingPosition()
        {
            Randomizer.Use(new FixedRandom());
            var emitter = new ParticleEmitter(GetEmitterData(logo), Vector3D.Zero);

            AdvanceTimeAndUpdateEntities(0.1f);
            Assert.AreNotEqual(emitter.Position, emitter.particles[0].Position);
            Assert.IsTrue(
                emitter.particles[0].Position.IsNearlyEqual(new Vector3D(-0.03333334f, -0.03333334f,
                                                                         0.0058f)));
        }
Exemplo n.º 13
0
 public void SetUp()
 {
     Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.6f, 0.7f, 0.2f }));
     InitializeMouse();
     AdvanceTimeAndUpdateEntities();
     game1 = new TwoHumanNetworkGame(Messaging.StartSession(Port), BoardTests.Width,
                                     BoardTests.Height);
     Assert.True(game1.IsPauseable);
     game2 = new TwoHumanNetworkGame(Messaging.JoinSession("", Port),
                                     new Board.Data(BoardTests.Width, BoardTests.Height, (game1).Colors));
 }
        public void ParticlesTrackingEmitterUpdatingPosition()
        {
            Randomizer.Use(new FixedRandom());
            var emitterData = GetEmitterData(logo);

            emitterData.DoParticlesTrackEmitter = true;
            var emitter = new ParticleEmitter(emitterData, Vector3D.Zero);

            AdvanceTimeAndUpdateEntities(0.1f);
            emitter.Position = Vector3D.One;
            AdvanceTimeAndUpdateEntities(0.1f);
            Assert.IsTrue(
                emitter.particles[0].Position.IsNearlyEqual(new Vector3D(0.90025f, 0.90025f, 1.0175f)));
        }
Exemplo n.º 15
0
 public Grid(Renderer renderer, BlocksContent content, Randomizer random)
 {
     this.renderer = renderer;
     this.content = content;
     Random = random;
 }
 public void SetUp()
 {
     Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.6f, 0.7f, 0.2f }));
     logic = new SinglePlayerLogic(BoardTests.Width, BoardTests.Height);
 }
 private void Reset(Randomizer random)
 {
     DrawArea = Rectangle.FromCenter(Point.Half, new Size(random.Get(0.1f, 0.2f)));
     velocity = new Point(random.Get(-0.4f, +0.4f), random.Get(-0.4f, +0.4f));
 }
Exemplo n.º 18
0
 public void GetRandomValue()
 {
     Randomizer.Use(new FixedRandom(new[] { 0.4f }));
     Assert.AreEqual(0.24f, valueRange.GetRandomValue(), 0.0001f);
 }
Exemplo n.º 19
0
		public static IDisposable Use(Randomizer randomizer)
		{
			return ThreadStaticRandomizer.Use(randomizer);
		}
Exemplo n.º 20
0
 public TestGrid(Renderer renderer, BlocksContent content, Randomizer random)
     : base(renderer, content, random)
 {
 }
 public BouncingLogoWithFriction(Content content, Randomizer random)
     : base(content, random)
 {
 }
Exemplo n.º 22
0
 public void SetUp()
 {
     Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.6f, 0.7f, 0.2f }));
     board = new Board(Width, Height);
 }