コード例 #1
0
ファイル: Spawner.cs プロジェクト: CamDHall/HammerGame
    // 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);
        }
    }
コード例 #2
0
 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>();
     }
 }
コード例 #3
0
ファイル: BallTest.cs プロジェクト: anarcode/anarkanoid
        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);
        }
コード例 #4
0
ファイル: BallTest.cs プロジェクト: anarcode/anarkanoid
        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);
        }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: BallTest.cs プロジェクト: anarcode/anarkanoid
        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);
        }