예제 #1
0
        public bool checkActions(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
        {
            if (keyHandler.isActionReady())
            {
                if (checkMainAction(gameInit, keyHandler))
                {
                    return true;
                }
            }

            if (keyHandler.isBackReady())
            {
                return true;
            }

            if (keyHandler.isM1Ready())
            {
                return true;
            }

            if (keyHandler.isM2Ready())
            {
                return true;
            }
            return false;
        }
예제 #2
0
 public void updateLogic(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
     if (gameInit.getGameState().getState() == gameInit.getGameState().START_STATE)
     {
         updateStartLogic(gameInit, keyHandler, content);
     }
     else if (gameInit.getGameState().getState() == gameInit.getGameState().FREE_ROAM_STATE)
     {
         updateFreeRoamLogic(gameInit, keyHandler, content);
     }
     else if (gameInit.getGameState().getState() == gameInit.getGameState().BATTLE_STATE)
     {
         updateBattleLogic(gameInit, keyHandler, content);
     }
     else if (gameInit.getGameState().getState() == gameInit.getGameState().PAUSE_STATE)
     {
     }
 }
예제 #3
0
        private bool checkMainAction(GameInit gameInit, KeyHandler keyHandler)
        {
            int direction = gameInit.getParty().getPartyMembers()[0].getFacingDirection();

            if (direction == 0)
            {
                int targetX = gameInit.getParty().getPartyMembers()[0].getX() - 1;
                int targetY = gameInit.getParty().getPartyMembers()[0].getY();

                if (targetX < 0)
                {
                    return false;
                }
                else
                {
                    checkForInteract(gameInit, targetX, targetY);
                }
            }
            else if (direction == 1)
            {
                int targetX = gameInit.getParty().getPartyMembers()[0].getX() + 1;
                int targetY = gameInit.getParty().getPartyMembers()[0].getY();

                if (targetX >= gameInit.getFreeRoamState().getCurrentZone().getTileWidth())
                {
                    return false;
                }
                else
                {
                    checkForInteract(gameInit, targetX, targetY);
                }
            }
            else if (direction == 2)
            {
                int targetX = gameInit.getParty().getPartyMembers()[0].getX();
                int targetY = gameInit.getParty().getPartyMembers()[0].getY() - 1;

                if (targetY < 0)
                {
                    return false;
                }
                else
                {
                    checkForInteract(gameInit, targetX, targetY);
                }
            }
            else if (direction == 3)
            {
                int targetX = gameInit.getParty().getPartyMembers()[0].getX();
                int targetY = gameInit.getParty().getPartyMembers()[0].getY() + 1;

                if (targetY >= gameInit.getFreeRoamState().getCurrentZone().getTileHeight())
                {
                    return false;
                }
                else
                {
                    checkForInteract(gameInit, targetX, targetY);
                }
            }
            else
            {
                return false;
            }
            return false;
        }
예제 #4
0
        public void continueChatWindow(GameInit gameInit, KeyHandler keyHandler)
        {
            chatCounter++;

            if (chatCounter > CHAT_THRESHOLD)
            {
                if (keyHandler.isActionReady())
                {
                    chatObject.advanceMessage(gameInit);

                    if (!chatObject.showChatWindow())
                    {
                        chatWindow = false;
                        gameInit.getFreeRoamState().setChatWindow(false);
                    }
                    else
                    {
                        chatObject.talk(gameInit);
                    }

                    if (chatObject.giveItem())
                    {
                        chatObject.noItem();
                    }
                }
                else if (keyHandler.isBackReady())
                {
                    chatObject.backAdvanceMessage(gameInit);

                    if (!chatObject.showChatWindow())
                    {
                        chatWindow = false;
                        gameInit.getFreeRoamState().setChatWindow(false);
                    }
                    else
                    {
                        chatObject.talk(gameInit);
                    }

                    if (chatObject.giveItem())
                    {
                        chatObject.noItem();
                    }
                }
                else if (keyHandler.getUpTime() >= keyHandler.getDownTime())
                {
                    if (keyHandler.getUpTime() >= 3)
                    {
                        chatObject.moveUpOptionIndex(gameInit);
                    }
                }
                else if (keyHandler.getDownTime() >= 3)
                {
                    chatObject.moveDownOptionIndex(gameInit);
                }
            }
            else
            {
                if (keyHandler.getUpTime() >= keyHandler.getDownTime())
                {
                    if (keyHandler.getUpTime() >= 3)
                    {
                        chatObject.moveUpOptionIndex(gameInit);
                    }
                }
                else if (keyHandler.getDownTime() >= 3)
                {
                    chatObject.moveDownOptionIndex(gameInit);
                }
            }
        }
예제 #5
0
        private int getGreatestDirection(KeyHandler keyHandler)
        {
            int greatest = 0;
            int time = keyHandler.getUpTime();

            if (keyHandler.getDownTime() > time)
            {
                greatest = 1;
                time = keyHandler.getDownTime();
            }

            if (keyHandler.getRightTime() > time)
            {
                greatest = 2;
                time = keyHandler.getRightTime();
            }

            if (keyHandler.getLeftTime() > time)
            {
                greatest = 3;
                time = keyHandler.getLeftTime();
            }

            if (time == 0)
            {
                return -1;
            }
            else
            {
                //Console.WriteLine("Greatest: " + greatest);
                return greatest;
            }
        }
예제 #6
0
        public bool checkMove(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
        {
            int direction = getGreatestDirection(keyHandler);

            if (direction == 0)
            {
                gameInit.getParty().getPartyMembers()[0].setFacingDirection(0);
                if (keyHandler.getUpTime() < TURN_THRESHOLD)
                {
                    return false;
                }
                else
                {
                    if (checkHeight(gameInit, -1, 0) && checkAvailability(gameInit, -1, 0))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            else if (direction == 1)
            {
                gameInit.getParty().getPartyMembers()[0].setFacingDirection(1);
                if (keyHandler.getDownTime() < TURN_THRESHOLD)
                {
                    return false;
                }
                else
                {
                    if (checkHeight(gameInit, 1, 0) && checkAvailability(gameInit, 1, 0))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            else if (direction == 2)
            {
                gameInit.getParty().getPartyMembers()[0].setFacingDirection(2);
                if (keyHandler.getRightTime() < TURN_THRESHOLD)
                {
                    return false;
                }
                else
                {
                    if (checkHeight(gameInit, 0, -1) && checkAvailability(gameInit, 0, -1))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            else if (direction == 3)
            {
                gameInit.getParty().getPartyMembers()[0].setFacingDirection(3);
                if (keyHandler.getLeftTime() < TURN_THRESHOLD)
                {
                    return false;
                }
                else
                {
                    if (checkHeight(gameInit, 0, 1) && checkAvailability(gameInit, 0, 1))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            else
            {
                return false;
            }
        }
예제 #7
0
        private void updateFreeRoamPlayerLogic(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
        {
            //Console.WriteLine("PLAYER X: " + gameInit.getParty().getPartyMembers()[0].getX());
            //Console.WriteLine("PLAYER Y: " + gameInit.getParty().getPartyMembers()[0].getY());
            //Console.WriteLine("HEIGHT: " + gameInit.getParty().getPartyMembers()[0].getHeight());
            if (movementHandler.isMoving())
            {
                movementHandler.updateMove(gameInit);
            }
            else if (transitionHandler.isTransitioning())
            {
                transitionHandler.continueTransition(gameInit);
                drawColor = transitionHandler.getFadeColor();
            }
            else if (actionHandler.isActivating())
            {
                actionHandler.continueActivation(gameInit);

                if (actionHandler.isTransitionReady())
                {
                    transitionHandler.startTransition(gameInit, (Door)actionHandler.getTransitioningObject());
                }
            }
            else if (actionHandler.showBigChat())
            {
            }
            else if (actionHandler.showChatWindow())
            {
                actionHandler.continueChatWindow(gameInit, keyHandler);
            }
            else
            {
                if (!actionHandler.checkActions(gameInit, keyHandler, content))
                {
                    if (!checkMove(gameInit, keyHandler, content))
                    {
                        int x = gameInit.getParty().getPartyMembers()[0].getX();
                        int y = gameInit.getParty().getPartyMembers()[0].getY();
                        int direction = gameInit.getParty().getPartyMembers()[0].getFacingDirection();

                        if (gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].isTransition() && gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].getTransitionDirection() == direction)
                        {
                            gameInit.getParty().getPartyMembers()[0].setFacingDirection(gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].getTransitionDirection());
                            transitionHandler.startTransition(gameInit, gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y]);
                        }
                        else
                        {

                            if (direction == 0)
                            {
                                gameInit.getParty().getPartyMembers()[0].getCharacterAnimations().setNewAnimation(0);

                                if (gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].isSloped())
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 4));
                                }
                                else
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 0));
                                }
                            }
                            else if (direction == 1)
                            {
                                gameInit.getParty().getPartyMembers()[0].getCharacterAnimations().setNewAnimation(1);

                                if (gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].isSloped())
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 4));
                                }
                                else
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 0));
                                }
                            }
                            else if (direction == 2)
                            {
                                gameInit.getParty().getPartyMembers()[0].getCharacterAnimations().setNewAnimation(2);

                                if (gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].isSloped())
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 4));
                                }
                                else
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 0));
                                }
                            }
                            else if (direction == 3)
                            {
                                gameInit.getParty().getPartyMembers()[0].getCharacterAnimations().setNewAnimation(3);

                                if (gameInit.getFreeRoamState().getCurrentZone().getTileMap()[x, y].isSloped())
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 4));
                                }
                                else
                                {
                                    gameInit.getParty().getPartyMembers()[0].setTileDrawOffset(new Vector2(0, 0));
                                }
                            }
                        }

                    }
                    else
                    {
                        movementHandler.movePlayer(gameInit);
                    }
                }
                else
                {
                }
            }
        }
예제 #8
0
 private void updateFreeRoamLogic(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
     updateFreeRoamPlayerLogic(gameInit, keyHandler, content);
 }
예제 #9
0
 private void updateBattleLogic(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
 }
예제 #10
0
 private bool checkMove(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
     return movementHandler.checkMove(gameInit, keyHandler, content);
 }
예제 #11
0
 private bool checkMenu(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
     return true;
 }
예제 #12
0
 private void updateStartLogic(GameInit gameInit, KeyHandler keyHandler, ContentHandler content)
 {
 }