Skip to content

Gavin l #33

Merged
merged 5 commits into from
Apr 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MerchantRPGCSE2102/src/config/instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testing Instructions file
24 changes: 23 additions & 1 deletion MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

Expand All @@ -11,6 +12,7 @@
import model.Merchant;
import model.Player;
import view.MapUI;
import view.StartScreen;

public class RPGame {

Expand Down Expand Up @@ -40,6 +42,7 @@ public class RPGame {
public boolean _movement = true;
private int _currentDay;
private int _transactionLimit;
public boolean _initialGameVariable;


public RPGame(int transactionLimit, int tileSize) {
Expand All @@ -59,6 +62,21 @@ public RPGame(int transactionLimit, int tileSize) {
buildMerchants();
buildPlayer("test", 500);

// Initialize the start screen
_initialGameVariable = false;

try {
createStartScreen(this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

while(_initialGameVariable == false)
{
System.out.println("In Loop");
}

// Initialiing Map instance and adding the player and merchants to the map
map = new Map(rows, cols);
map.initializePlayer(_player, rows/2, cols/2);
Expand Down Expand Up @@ -132,7 +150,7 @@ else if (currentMerchant == 3)
*/
public void buildMerchants()
{
_merchant1 = new Merchant("Cheap Merchant", 200, merchantInventoryList1, 0);
_merchant1 = new Merchant("Cheap Merchant", 300, merchantInventoryList1, 0);
_merchant2 = new Merchant("Medium Merchant", 600, merchantInventoryList2, merchantInventoryList1.size());
_merchant3 = new Merchant("Expensive Merchant", 1000, merchantInventoryList3, merchantInventoryList1.size()+ merchantInventoryList2.size());
}
Expand Down Expand Up @@ -197,6 +215,10 @@ public void createTransaction(Player player, Merchant targetMerchant)
}
}

public void createStartScreen(RPGame game) throws IOException
{
StartScreen newStartScreen = new StartScreen(game);
}

/**
* Will refresh number of transactions the Player has available
Expand Down
11 changes: 11 additions & 0 deletions MerchantRPGCSE2102/src/model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,15 @@ public int getPlayerCash()
{
return _playerCash;
}

/**
* Setter for player name
*
* @param playerName Name of the player
*/
public void setPlayerName(String playerName)
{
_name = playerName;
}

}
51 changes: 31 additions & 20 deletions MerchantRPGCSE2102/src/view/StartScreen.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
package view;

import java.awt.*;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

public class StartScreen extends JFrame {
import controller.RPGame;
import model.Player;

private static final long serialVersionUID = 1L;
@SuppressWarnings("serial")
public class StartScreen extends JFrame {

JPanel startMenu = new JPanel();
RPGame _master;

public StartScreen(RPGame master) throws IOException {


public static void main(String[] args) throws IOException {
new StartScreen();
}

public StartScreen() throws IOException {

_master = master;
JLabel MainMenuBG = new JLabel(new ImageIcon("src/images/background.jpg"));
MainMenuBG.setVisible(true);
Image icon, background;
Expand All @@ -47,18 +42,30 @@ public StartScreen() throws IOException {
JButton start = new JButton("Start");
start.setVisible(true);

start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
start.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent arg0) {
System.out.println("Game started");
_master._initialGameVariable = true;
exitWindow();

}
});

JButton instructions = new JButton("Instructions");
instructions.setVisible(true);

instructions.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
instructions.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent arg0) {
System.out.println("Instructions opened");
ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "src/config/instructions.txt");
try {
pb.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

Expand Down Expand Up @@ -94,5 +101,9 @@ public BufferedImage loadBackground() throws IOException {
return null;
}
}


public void exitWindow()
{
this.dispose();
}
}