Пример #1
0
        public void moveBallComplete(itemBase it, ball b)
        {
            ESlide inSide = b.getInSide();

            if (inSide == ESlide.center && it.isFinishItem())
            {
                HtmlContext.window.alert("Success level.");
            }
            else
            {
                int x = it.getX();
                int y = it.getY();
                var side = ESlide.none;
                if (inSide == ESlide.top)
                {
                    y--;
                    side = ESlide.bottom;
                }
                else if (inSide == ESlide.bottom)
                {
                    y++;
                    side = ESlide.top;
                }
                else if (inSide == ESlide.left)
                {
                    x--;
                    side = ESlide.right;
                }
                else if (inSide == ESlide.right)
                {
                    x++;
                    side = ESlide.left;
                }

                itemBase newItem = map.inst().getItemByXY(x, y);
                if (newItem != null && newItem.hasSide(side))
                {
                    b.setInSide(side);
                    newItem.moveBall(b, js.bind(delegate { moveBallComplete(newItem, b); }, this));
                }
                else
                {
                    HtmlContext.window.alert("Failed level.");
                }
            }
        }
Пример #2
0
        public void moveBall(ball ball, JsAction callback)
        {
            topToRightItem self = this;

            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMin, inSide = ESlide.top});

            for (int y = yMin + 1; y < yMed; ++y)
            {
                points.push(new point {x = xMed, y = y});
            }

            for (int x = xMed; x < xMax; ++x)
            {
                points.push(new point {x = x, y = yMed});
            }

            points.push(new point {x = xMax, y = yMed, inSide = ESlide.right});

            HtmlElement div = getDiv();
            if (ball.getInSide() == ESlide.top)
            {
                div.appendChild(ball.getDiv());
                points = points.reverse();
                _moveBallInternal(ball, points, callback);
            }
            else if (ball.getInSide() == ESlide.right)
            {
                div.appendChild(ball.getDiv());
                _moveBallInternal(ball, points, callback);
            }
            else
            {
                js.assert(false);
            }
        }
Пример #3
0
        public override void showBall(ball ball, JsAction callback)
        {
            topToRightItem self = this;

            HtmlElement div = getDiv();
            if (ball.getInSide() == ESlide.top)
            {
                div.appendChild(ball.getDiv());
                ball.getDiv().style.left = xMed + "%";
                ball.getDiv().style.top = yMin + "%";
            }
            else if (ball.getInSide() == ESlide.right)
            {
                div.appendChild(ball.getDiv());
                ball.getDiv().style.left = xMax + "%";
                ball.getDiv().style.top = yMed + "%";
            }
        }
Пример #4
0
        public void moveBall(ball ball, JsAction callback)
        {
            topToBottomItem self = this;

            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMin, inSide = ESlide.top});

            for (int y = yMin + 1; y < yMax; ++y)
            {
                points.push(new point {x = xMed, y = y});
            }
            points.push(new point {x = xMed, y = yMax, inSide = ESlide.bottom});

            HtmlElement div = getDiv();
            if (ball.getInSide() == ESlide.top)
            {
                div.appendChild(ball.getDiv());
                points = points.reverse();
                _moveBallInternal(ball, points, callback);
            }
            else if (ball.getInSide() == ESlide.bottom)
            {
                div.appendChild(ball.getDiv());
                _moveBallInternal(ball, points, callback);
            }
        }