Esempio n. 1
0
    // aka get out the way
    public override void MovingIn(GameThing other, int intoDirection)
    {
        int x = GetX();
        int y = GetY();

        int dx = DirectionDX(intoDirection);
        int dy = DirectionDY(intoDirection);

        GameThing inTheWay = GameController.game.GetThingAt(x + dx, y + dy);

        inTheWay.MovingIn(this, intoDirection);

        ActuallyMove(x + dx, y + dy);
    }
Esempio n. 2
0
    bool TryToWalk()
    {
        if (!KeyPressed(RIGHT) && !KeyPressed(LEFT))
        {
            return(false);
        }
        if (KeyPressed(RIGHT) && KeyPressed(LEFT))
        {
            return(false);
        }

        int direction;
        int dx;

        if (KeyPressed(RIGHT))
        {
            direction = RIGHT;
            dx        = 1;
        }
        else
        {
            direction = LEFT;
            dx        = -1;
        }
        FaceDirection(direction);

        int       x        = GetX();
        int       y        = GetY();
        GameThing inTheWay = GameController.game.GetThingAt(x + dx, y);

        if (!inTheWay.AllowMovingThrough(this, direction))
        {
            return(false);
        }

        // Push if it's a block
        inTheWay.MovingIn(this, direction);

        ActuallyMove(x + dx, y);
        lastMoved = Time.timeSinceLevelLoad;

        return(true);
    }
Esempio n. 3
0
    bool TryToJump()
    {
        if (!KeyPressed(UP) || KeyPressed(DOWN))
        {
            return(false);
        }

        int       x        = GetX();
        int       y        = GetY();
        GameThing inTheWay = GameController.game.GetThingAt(x, y + 1);

        if (!inTheWay.AllowMovingThrough(this, UP))
        {
            return(false);
        }

        // Push if it's a rock
        inTheWay.MovingIn(this, UP);

        ActuallyMove(x, y + 1);
        lastJumped = Time.timeSinceLevelLoad;

        return(true);
    }