Ejemplo n.º 1
0
        public void warpPlayer(Game game, LLESprite playerCharacter, float mPlayerX, float mPlayerY, Vector2 windowSize)
        {
            int index = checkWarpCollision(playerCharacter);

            if (index != -1 && warpBoxes[index].mID.Replace(" ", "") != "-1" && warpBoxes[index].mTargetID.Replace(" ", "") != "-1")
            {
                if (warpBoxes[index].mTargetLevel == "NONE")
                {
                    for (int i = 0; i < warpBoxes.Count; i++)
                    {
                        if (i != index && warpBoxes[i] != null && warpBoxes[i].mID == warpBoxes[index].mTargetID)
                        {
                            if (warpBoxes[i].mDirection.ToUpper() == "UP")
                            {
                                playerCharacter.setX(warpBoxes[i].mX + (warpBoxes[i].mWidth / 2) - (playerCharacter.getFrameWidth() / 2));

                                playerCharacter.setY(warpBoxes[i].mY - playerCharacter.getHeight() - 10);

                                //game.setPlayerXY(playerCharacter.getX(), playerCharacter.getY());

                                playerCharacter.setVisible(false);
                            }

                            else if (warpBoxes[i].mDirection.ToUpper() == "DOWN")
                            {
                                playerCharacter.setX(warpBoxes[i].mX + (warpBoxes[i].mWidth / 2) - (playerCharacter.getFrameWidth() / 2));

                                playerCharacter.setY(warpBoxes[i].mY + (warpBoxes[i].mHeight / 2));

                                //game.setPlayerXY(playerCharacter.getX(), playerCharacter.getY());

                                playerCharacter.setVisible(false);
                            }

                            else if (warpBoxes[i].mDirection.ToUpper() == "LEFT")
                            {
                                playerCharacter.setX(warpBoxes[i].mX - playerCharacter.getFrameWidth() - 10);

                                playerCharacter.setY(warpBoxes[i].mY + (warpBoxes[i].mHeight / 2) - (playerCharacter.getFrameHeight() / 2));
                            }

                            else if (warpBoxes[i].mDirection.ToUpper() == "RIGHT")
                            {
                                playerCharacter.setX(warpBoxes[i].mX + warpBoxes[i].mWidth + 10);

                                playerCharacter.setY(warpBoxes[i].mY + (warpBoxes[i].mHeight / 2) - (playerCharacter.getFrameHeight() / 2));
                            }

                            setCameraDestination(new Vector2(playerCharacter.getX(), playerCharacter.getY()), windowSize);

                            mWarping = true;

                            break;
                        }
                    }
                }

                else
                {
                    //game.setWarpVariables(true, warpBoxes[index].mTargetLevel, warpBoxes[index].mTargetID);
                }
            }
        }
Ejemplo n.º 2
0
        public void alignCameraToWarp(string targetWarpID, LLESprite playerCharacter)
        {
            int index = getTargetWarpID(targetWarpID);

            if (index != -1)
            {
                cameraX = warpBoxes[index].mX + (warpBoxes[index].mWidth / 2) - (10 * TILE_SIZE);

                cameraY = warpBoxes[index].mY - (7 * TILE_SIZE);

                if (cameraX < 0)
                {
                    cameraX = 0;
                }

                if (cameraY < 0)
                {
                    cameraY = 0;
                }

                if (warpBoxes[index].mDirection.ToUpper() == "UP")
                {
                    cameraY -= playerCharacter.getHeight() - 5;

                    playerCharacter.setX(warpBoxes[index].mX + (warpBoxes[index].mWidth / 2) - (playerCharacter.getFrameWidth() / 2) - cameraX);

                    playerCharacter.setY(warpBoxes[index].mY - playerCharacter.getHeight() - 5 - cameraY);
                }

                else if (warpBoxes[index].mDirection.ToUpper() == "DOWN")
                {
                    playerCharacter.setX(warpBoxes[index].mX + (warpBoxes[index].mWidth / 2) - (playerCharacter.getFrameWidth() / 2) - cameraX);

                    playerCharacter.setY(warpBoxes[index].mY + warpBoxes[index].mHeight - (playerCharacter.getHeight() / 2) - cameraY);
                }

                else if (warpBoxes[index].mDirection.ToUpper() == "LEFT")
                {
                    cameraX -= playerCharacter.getFrameWidth() - 5;

                    playerCharacter.setX(warpBoxes[index].mX - playerCharacter.getFrameWidth() - 5 - cameraX);

                    playerCharacter.setY(warpBoxes[index].mY + (warpBoxes[index].mHeight / 2) - (playerCharacter.getHeight() / 2) - cameraY);
                }

                else if (warpBoxes[index].mDirection.ToUpper() == "RIGHT")
                {
                    cameraX += playerCharacter.getFrameWidth() - 5;

                    playerCharacter.setX(warpBoxes[index].mX + warpBoxes[index].mWidth + 5 - cameraX);

                    playerCharacter.setY(warpBoxes[index].mY + (warpBoxes[index].mHeight / 2) - (playerCharacter.getHeight() / 2) - cameraY);
                }
            }
        }