// Update is called once per frame void Update() { if (Time.time > Timer) { int choice = Random.Range(0, 3); switch (choice) { case 0: Ball basic = new BasicBall(basic_ball); balls.Add(basic.Obj, basic); break; case 1: Ball bouncy = new BouncyBall(bouncy_ball); balls.Add(bouncy.Obj, bouncy); break; case 2: Ball explosive = new ExplosiveBall(explosive_ball); balls.Add(explosive.Obj, explosive); break; } Timer = Time.time + Random.Range(2f, 4f); } }
public void SetBall(BallType ballType) { if (ballStore > 0) { pController = GetComponent <PlayerController>(); holdBall = ballFactory.CreateBall(ballType, this, fadeTime); holdBall.transform.SetParent(this.transform); ball = holdBall.GetComponent <BasicBall>(); } }
public void IfIGoUpVeryFastICantGoMoreFarThanTheSpace() { IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(42, 42)); ball.Position = new Vector2(42, 3); ball.Speed = new Vector2(42, -4); ball.Move(); Assert.AreEqual(0, ball.Position.Y); ball.Move(); Assert.AreEqual(ball.Speed.Y, ball.Position.Y); }
public void IfIGoVeryFastToTheLeftICantGoMoreFarThanTheSpace() { int speed = 4; IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(42, 42)); ball.Position = new Vector2(speed - 1, 42); ball.Speed = new Vector2(speed * -1, 42); ball.Move(); Assert.AreEqual(0, ball.Position.X); ball.Move(); Assert.AreEqual(ball.Speed.X, ball.Position.X); }
public void IFindCollisions() { var configuration = new BasicGameConfiguration(0, null); var blocks = new List <IBlock>() { new BasicBlock(configuration, new Size(64, 32)) { Position = new Vector2(5, 5) } }; var ball = new BasicBall(configuration, new Size(5, 5)) { Position = new Vector2(15, 26.15f), Speed = new Vector2(0, -2) }; var board = new Board(blocks, null, new Size(100, 100), ball.Size.Width * ball.Scale.X); var block = board.Collides(ball); }
public void IfIGoVeryFastToTheRightICantGoMoreFarThanTheSpace() { int screenWidth = 800, ballWidth = 21, speed = 4; int roundErrorForBallScaleFloatValue = 1; IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(ballWidth, 42)); ball.Position = new Vector2(screenWidth - ballWidth - speed + 1, 42); ball.Speed = new Vector2(speed, 42); ball.Move(); Assert.AreEqual(screenWidth - ballWidth, ball.Position.X - roundErrorForBallScaleFloatValue); ball.Move(); Assert.AreEqual(ball.Speed.X, (float)Math.Round(screenWidth - ballWidth - ball.Position.X, 2) * -1 - roundErrorForBallScaleFloatValue); }