Exemplo n.º 1
0
        void updateDirAndTimeByEdge(FP _percent, tableEdge _tbe, BallObj ball, FP _deltaTime)
        {
            ball.UpdateBallPos(_deltaTime * _percent);                                                                       //先更新到撞击点
            var curReflcDir = Detection.CheckCircle_LineCollision(_tbe, ball.GetPos(), ball.GetRadius(), ball.GetMoveDir()); //计算碰撞响应

            ball.UpdateMoveDir(curReflcDir);                                                                                 //更新实时方向
        }
Exemplo n.º 2
0
 public void Init(BallObj _runballObj, BallObj _staticballObj, FP _t_percent)
 {
     runballObj    = _runballObj;
     staticballObj = _staticballObj;
     t_percent     = _t_percent;
     hitType       = HitType.Ball;
 }
Exemplo n.º 3
0
        void _updateDirAndTimeByEdge(FP _percent, TSVector2 hitNormal, BallObj ball, FP _deltaTime)
        {
            ball.UpdateBallPos(_deltaTime * _percent);                                           //先更新到撞击点
            var curReflcDir = Detection.CheckCircle_EdgeCollision(hitNormal, ball.GetMoveDir()); //计算碰撞响应

            ball.UpdateMoveDir(curReflcDir);                                                     //更新实时方向
        }
Exemplo n.º 4
0
 public fastHitBall(BallObj _runballObj, BallObj _staticballObj, FP _t_percent)
 {
     runballObj    = _runballObj;
     staticballObj = _staticballObj;
     t_percent     = _t_percent;
     hitType       = HitType.Ball;
 }
Exemplo n.º 5
0
 public fastEdge(BallObj _ball, tableEdge _tbe, FP _t_percent)
 {
     ball      = _ball;
     tbe       = _tbe;
     t_percent = _t_percent;
     deltaTime = ball.deltaTime;
     hitType   = HitType.Edge;
 }
Exemplo n.º 6
0
 public void Init(BallObj _ball, tableEdge _tbe, FP _t_percent, TSVector2 _hitNormal)
 {
     ball      = _ball;
     tbe       = _tbe;
     t_percent = _t_percent;
     deltaTime = ball.deltaTime;
     hitType   = HitType.Edge;
     hitNormal = _hitNormal;
 }
Exemplo n.º 7
0
 public BallObj(BallObj other)
 {
     ID        = other.ID;
     cur_pos   = other.cur_pos;
     pre_pos   = other.pre_pos;
     radius    = other.radius;
     moveDir   = other.moveDir;
     moveSpeed = other.moveSpeed;
 }
Exemplo n.º 8
0
        void updateDirAndTimeByBall(FP _percent, BallObj runball, BallObj staticball, FP _deltaTime)
        {
            runball.UpdateBallPos(_deltaTime * _percent);//先更新到撞击点
            staticball.UpdateBallPos(_deltaTime * _percent);


            //var runcrd = new CircleRunData(runball.GetPos(), runball.PredictPos(_deltaTime), runball.GetRadius());
            //var staticcrd = new CircleRunData(staticball.GetPos(), staticball.PredictPos(_deltaTime), staticball.GetRadius());
            var curReflcDir = Detection.CheckCircle_CircleCollision(runball.GetPos(), runball.GetMoveDir(), staticball.GetPos(), staticball.GetMoveDir());//计算碰撞响应

            runball.UpdateMoveDir(curReflcDir[0]);
            staticball.UpdateMoveDir(curReflcDir[1]);
        }
Exemplo n.º 9
0
        void RandCreateBalls()
        {
            TSRandom.Init();
            FP halfx = TableWidth / 2 - 2 * radius - 5;
            FP halfy = TableHeight / 2 - 2 * radius - 5;

            for (int i = 0; i < 20; i++)
            {
                var ball = new BallObj(i, new TSVector2(TSRandom.Range((int)(-halfx), (int)halfx), TSRandom.Range((int)(-halfy), (int)halfy)), new TSVector2(TSRandom.Range(-1, 1), TSRandom.Range(-1, 1)).normalized, TSRandom.Range(10, 100), radius);
                //var ball = new BallObj(i, new TSVector2(TSRandom.Range((int)(-halfx), (int)halfx), TSRandom.Range((int)(-halfy), (int)halfy)), radius);
                balls.Add(ball);
                if (ball.ID == 0)
                {
                    mainBall = ball;
                }
            }
        }
Exemplo n.º 10
0
        void CreateBalls()
        {
            RandCreateBalls();
            return;

            var ballObj = new BallObj(1, new TSVector2(tableWidth / 2 + 0.4, 0), new TSVector2(0, 1).normalized, 1, 0.5);

            balls.Add(ballObj);

            //ballObj = new BallObj(2, new TSVector2(-4, 0), new TSVector2(1, 0).normalized, 3, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(3, new TSVector2(4, 0), new TSVector2(-1, 0).normalized, 5, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(4, new TSVector2(2, 1), new TSVector2(-0.5, 0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(5, new TSVector2(2, 1), new TSVector2(-0.5, 0.6).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(6, new TSVector2(2, 1), new TSVector2(0.5, 0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(7, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(8, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(9, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(10, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(11, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(12, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(13, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(14, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(15, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(16, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(17, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(18, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(19, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(20, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(21, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(22, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(23, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(24, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);
            //ballObj = new BallObj(25, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(26, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);
            //ballObj = new BallObj(27, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(28, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);
            //ballObj = new BallObj(29, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);

            //ballObj = new BallObj(30, new TSVector2(2, 1), new TSVector2(-0.5, -0.3).normalized, 2, 0.5);
            //balls.Add(ballObj);
        }
Exemplo n.º 11
0
 public fastBall(BallObj _ball)
 {
     ball      = _ball;
     deltaTime = _ball.deltaTime;
     hitType   = HitType.None;
 }