示例#1
0
        public void executeAction(GameInit gameInit)
        {
            if (currentAction == ACTIVATE)
            {
            }
            else if (currentAction == ENTER)
            {
            }
            else if (currentAction == INSPECT)
            {
            }
            else if (currentAction == OPEN)
            {
            }
            else if (currentAction == TALK)
            {
                int direction = gameInit.getPlayer().getFacingDirection();

                if (direction == 0)
                {
                    interactingNPC.turn(1);
                    interactingNPC.setNewAnimation(gameInit.getContentHandler().getNPCContentHandler().getNPCImages()[interactingNPC.getName()]["STATIONARY_DOWN"]);
                }
                else if (direction == 1)
                {
                    interactingNPC.turn(0);
                    interactingNPC.setNewAnimation(gameInit.getContentHandler().getNPCContentHandler().getNPCImages()[interactingNPC.getName()]["STATIONARY_UP"]);
                }
                else if (direction == 2)
                {
                    interactingNPC.turn(3);
                    interactingNPC.setNewAnimation(gameInit.getContentHandler().getNPCContentHandler().getNPCImages()[interactingNPC.getName()]["STATIONARY_LEFT"]);
                }
                else if (direction == 3)
                {
                    interactingNPC.turn(2);
                    interactingNPC.setNewAnimation(gameInit.getContentHandler().getNPCContentHandler().getNPCImages()[interactingNPC.getName()]["STATIONARY_RIGHT"]);
                }

                gameInit.getGameState().setChatState();
                gameInit.getChatKeyHandler().fadeIn(interactingNPC);
            }
        }
示例#2
0
        private void checkIfPushContinue(GameInit gameInit, KeyboardState keyboardState)
        {
            int direction = gameInit.getPlayer().getFacingDirection();

            if (direction == 0)
            {
                if (keyboardState.IsKeyDown(DOWN_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_UP"]);
                }
                if (keyboardState.IsKeyDown(RIGHT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_UP"]);
                    moveRightFlag = true;
                }
                if (keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_UP"]);
                    moveLeftFlag = true;
                }
                if (!keyboardState.IsKeyDown(DOWN_MOVE) && !keyboardState.IsKeyDown(RIGHT_MOVE) && !keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    if (gameInit.getPlayer().isAnimationFinished())
                    {
                        gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_UP"]);
                    }
                    else
                    {
                        gameInit.getPlayer().advanceCurrentAnimation();
                    }
                }
            }
            else if (direction == 1)
            {
                if (keyboardState.IsKeyDown(UP_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_DOWN"]);
                }
                if (keyboardState.IsKeyDown(RIGHT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_DOWN"]);
                    moveRightFlag = true;
                }
                if (keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_DOWN"]);
                    moveLeftFlag = true;
                }
                if (!keyboardState.IsKeyDown(UP_MOVE) && !keyboardState.IsKeyDown(RIGHT_MOVE) && !keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    if (gameInit.getPlayer().isAnimationFinished())
                    {
                        gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_DOWN"]);
                    }
                    else
                    {
                        gameInit.getPlayer().advanceCurrentAnimation();
                    }
                }
            }
            else if (direction == 2)
            {
                if (keyboardState.IsKeyDown(DOWN_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_RIGHT"]);
                    moveDownFlag = true;
                }
                if (keyboardState.IsKeyDown(UP_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_RIGHT"]);
                    moveUpFlag = true;
                }
                if (keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_RIGHT"]);
                }
                if (!keyboardState.IsKeyDown(DOWN_MOVE) && !keyboardState.IsKeyDown(UP_MOVE) && !keyboardState.IsKeyDown(LEFT_MOVE))
                {
                    if (gameInit.getPlayer().isAnimationFinished())
                    {
                        gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_RIGHT"]);
                    }
                    else
                    {
                        gameInit.getPlayer().advanceCurrentAnimation();
                    }
                }
            }
            else if (direction == 3)
            {
                if (keyboardState.IsKeyDown(DOWN_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_LEFT"]);
                    moveDownFlag = true;
                }
                if (keyboardState.IsKeyDown(RIGHT_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_LEFT"]);
                }
                if (keyboardState.IsKeyDown(UP_MOVE))
                {
                    pushing = false;
                    pushingCounter = 0;
                    walking = true;
                    gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["WALK_LEFT"]);
                    moveUpFlag = true;
                }
                if (!keyboardState.IsKeyDown(DOWN_MOVE) && !keyboardState.IsKeyDown(RIGHT_MOVE) && !keyboardState.IsKeyDown(UP_MOVE))
                {
                    if (gameInit.getPlayer().isAnimationFinished())
                    {
                        gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["PUSH_LEFT"]);
                    }
                    else
                    {
                        gameInit.getPlayer().advanceCurrentAnimation();
                    }
                }
            }
        }
示例#3
0
        private void beginDrain(GameInit gameInit)
        {
            drainTiles.Clear();

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

            if (direction == 0)
            {
                drainCenter = gameInit.getPlayer().getGlobalLocation() + new Vector2(15, -15);
                gameInit.getPlayer().setNewAbilityAnimation(gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimations()["CIRCLEGROWUP"], gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimationOffsets()["CIRCLEGROWUP"]);
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["DRAIN_UP"]);
            }
            else if (direction == 1)
            {
                drainCenter = gameInit.getPlayer().getGlobalLocation() + new Vector2(15, 45);
                gameInit.getPlayer().setNewAbilityAnimation(gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimations()["CIRCLEGROWDOWN"], gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimationOffsets()["CIRCLEGROWDOWN"]);
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["DRAIN_DOWN"]);
            }
            else if (direction == 2)
            {
                drainCenter = gameInit.getPlayer().getGlobalLocation() + new Vector2(45, 15);
                gameInit.getPlayer().setNewAbilityAnimation(gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimations()["CIRCLEGROWRIGHT"], gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimationOffsets()["CIRCLEGROWRIGHT"]);
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["DRAIN_RIGHT"]);
            }
            else if (direction == 3)
            {
                drainCenter = gameInit.getPlayer().getGlobalLocation() + new Vector2(-15, 15);
                gameInit.getPlayer().setNewAbilityAnimation(gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimations()["CIRCLEGROWLEFT"], gameInit.getContentHandler().getAbilityContentHandler().getAbilityAnimationOffsets()["CIRCLEGROWLEFT"]);
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["DRAIN_LEFT"]);
            }

            drainCounter++;
            drainRadius = 10;

            //fillDrainTiles(gameInit);
        }
示例#4
0
        private void animateObjects(GameInit gameInit)
        {
            List<ManipulatableObject> objectList = gameInit.getZoneFactory().getCurrentZone().getObjectList();

            for (int i = 0; i < objectList.Count; i++)
            {
                ManipulatableObject currentObject = objectList[i];

                if (currentObject.isStationary())
                {
                    if (currentObject.isAnimationFinished())
                    {
                        currentObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "STATIONARY");
                    }
                    else
                    {
                        currentObject.advanceAnimation();
                    }
                }
            }
        }
示例#5
0
        private void setStationaryAnimation(GameInit gameInit)
        {
            int direction = gameInit.getPlayer().getFacingDirection();

            if (direction == 0)
            {
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_UP"]);
            }
            else if (direction == 1)
            {
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_DOWN"]);
            }
            else if (direction == 2)
            {
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_RIGHT"]);
            }
            else if (direction == 3)
            {
                gameInit.getPlayer().setNewAnimation(gameInit.getContentHandler().getPlayerContentHandler().getPlayerAnimations()["STATIONARY_LEFT"]);
            }
        }
示例#6
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;
                    }
                }
            }
        }
