public LLEMessageBalloon(float x, float y, Texture2D texture, Texture2D balloonPointer, SpriteFont font, LLEMapFrontLayer frontLayer) { mText = ""; mBalloonPointer = balloonPointer; mBalloon = null; mBalloon = new LLESprite(x, y, 0, 0, 0); mBalloon.setTexture(texture); mIcon = null; mFont = font; mTextLines = new List<string>(); mEventMsg = false; mTextColor = new Color(210, 105, 0); mWindowWidth = frontLayer.getWindowWidth(); mWindowHeight = frontLayer.getWindowHeight(); }
public void accessObject(LLESprite playerCharacter, KeyboardState keyboardState, KeyboardState prevKeyboardState) { mPlayerCharacter = playerCharacter; if (playerCharacter != null && (playerCharacter.getDirection() == LLESprite.DIRECTION_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT_UP) && keyboardState.IsKeyDown(Keys.Z) == true && prevKeyboardState.IsKeyDown(Keys.Z) == false) { for (int i = 0; i < mapObjects.Count; i++) { if (mapObjects[i] != null && mapObjects[i].getSprite() != null) { LLESprite target = mapObjects[i].getSprite(); if (playerCharacter.isCollidingMap(new Vector4(target.getX(), target.getY(), target.getHeight(), target.getWidth()), new Vector2(cameraX, cameraY), false, true, 4) == true) { scriptProcessor.extractObjectVariables(mapObjects[i]); attack = false; break; } } } } }
public LLEEnemy(string name, int hp, Vector2 position, Assets assets) { mName = name; mHP = hp; mSprite = new LLESprite(position.X, position.Y, 0, 0, 0); mSprite.setTexture(assets.getTexture(mName)); mSprite.setTextureName(mName); }
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(); } }
public LLEObject(float x, float y) { mName = mScriptName = "NONE"; mSprite = new LLESprite(x, y, 0, 0, 0); mIsItem = false; mEnabled = true; mDestroyable = false; mCollide = true; }
public LLEMapFrontLayer(Assets theAssets, string saveSlotName, int windowWidth, int windowHeight) { assets = theAssets; mapObjects = null; mapObjects = new List<LLEObject>(); playerInventory = new List<LLEObject>(); mapEnemies = new List<LLEEnemy>(); msgManager = null; mPlayerCharacter = null; mSaveSlotName = saveSlotName; mWindowWidth = windowWidth; mWindowHeight = windowHeight; }
public void tryDestroyObjects(LLESprite playerCharacter) { for (int i = 0; i < mapObjects.Count; i++) { bool collided = playerCharacter.isCollidingMap(new Vector4(mapObjects[i].getSprite().getX(), mapObjects[i].getSprite().getY(), mapObjects[i].getSprite().getHeight(), mapObjects[i].getSprite().getWidth()), new Vector2(cameraX, cameraY), true, true, 1); if (mapObjects[i].isDestroyable() == true && collided == true) { mapObjects[i].release(); mapObjects[i] = null; mapObjects.RemoveAt(i); i = -1; } } }
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); } } }
public void doCharacterAttack(LLESprite playerCharacter) { if (attack) { playerCharacter.stopAnimation(); if (playerCharacter.getDirection() == LLESprite.DIRECTION_DOWN) { playerCharacter.startAnimation(32, 35); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT) { playerCharacter.startAnimation(36, 39); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_UP) { playerCharacter.startAnimation(40, 43); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT) { playerCharacter.startAnimation(44, 47); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT_UP) { playerCharacter.startAnimation(48, 51); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT_UP) { playerCharacter.startAnimation(52, 55); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT_DOWN) { playerCharacter.startAnimation(56, 59); } else if (playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT_DOWN) { playerCharacter.startAnimation(60, 63); } } attack = true; }
public void checkObjectCollision(LLESprite playerCharacter, LLEPlayerData playerData, KeyboardState keyboardState, KeyboardState prevKeyboardState) { mPlayerCharacter = playerCharacter; for (int i = 0; i < mapObjects.Count; i++) { if (mapObjects[i] != null && mapObjects[i].getSprite() != null && mapObjects[i].getSprite().isVisible()) { LLESprite target = mapObjects[i].getSprite(); if (mapObjects[i].isColliding() == true && playerCharacter.isCollidingMap(new Vector4(target.getX(), target.getY(), target.getHeight(), target.getWidth()), new Vector2(cameraX, cameraY), true, true, 4) == true) { if ((playerCharacter.getDirection() == LLESprite.DIRECTION_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT_UP) && keyboardState.IsKeyDown(Keys.Z) == true && prevKeyboardState.IsKeyDown(Keys.Z) == false) { if (mapObjects[i].getScriptName().Replace("NONE", "" ).Replace(" ", "") != "") { playerCharacter.setAttacking(false); scriptProcessor.extractObjectVariables(mapObjects[i]); scriptProcessor.executeScript(msgManager, playerData); } break; } } } } }
public void release() { mBalloon = null; }
public void setSprite(LLESprite sprite) { mSprite = sprite; }
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); } } }
public virtual LLESprite clone() { LLESprite theSprite = new LLESprite(mX, mY, mXVel, mYVel, mSpeed); theSprite.setTexture(mTexture); theSprite.setTextureName(mTextureName); theSprite.setWidth(mW); theSprite.setHeight(mH); theSprite.setRotation(mRotation); theSprite.setRotationSpeed(mRotationSpeed); theSprite.setTextureColor(mTextureColor); theSprite.setVisible(mVisible); return theSprite; }
public void setGridTile(int tileX, int tileY, string tileTexture, int layer) { if (layer == 1) { tileGrid[tileX, tileY] = new LLESprite(0, 0, 0, 0, 0); tileGrid[tileX, tileY].setTexture(assets.getTexture(tileTexture)); tileGrid[tileX, tileY].setTextureName(tileTexture); } else { tileGrid2[tileX, tileY] = new LLESprite(0, 0, 0, 0, 0); tileGrid2[tileX, tileY].setTexture(assets.getTexture(tileTexture)); tileGrid2[tileX, tileY].setTextureName(tileTexture); } }
public int checkWarpCollision(LLESprite playerCharacter) { List<LLEWarpBox> rectangles = warpBoxes; for (int i = 0; i < rectangles.Count; i++) { if (playerCharacter.isCollidingMap(new Vector4(rectangles[i].mX, rectangles[i].mY, rectangles[i].mHeight, rectangles[i].mWidth), new Vector2(cameraX, cameraY), true, true, 4) == true) { return i; } } return -1; }
public void checkBoxCollision(LLESprite playerCharacter) { List<LLERect> rectangles = collisionBoxes; for (int i = 0; i < rectangles.Count; i++) { if (rectangles[i] != null && playerCharacter != null) { playerCharacter.isCollidingMap(new Vector4(rectangles[i].mX, rectangles[i].mY, rectangles[i].mHeight, rectangles[i].mWidth), new Vector2(cameraX, cameraY), true, true, 4); } } }
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); } } }
public void setFocusEntity(string entityName) { focusEntity = mFrontLayer.getTargetEntity(entityName); }
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; }
public void release() { mSprite = null; }