/** * Spawn a character on the map * * @param MiX Minimum X value * @param MiY Minimum Y value * @param MaX Maximum X value * @param MaY Maximum Y value */ public void Spawn(int MiX, int MiY, int MaX, int MaY) { double Nx = 0, Ny = 0; // Random coordinate Nx = Math.random() * MaX + MiX; Ny = Math.random() * MaY + MiY; // Store block number int BNum = MAP.elementAt(0).getBlockNum(Nx + W / 2, Ny + H / 2); // if invalid block number if (BNum == -1) { Spawn(MiX, MiY, MaX, MaY); } // if invalid surface else if (!isValidSurface(MAP.elementAt(0).Fill[BNum])) { Spawn(MiX, MiY, MaX, MaY); } // if colliding with something else if (this.Collision(Nx + W / 2, Ny + H / 2)) { Spawn(MiX, MiY, MaX, MaY); } else { X = Nx; Y = Ny; } }
public void CompleteQuest(int Index) { Quest qstComp = QUEST_LIST.elementAt(Index); qstComp.STATUS = 3; qstComp.QUEST_GIVER.QUEST_LIST.elementAt(0).STATUS = 3; qstComp.QUEST_GIVER.QUEST_LIST.removeElementAt(0); STATS.IncreaseXP(qstComp.XP); GOLD += qstComp.GOLD; }
/** * Check character collision with all kinds of objects * * @param x X Coordinate * @param y Y Coordinate * @return if Character is about to collide with something */ public boolean Collision(double x, double y) { boolean blnCol = false; // Wall Collision for (int i = 0; i < MAP.size(); i++) { blnCol = blnCol || WallCollision(x, y, MAP.elementAt(i)); } // Game Object Collision for (int i = 0; i < OBJECTS.size(); i++) { blnCol = blnCol || ObjectCollision(x, y, OBJECTS.elementAt(i)); } // Game Character collision for (int i = 0; i < CHARACTERS.size(); i++) { blnCol = blnCol || CharacterCollision(x, y, CHARACTERS.elementAt(i)); } // Game Building Collision for (int i = 0; i < BUILD.size(); i++) { blnCol = blnCol || BuildingCollision(x, y, BUILD.elementAt(i)); } return blnCol; }
/** * Used for debugging get list of spells available to character * * @return List */ public String[] getSpellList() { // Make Array String[] arg = new String[SPELL_LIST.size()]; // Assign names for (int i = 0; i < arg.length; i++) { arg[i] = SPELL_LIST.elementAt(i)[0].NAME; System.out.println(arg[i]); } // Return list return arg; }
/** * Draw character in game window * * @param g Graphics * @param Dx X Displacement * @param Dy Y Displacement * @param G Growth factor */ public void Draw(Graphics g, int Dx, int Dy, double G) { // Draw blood if (ISDEAD) { g.drawImage( imgBLOOD, (int) (X + Dx - 25), (int) (Y + Dy - 15), (int) (W * GROWTHFACTOR + 35), (int) (H * GROWTHFACTOR + 35), null); } // Quest Givers if (CLASS != "Player") { for (int i = 0; i < QUEST_LIST.size(); i++) { if (QUEST_LIST.elementAt(i).STATUS == 0) { g.drawImage(imgQStart, (int) (X + Dx + 5), (int) (Y + Dy - 30), (int) W, 35, null); } else if (QUEST_LIST.elementAt(i).STATUS == 2) { g.drawImage(imgQEnd, (int) (X + Dx), (int) (Y + Dy - 30), (int) W + 5, 35, null); } } } // Draw character g.drawImage( imgCHARAC, (int) (X + Dx), (int) (Y + Dy), (int) (X + Dx + W * G), (int) (Y + Dy + H * G), (int) (W * FX), (int) (H * FY), (int) (W * FX + W), (int) (H * FY + H), null); GROWTHFACTOR = G; }
public void giveQuest(GameCharacter Reciever) { if (QUEST_LIST.size() > 0) { if (QUEST_LIST.elementAt(0).STATUS == 0) { Reciever.QUEST_LIST.add(QUEST_LIST.elementAt(0)); QUEST_LIST.elementAt(0).play_UpdateSound(); if (QUEST_LIST.elementAt(0).QTYPE == Quest_Type.DELIVERY) { for (int i = 0; i < QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_NAME.size(); i++) { Reciever.INVENTORY.addItem( QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_NAME.elementAt(i), QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_PRICE.elementAt(i), QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_QUANTITY.elementAt(i), QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_IMAGE.elementAt(i), QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_TAG.elementAt(i), QUEST_LIST.elementAt(0).TARGET_LIST.STATS.elementAt(i)); } } QUEST_LIST.elementAt(0).STATUS = 1; } } }