示例#7
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"]);
                }
            }
        }
示例#8
0
        private void drain(GameInit gameInit)
        {
            int xStart = (int)drainCenter.X - drainRadius;
            int yStart = (int)drainCenter.Y - drainRadius;

            int xTileStart;
            int yTileStart;

            int xLength;
            int yLength;

            int xTiles;
            int yTiles;

            if (xStart >= 0)
            {
                xTileStart = xStart / 30;
                xLength = 2 * drainRadius;
                xTiles = (xLength + 29 + xStart % 30) / 30;
            }
            else
            {
                xTileStart = 0;
                xLength = 2 * drainRadius + xStart;
                xTiles = (xLength + 29) / 30;
            }

            if (yStart >= 0)
            {
                yTileStart = yStart / 30;
                yLength = 2 * drainRadius;
                yTiles = (yLength + 29 + yStart % 30) / 30;
            }
            else
            {
                yTileStart = 0;
                yLength = 2 * drainRadius + yStart;
                yTiles = (yLength + 29) / 30;
            }

            Console.WriteLine("X: " + xTiles);
            Console.WriteLine("Y: " + yTiles);

            for (int i = 0; i < xTiles; i++)
            {
                for (int j = 0; j < yTiles; j++)
                {
                    if (xTileStart + i > 0 && xTileStart + i < gameInit.getZoneFactory().getCurrentZone().getTileWidth())
                    {
                        if (yTileStart + j > 0 && yTileStart + i < gameInit.getZoneFactory().getCurrentZone().getTileHeight())
                        {
                            if (gameInit.getZoneFactory().getCurrentZone().getZoneTileMap().getTile(yTileStart + j, xTileStart + i, gameInit.getPlayer().getCurrentZoneLevel()).isObject())
                            {
                                ManipulatableObject currentObject = gameInit.getZoneFactory().getCurrentZone().getZoneTileMap().getTile(yTileStart + j, xTileStart + i, gameInit.getPlayer().getCurrentZoneLevel()).getTileObject();
                                if (currentObject.getDrainAmount() != 0 && currentObject.getEnergy() != 0 && currentObject.isStationary())
                                {
                                    currentObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "DRAIN");
                                    gameInit.getPlayer().drainEnergy(currentObject.getDrainAmount(), currentObject.getEnergyType());
                                    manipulatedObjects.Add(currentObject);
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine(manipulatedObjects.Count);
        }
示例#9
0
        private void cleanManipulatedObjects(GameInit gameInit)
        {
            for (int i = 0; i < manipulatedObjects.Count; i++)
            {
                ManipulatableObject currentObject = manipulatedObjects[i];

                if (currentObject.isAnimationFinished())
                {
                    manipulatedObjects.Remove(currentObject);
                    currentObject.activate(gameInit.getContentHandler(), gameInit.getZoneFactory().getCurrentZone(), "STATIONARY");
                }
                else
                {
                    currentObject.advanceAnimation();
                }
            }
        }