Exemplo n.º 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.");
                }
            }
        }
Exemplo n.º 2
0
        public void moveBall(ball ball, JsAction callback)
        {
            finishRightItem self = this;
            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMed, inSide = ESlide.center});
            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();
            div.appendChild(ball.getDiv());
            _moveBallInternal(ball, points, callback);
        }
Exemplo n.º 3
0
        public override void showBall(ball ball, JsAction callback)
        {
            finishItemBase self = this;

            HtmlElement div = getDiv();
            div.appendChild(ball.getDiv());
        }
Exemplo n.º 4
0
        public void moveBall(ball ball, JsAction callback)
        {
            startBottomItem self = this;
            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMed, inSide = ESlide.center});
            for (int y = yMed; y < yMax; ++y)
            {
                points.push(new point {x = xMed, y = y});
            }
            points.push(new point {x = xMed, y = yMax, inSide = ESlide.bottom});
            points = points.reverse();

            HtmlElement div = getDiv();
            div.appendChild(ball.getDiv());
            _moveBallInternal(ball, points, callback);
        }
Exemplo n.º 5
0
        public void moveBall(ball ball, JsAction callback)
        {
            startLeftItem self = this;
            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMed, inSide = ESlide.center});
            for (int x = xMed - 1; x > xMin; x--)
            {
                points.push(new point {x = x, y = yMed});
            }
            points.push(new point {x = xMin, y = yMed, inSide = ESlide.left});
            points = points.reverse();

            HtmlElement div = getDiv();
            div.appendChild(ball.getDiv());
            _moveBallInternal(ball, points, callback);
        }
Exemplo n.º 6
0
        public override void showBall(ball ball, JsAction callback)
        {
            startItemBase self = this;

            HtmlElement div = getDiv();
            div.appendChild(ball.getDiv());
            ball.getDiv().style.left = xMed + "%";
            ball.getDiv().style.top = yMed + "%";
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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 + "%";
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
0
 public virtual void showBall(ball ball, JsAction callback)
 {
     
 }
Exemplo n.º 11
0
        public void _moveBallInternal(ball b, JsArray<point> points, JsAction callback)
        {
            itemBase self = this;

            point point = points.pop();
            if (point != null)
            {
                b.getDiv().style.left = point.x + "%";
                b.getDiv().style.top = point.y + "%";
                if (point.inSide != ESlide.none)
                {
                    b.setInSide(point.inSide);
                }
                HtmlContext.window.setTimeout(delegate { self._moveBallInternal(b, points, callback); }, 50);
            }
            else
            {
                callback();
            }
        }
Exemplo n.º 12
0
        public void moveBall(ball ball, JsAction callback)
        {
            finishTopItem self = this;
            var points = new JsArray<point>();
            points.push(new point {x = xMed, y = yMed, inSide = ESlide.center});
            for (int y = yMed; y > yMin; --y)
            {
                points.push(new point {x = xMed, y = y});
            }
            points.push(new point {x = xMed, y = yMin, inSide = ESlide.top});

            HtmlElement div = getDiv();
            div.appendChild(ball.getDiv());
            _moveBallInternal(ball, points, callback);
        }