Beispiel #1
0
        private void AddNext(Row upRow, Row downRow)
        {
            float upEndX   = upRow.Last.transform.position.x + upRow.Last.width;
            float downEndX = downRow.Last.transform.position.x + downRow.Last.width;

            bool addUp   = upEndX < Singleton.Instanse.screen.x;
            bool addDown = downEndX < Singleton.Instanse.screen.x;

            if (addUp && addDown)              //both
            {
                Row    continueRow = Singleton.RandomBetween <Row>(upRow, downRow, TOP_DOWN_PROBABILITY);
                Border border      = AddNextInLine(continueRow, RealWidth, RealWidth, 1f);
                if (Singleton.RandomBetween <bool>(true, false, BARRIER_PROBABILITY))
                {
                    border.CreateRightBarrier();
                }
                if (Singleton.RandomBetween(true, false, GOOD_APPEARANCE_PROBABILITY))
                {
                    border.SetGood();
                }
            }
            else if (addUp && !addDown)              //add up
            {
                float  space  = (downEndX - upEndX);
                Border border = AddNextInLine(upRow, RealWidth, space, ZERO_SPACE_PROBABILITY);
                if (Singleton.RandomBetween <bool>(true, false, BARRIER_PROBABILITY))
                {
                    border.CreateRightBarrier();
                }
                if (!downRow.Last.IsRightBarrierActive())
                {
                    if (Singleton.RandomBetween <bool>(true, false, BARRIER_PROBABILITY))
                    {
                        border.CreateLeftBarrier();
                    }
                }
                if (Singleton.RandomBetween(true, false, GOOD_APPEARANCE_PROBABILITY))
                {
                    border.SetGood();
                }
            }
            else if (!addUp && addDown)              //add down
            {
                float  space  = (upEndX - downEndX);
                Border border = AddNextInLine(downRow, RealWidth, space, ZERO_SPACE_PROBABILITY);
                if (Singleton.RandomBetween <bool>(true, false, BARRIER_PROBABILITY))                 //генерация правого барьера
                {
                    border.CreateRightBarrier();
                }
                if (!upRow.Last.IsRightBarrierActive())
                {
                    if (Singleton.RandomBetween <bool>(true, false, BARRIER_PROBABILITY))                     //генерация левого барьера если сверху барьера нет
                    {
                        border.CreateLeftBarrier();
                    }
                }
                if (Singleton.RandomBetween(true, false, GOOD_APPEARANCE_PROBABILITY))
                {
                    border.SetGood();
                }
            }
        }