Ejemplo n.º 1
0
        public bool collide(LLESprite target, float offsetX, float offsetY)
        {
            if(target != null)
            {
                float targetX = target.getX();

                float targetY = target.getY();

                float targetW = target.getWidth();

                float targetH = target.getHeight();

                int theWidth = mW;

                if (mAnimating)
                {
                    theWidth = getFrameWidth();
                }

                if (mX + theWidth >= targetX + offsetX && mX <= targetX + targetW - offsetX &&

                   mY + mH >= targetY + offsetY && mY <= targetY + targetH - offsetY)
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 2
0
        public void alignCamera(GameTime gameTime, LLESprite playerCharacter, LLESprite partnerCharacter, Vector2 windowSize)
        {
            if ((mCameraVelocityX < 0.0f && cameraX < mCameraDestX) || (mCameraVelocityX > 0.0f && cameraX > mCameraDestX))
            {
                cameraX = mCameraDestX;

                mCameraVelocityX = 0.0f;
            }

            if ((mCameraVelocityY < 0.0f && cameraY < mCameraDestY) || (mCameraVelocityY > 0.0f && cameraY > mCameraDestY))
            {
                cameraY = mCameraDestY;

                mCameraVelocityY = 0.0f;
            }

            if (mCameraVelocityX == 0.0f && mCameraVelocityY == 0.0f)
            {
                mAlignCamera = false;

                playerCharacter.setXVel(0.0f);

                playerCharacter.setYVel(0.0f);

                partnerCharacter.setXVel(0.0f);

                partnerCharacter.setYVel(0.0f);

                return;
            }

            cameraX += (gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityX;

            cameraY += (gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityY;

            //Move playerCharacter and partnerCharacter

            playerCharacter.setX(playerCharacter.getX() - ((gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityX));

            playerCharacter.setY(playerCharacter.getY() - ((gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityY));

            playerCharacter.updateRectangle();

            if (partnerCharacter != null && partnerCharacter.isVisible())
            {
                partnerCharacter.setX(partnerCharacter.getX() - ((gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityX));

                partnerCharacter.setY(partnerCharacter.getY() - ((gameTime.ElapsedGameTime.Ticks / 100000.0f) * mCameraVelocityY));

                partnerCharacter.updateRectangle();
            }
        }
Ejemplo n.º 3
0
 public void triggerEnemyAppearal(LLESprite playerCharacter)
 {
     for (int i = 0; i < mapEnemies.Count; i++)
     {
         if (!mapEnemies[i].getSprite().isVisible() && (((mapEnemies[i].getSprite().getX() - cameraX) < playerCharacter.getX() && playerCharacter.getX() - (mapEnemies[i].getSprite().getX() - cameraX) < 250) || ((mapEnemies[i].getSprite().getX() - cameraX) > playerCharacter.getX() && (mapEnemies[i].getSprite().getX() - cameraX) - playerCharacter.getX() < 250))
             && (((mapEnemies[i].getSprite().getY() - cameraY) < playerCharacter.getY() && playerCharacter.getY() - (mapEnemies[i].getSprite().getY() - cameraY) < 250) || ((mapEnemies[i].getSprite().getY() - cameraY) > playerCharacter.getY() && (mapEnemies[i].getSprite().getY() - cameraY) - playerCharacter.getY() < 250)))
         {
             mapEnemies[i].getSprite().setVisible(true);
         }
     }
 }
Ejemplo n.º 4
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);
                }
            }
        }