Ejemplo n.º 1
0
        private void pushObject(GameInit gameInit, ZoneTile pushingTile, ZoneTile destination)
        {
            if (pushingTile.isFull())
            {
                if (destination.isFree() && destination.isPushable())
                {
                    if (pushingTile.getTileObject().isPushable())
                    {
                        ManipulatableObject tileObject = pushingTile.getTileObject();

                        int direction = gameInit.getPlayer().getFacingDirection();

                        if (direction == 0)
                        {
                            tileObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "PUSH_UP");
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_UP"]);
                        }
                        else if (direction == 1)
                        {
                            tileObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "PUSH_DOWN");
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_DOWN"]);
                        }
                        else if (direction == 2)
                        {
                            tileObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "PUSH_RIGHT");
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_RIGHT"]);
                        }
                        else if (direction == 3)
                        {
                            tileObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "PUSH_LEFT");
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_LEFT"]);
                        }
                        //manipulatedObjects.Add(tileObject);
                        animatingObject = tileObject;
                        environmentAnimation = true;
                        pushing = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void jump(GameInit gameInit, ZoneTile jumpingTile, ZoneTile destination)
        {
            int direction = gameInit.getPlayer().getFacingDirection();

            if (jumpingTile.isJumpable())
            {
                if (destination.getType() == 0)
                {
                    if (destination.isFree())
                    {
                        walking = false;
                        jumping = true;
                        pushingCounter = 0;
                        if (direction == 0)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_UP"]);
                        }
                        else if (direction == 1)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_DOWN"]);
                        }
                        else if (direction == 2)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_RIGHT"]);
                        }
                        else if (direction == 3)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_LEFT"]);
                        }
                        gameInit.getPlayer().jump(direction);
                        gameInit.getPlayer().setGlobalLocation(gameInit.getPlayer().getGlobalLocation() + gameInit.getPlayer().getJumpOffset()[gameInit.getPlayer().getAnimationIndex()]);
                        movementHandler.updateDrawLocations(gameInit.getPlayer(), gameInit.getZoneFactory().getCurrentZone());
                    }
                }
                else if (destination.getType() == 1)
                {
                    if (destination.isFull())
                    {
                        walking = false;
                        jumping = true;
                        pushingCounter = 0;
                        if (direction == 0)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_UP"]);
                        }
                        else if (direction == 1)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_DOWN"]);
                        }
                        else if (direction == 2)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_RIGHT"]);
                        }
                        else if (direction == 3)
                        {
                            gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["JUMP_LEFT"]);
                        }
                        gameInit.getPlayer().jump(direction);
                        gameInit.getPlayer().setGlobalLocation(gameInit.getPlayer().getGlobalLocation() + gameInit.getPlayer().getJumpOffset()[gameInit.getPlayer().getAnimationIndex()]);
                        movementHandler.updateDrawLocations(gameInit.getPlayer(), gameInit.getZoneFactory().getCurrentZone());
                    }
                }
                else
                {
                    walking = false;
                    pushingCounter = 0;
                    setStationaryAnimation(gameInit);
                }
            }
            else
            {
                pushing = true;
                walking = false;
                if (direction == 0)
                {
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_UP"]);
                }
                else if (direction == 1)
                {
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_DOWN"]);
                }
                else if (direction == 2)
                {
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_RIGHT"]);
                }
                else if (direction == 3)
                {
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_LEFT"]);
                }
            }
        }