// 发射一颗子弹
        public void OnFire(BallType type, Vector3 r)
        {
            FireBall fire = mPool.GetObject();

            fire.OnInit(type, r);
            mActiveBallQueue.Add(fire);
        }
Beispiel #2
0
        void CheckFireBallCross()
        {
            List <FireBall> list      = GameBulletinBoard.FireBallManager.GetActiveFireList();
            float           _distance = 0.47f * 0.5f;

            int i = list.Count;

            while (i-- > 0)
            {
                FireBall fire = list[i];

                bool isHit = false;
                int  j     = mSnakeSegment.Count;
                while (j-- > 0)
                {
                    Ball ball = mSnakeSegment[j];

                    do
                    {
                        if (fire.IsCross(ball.getPosition(), _distance))
                        {
                            Ball insert = CreateActiveBall(fire.Type);
                            Ball next   = ball.Next;
                            ball.SetNext(insert);
                            insert.SetPre(ball);
                            insert.SetNext(next);
                            if (next != null)
                            {
                                next.SetPre(insert);
                            }
                            insert.processIndex = ball.processIndex + 1;

                            EliminateQueue.Add(insert);

                            list.RemoveAt(i);
                            GameBulletinBoard.FireBallManager.OnBomb(fire);
                            isHit = true;
                            break;
                        }
                        ball = ball.Next;
                    } while (ball != null);

                    if (isHit)
                    {
                        UpdateBallAndBallDistance(mSnakeSegment[j]);
                        break;
                    }
                }
            }
        }
        // Update is called once per frame
        void Update()
        {
            float dt = Time.deltaTime;
            int   i  = mActiveBallQueue.Count;

            while (i-- > 0)
            {
                FireBall fire = mActiveBallQueue[i];
                fire.Tick(dt);
                if (fire.IsOutOfBounds())
                {
                    mActiveBallQueue.RemoveAt(i);
                    OnBomb(fire);
                }
            }
        }
 // 子弹爆炸失效
 public void OnBomb(FireBall fire)
 {
     fire.OnDestroy();
     mPool.SetObject(fire);
 }