示例#1
0
        public bool TrySpawnBall(Index2D slot = null, Color32?color = null)
        {
            if (slot == null)
            {
                if (!TryGetRandomAvailableSlot(Board, out slot))
                {
                    return(false);
                }
            }

            if (!Board.TryGetTile(slot, out var tile))
            {
                return(false);
            }

            color ??= BallColorPool.GetRandomColor();

            var ballStyle    = ballStyleRepository.ObtainDefault();
            var tilePosition = tile.transform.position;
            var ballPosition = new Vector3(
                tilePosition.x,
                (Board.TileStyle.Size + ballStyle.UniformScale) * 0.5f,
                tilePosition.z
                );
            var ball = ballFactory.Create(ballPosition, color.Value, ballStyle);

            ball.name = "Ball_" + slot.ColumnIndex + "_" + slot.RowIndex;
            ball.AddComponent <Rigidbody>();

            return(Board.TrySpawnBall(ball, slot));
        }
示例#2
0
        public void Create_sets_position()
        {
            var ballFactory = new BallFactory();
            var ball        = ballFactory.Create(new Point(16, 72));

            Assert.That(ball.Position, Is.EqualTo(new Point(16, 72)));
        }
示例#3
0
        public BallComponent SpawnOnStart(Action fellAction, Action pitPassedAction)
        {
            var ball = _factory.Create(_gameParams.BallPrefab);

            ball.FellInPitAction    = fellAction;
            ball.PitPassedAction    = pitPassedAction;
            ball.transform.position = _gameParams.BallStartPosition;
            return(ball);
        }
示例#4
0
    private IEnumerator WaitThenResetLevers()
    {
        yield return(new WaitForSeconds(DropDelay));

        BallFactory.Create();

        foreach (var leverLiftController in LeverLiftControllers)
        {
            leverLiftController.Ready();
        }

        EventHub.Instance.BallSpawned();
    }
示例#5
0
        public void SpawnBalls()
        {
            int trajectoryCount = m_TrajectorySource.GetTrajectoryCount();

            float x = m_BallSpawnSettings.InitSpawnPosition.x;
            float y = m_BallSpawnSettings.InitSpawnPosition.y;
            float z = m_BallSpawnSettings.InitSpawnPosition.z;

            Vector3 newballPosition = new Vector3(x, y, z);

            for (int i = 0; i < trajectoryCount; i++)
            {
                IBallFacade ball = BallFactory.Create(i);
                //ball.Transform.position = newballPosition;
                ball.Transform.rotation = Quaternion.identity;
                m_SceneManager.AddNewBall(ball);

                x += m_BallSpawnSettings.DistanceBetweenBalls;
                newballPosition = new Vector3(x, y, z);
            }
        }
示例#6
0
 public void Create_sets_position()
 {
     var ballFactory = new BallFactory();
     var ball = ballFactory.Create(new Point(16, 72));
     Assert.That(ball.Position, Is.EqualTo(new Point(16, 72)));
 }