Commit c5f1d789 authored by 9731301's avatar 9731301

complete some settings

parent 81e7c71b
...@@ -8,29 +8,29 @@ ...@@ -8,29 +8,29 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0b3d586d-9f0f-4ca4-b09d-03a200e1e684" name="Default Changelist" comment=""> <list default="true" id="0b3d586d-9f0f-4ca4-b09d-03a200e1e684" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/maps/map1.txt" beforeDir="false" afterPath="$PROJECT_DIR$/maps/map1.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/registeredName/registeredList" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/registeredName/registeredList" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/RewardState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/RewardState.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/RewardState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/RewardState.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/TankState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/TankState.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState$WallData.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState$WallData.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$3.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$4.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$4.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Setting.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Setting.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/Client.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/Client.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/Server.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/Server.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/TankState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/TankState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/WallState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/WallState.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/GameState/WallState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/WallState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/Game/Rendering.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Game/Rendering.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/MainPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/MainPanel.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/LogIn/MainPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/MainPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGRendering.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGRendering.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/LogIn/SettingPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/SettingPanel.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -174,7 +174,8 @@ ...@@ -174,7 +174,8 @@
<workItem from="1596736621086" duration="2472000" /> <workItem from="1596736621086" duration="2472000" />
<workItem from="1596753755315" duration="9970000" /> <workItem from="1596753755315" duration="9970000" />
<workItem from="1596805407066" duration="11801000" /> <workItem from="1596805407066" duration="11801000" />
<workItem from="1596824371588" duration="683000" /> <workItem from="1596824371588" duration="1310000" />
<workItem from="1596884826456" duration="10887000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -182,14 +183,14 @@ ...@@ -182,14 +183,14 @@
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1596402386433"> <state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1596890904278">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1596402386433" /> <state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1596890904278" />
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1596755270557"> <state x="574" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1596888173096">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1596755270557" /> <state x="574" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1596888173096" />
<state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1596591250036"> <state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1596591250036">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -210,22 +211,22 @@ ...@@ -210,22 +211,22 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="549" y="153" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1596567968810" /> <state x="549" y="153" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1596567968810" />
<state width="1493" height="266" key="GridCell.Tab.0.bottom" timestamp="1596825061812"> <state width="1493" height="119" key="GridCell.Tab.0.bottom" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="266" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" /> <state width="1493" height="119" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="266" key="GridCell.Tab.0.center" timestamp="1596825061812"> <state width="1493" height="119" key="GridCell.Tab.0.center" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="266" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" /> <state width="1493" height="119" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="266" key="GridCell.Tab.0.left" timestamp="1596825061812"> <state width="1493" height="119" key="GridCell.Tab.0.left" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="266" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" /> <state width="1493" height="119" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="266" key="GridCell.Tab.0.right" timestamp="1596825061812"> <state width="1493" height="119" key="GridCell.Tab.0.right" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="266" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" /> <state width="1493" height="119" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state x="589" y="114" key="RollbackChangesDialog" timestamp="1595702094731"> <state x="589" y="114" key="RollbackChangesDialog" timestamp="1595702094731">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -234,10 +235,10 @@ ...@@ -234,10 +235,10 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="249" y="0" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1596591266758" /> <state x="249" y="0" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1596591266758" />
<state x="107" y="201" key="com.intellij.ide.util.TipDialog" timestamp="1596824371717"> <state x="107" y="201" key="com.intellij.ide.util.TipDialog" timestamp="1596885982849">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="107" y="201" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1596824371717" /> <state x="107" y="201" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1596885982849" />
<state x="578" y="330" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1596406077996"> <state x="578" y="330" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1596406077996">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -263,4 +264,20 @@ ...@@ -263,4 +264,20 @@
</state> </state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1595684580506" /> <state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1595684580506" />
</component> </component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java</url>
<line>80</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java</url>
<line>51</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project> </project>
\ No newline at end of file
1111111111111111111111111 11111111111111111111
1001001001001010100011001 10000100010000002001
1000002000000220001100001 10000100011100002001
1000111100011101110000001 10000100010000000001
1001100200000000010011111 11100000020000000001
1001000111000011110000001 10000000000000000001
1002000001000001000000001 11111111111111111111
1002000001000011000000001 \ No newline at end of file
1111111111111111111111111
\ No newline at end of file
1111111111111111111111111
1001001001001010100011001
1000002000000220001100001
1000111100011101110000001
1001100200000000010011111
1001000111000011110000001
1002000001000001000000001
1002000001000011000000001
1111111111111111111111111
\ No newline at end of file
...@@ -3,3 +3,5 @@ his2|pp ...@@ -3,3 +3,5 @@ his2|pp
1|1 1|1
4|4 4|4
2|2
...@@ -30,7 +30,6 @@ public class Client1 { ...@@ -30,7 +30,6 @@ public class Client1 {
this.host = address; this.host = address;
this.port = port; this.port = port;
numOfEnemies = 0; numOfEnemies = 0;
wallState = new WallState(GameFrame.GAME_WIDTH , GameFrame.GAME_HEIGHT);
} }
public void run0() throws IOException { public void run0() throws IOException {
...@@ -42,26 +41,22 @@ public class Client1 { ...@@ -42,26 +41,22 @@ public class Client1 {
public void run1wall() throws IOException { public void run1wall() throws IOException {
out.write(InitialPanel.userName.getText().getBytes()); out.write(InitialPanel.userName.getText().getBytes());
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
int read = in.read(buffer); int read = in.read(buffer);
wallMap = new String(buffer,0,read); wallMap = new String(buffer,0,read);
setWallState();
} }
public void runToUpdateTank(TankState tankState) throws IOException { public void runToUpdateTank(TankState tankState) throws IOException {
try { try {
boolean running = true;
// do {
String clientText = ""; String clientText = "";
clientText = myTankComponents(); clientText = myTankComponents();
running = !clientText.equalsIgnoreCase("over");
out.write(clientText.getBytes()); out.write(clientText.getBytes());
byte[] buffer1 = new byte[2048]; byte[] buffer1 = new byte[2048];
int read1 = in.read(buffer1); int read1 = in.read(buffer1);
serverAns = new String(buffer1, 0, read1); serverAns = new String(buffer1, 0, read1);
System.out.println("- From Server : " + serverAns); System.out.println("- From Server : " + serverAns);
// }while(running);
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
...@@ -82,10 +77,10 @@ public class Client1 { ...@@ -82,10 +77,10 @@ public class Client1 {
return numOfEnemies; return numOfEnemies;
} }
public ArrayList<EnemyTank> createEnemyTanks(){ public ArrayList<EnemyTank> createEnemyTanks() throws IOException {
ArrayList<EnemyTank> enemyTanks = new ArrayList<>(); ArrayList<EnemyTank> enemyTanks = new ArrayList<>();
for (int i = 0 ; i < getNumOfEnemies() ; i ++){ for (int i = 0 ; i < getNumOfEnemies() ; i ++){
EnemyTank enemyTank = new EnemyTank(getWallState()); EnemyTank enemyTank = new EnemyTank(wallState);
enemyTanks.add(enemyTank); enemyTanks.add(enemyTank);
} }
if (enemyTanks == null) if (enemyTanks == null)
...@@ -126,8 +121,12 @@ public class Client1 { ...@@ -126,8 +121,12 @@ public class Client1 {
return tankComponent+bulletComponent; return tankComponent+bulletComponent;
} }
public WallState getWallState() { private void setWallState() throws IOException {
wallState = new WallState(GameFrame.GAME_WIDTH , GameFrame.GAME_HEIGHT);
wallState.setSource(wallMap); wallState.setSource(wallMap);
}
public WallState getWallState() {
return wallState; return wallState;
} }
} }
...@@ -3,3 +3,5 @@ his2|pp ...@@ -3,3 +3,5 @@ his2|pp
1|1 1|1
4|4 4|4
2|2
...@@ -61,7 +61,7 @@ public class RewardState { ...@@ -61,7 +61,7 @@ public class RewardState {
public int chooseRandomReward(){ public int chooseRandomReward(){
Random random = new Random(); Random random = new Random();
int x = random.nextInt(5); int x = random.nextInt(3);
return x; return x;
} }
...@@ -77,11 +77,11 @@ public class RewardState { ...@@ -77,11 +77,11 @@ public class RewardState {
case 1: case 1:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\heart.png"));break; reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\heart.png"));break;
case 2: case 2:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullet.png"));break; reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\laser.png"));break;
case 3: case 3:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullets.png"));break; reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullets.png"));break;
case 4: case 4:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\laser.png"));break; reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullet.png"));break;
} }
rewardImage = reward.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); rewardImage = reward.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
return rewardImage; return rewardImage;
...@@ -93,9 +93,9 @@ public class RewardState { ...@@ -93,9 +93,9 @@ public class RewardState {
switch (numOfReward) { switch (numOfReward) {
case 0:shield(tankState);break; case 0:shield(tankState);break;
case 1:extraLife(tankState);break; case 1:extraLife(tankState);break;
case 2:extraBulletDamage(tankState);break; case 2:laser(tankState);break;
case 3:extraBulletDamage2(tankState);break; case 3:extraBulletDamage2(tankState);break;
case 4:laser(tankState);break; case 4:extraBulletDamage(tankState);break;
} }
} }
......
package UI.GameState; package UI.GameState;
import UI.LogIn.MainPanel;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
...@@ -8,6 +10,7 @@ import java.nio.charset.StandardCharsets; ...@@ -8,6 +10,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
public class WallState { public class WallState {
...@@ -27,7 +30,8 @@ public class WallState { ...@@ -27,7 +30,8 @@ public class WallState {
frameY = GAME_HEIGHT; frameY = GAME_HEIGHT;
try { try {
source = new String(Files.readAllBytes(Paths.get(source)), StandardCharsets.UTF_8); if (MainPanel.singlePlay)
setSource(findMapPath());
wall1 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall1.png")); wall1 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall1.png"));
wall2 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall2.png")); wall2 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall2.png"));
blank = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\blank.png")); blank = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\blank.png"));
...@@ -137,8 +141,19 @@ public class WallState { ...@@ -137,8 +141,19 @@ public class WallState {
return false; return false;
} }
public void setSource(String source) { public String findMapPath(){
this.source = source; Random random = new Random();
int x = random.nextInt(2);
System.out.println(x);
switch (x){
case 0:return "C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\maps\\map1.txt";
case 1:return "C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\maps\\map3.txt";
}
return null;
}
public void setSource(String mapPath) throws IOException {
source = new String(Files.readAllBytes(Paths.get(mapPath)), StandardCharsets.UTF_8);
} }
public ArrayList<WallData> getWalls() { public ArrayList<WallData> getWalls() {
......
package UI.LogIn.Game; package UI.LogIn.Game;
import UI.GameState.*; import UI.GameState.*;
import UI.LogIn.MainPanel;
import UI.LogIn.Setting; import UI.LogIn.Setting;
import UI.LogIn.SettingPanel;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
...@@ -22,7 +25,7 @@ public class Rendering { ...@@ -22,7 +25,7 @@ public class Rendering {
int lastRender = -1; int lastRender = -1;
private ArrayList<Float> fpsHistory; private ArrayList<Float> fpsHistory;
private ArrayList<RewardState> rewards = new ArrayList<>(); private ArrayList<RewardState> rewards = new ArrayList<>();
private Setting setting = new Setting(); private boolean flag = true;
public Rendering(){ public Rendering(){
fpsHistory = new ArrayList<>(100); fpsHistory = new ArrayList<>(100);
...@@ -40,7 +43,7 @@ public class Rendering { ...@@ -40,7 +43,7 @@ public class Rendering {
// Draw my tank; // Draw my tank;
try { try {
image1 = ImageIO.read(new File(setting.getTankShapePath())); image1 = ImageIO.read(new File(SettingPanel.setting.getTankShapePath()));
} catch (IOException e) { } catch (IOException e) {
System.out.println(e); System.out.println(e);
} }
...@@ -149,9 +152,14 @@ public class Rendering { ...@@ -149,9 +152,14 @@ public class Rendering {
g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), myTank.locX, myTank.locY, null); g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), myTank.locX, myTank.locY, null);
myTank.setTankLife(0); myTank.setTankLife(0);
myTank.gameOver = true; myTank.gameOver = true;
if (flag) {
System.out.println(MainPanel.startTimeForSetting + "********"+ System.currentTimeMillis());
SettingPanel.setting.updateSettingAfterASingleGame(MainPanel.startTimeForSetting, System.currentTimeMillis(), false);
System.out.println(MainPanel.startTimeForSetting + "********"+ System.currentTimeMillis());
flag = false;
}
} }
} else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) { } else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) {
System.out.println("has ");
myTank.setHasMoreLife(false); myTank.setHasMoreLife(false);
if (myTank.getTankLife() > 100) if (myTank.getTankLife() > 100)
myTank.setTankLife(myTank.getTankLife() - 10); myTank.setTankLife(myTank.getTankLife() - 10);
...@@ -169,6 +177,9 @@ public class Rendering { ...@@ -169,6 +177,9 @@ public class Rendering {
g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), enemyTank.locX, enemyTank.locY, null); g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), enemyTank.locX, enemyTank.locY, null);
enemyTank.setTankLife(0); enemyTank.setTankLife(0);
enemyTank.gameOver = true; enemyTank.gameOver = true;
if (flag){
SettingPanel.setting.updateSettingAfterASingleGame(MainPanel.startTimeForSetting , System.currentTimeMillis() ,true);}
flag = false;
} }
} }
} }
......
...@@ -20,6 +20,8 @@ import java.net.UnknownHostException; ...@@ -20,6 +20,8 @@ import java.net.UnknownHostException;
public class MainPanel extends JPanel { public class MainPanel extends JPanel {
private Image image; private Image image;
public static boolean singlePlay;
public static long startTimeForSetting;
public MainPanel() throws IOException { public MainPanel() throws IOException {
image = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\index.png")); image = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\index.png"));
...@@ -48,6 +50,9 @@ public class MainPanel extends JPanel { ...@@ -48,6 +50,9 @@ public class MainPanel extends JPanel {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
singlePlay =true;
long x = System.currentTimeMillis();
startTimeForSetting = x ;
run(); run();
} }
...@@ -60,6 +65,7 @@ public class MainPanel extends JPanel { ...@@ -60,6 +65,7 @@ public class MainPanel extends JPanel {
Client1 client1 = null; Client1 client1 = null;
try { try {
client1 = new Client1(InetAddress.getLocalHost().getHostName(),5001); client1 = new Client1(InetAddress.getLocalHost().getHostName(),5001);
startTimeForSetting =System.currentTimeMillis();
run2(client1); run2(client1);
} catch (UnknownHostException ex) { } catch (UnknownHostException ex) {
ex.printStackTrace(); ex.printStackTrace();
...@@ -133,9 +139,7 @@ public class MainPanel extends JPanel { ...@@ -133,9 +139,7 @@ public class MainPanel extends JPanel {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("222222 after init");
ThreadPool.execute(game); ThreadPool.execute(game);
System.out.println("after thearsd");
// and the game starts ... // and the game starts ...
} }
}); });
......
...@@ -47,8 +47,9 @@ import java.util.ArrayList; ...@@ -47,8 +47,9 @@ import java.util.ArrayList;
*/ */
public void init() throws IOException { public void init() throws IOException {
// Perform all initializations ... // Perform all initializations ...
myTank = new MyTank(client1.getWallState());
client1.run1wall(); client1.run1wall();
System.out.println(client1.getWallState());
myTank = new MyTank(client1.getWallState());
client1.runToUpdateTank(myTank); client1.runToUpdateTank(myTank);
enemyTanks = client1.createEnemyTanks(); enemyTanks = client1.createEnemyTanks();
canvas.addKeyListener(myTank.getMyListener()); canvas.addKeyListener(myTank.getMyListener());
......
...@@ -3,6 +3,7 @@ package UI.LogIn.NetWorkGame; ...@@ -3,6 +3,7 @@ package UI.LogIn.NetWorkGame;
import Server_Client.NetWorkGame.Client1; import Server_Client.NetWorkGame.Client1;
import UI.GameState.*; import UI.GameState.*;
import UI.LogIn.Game.GameLoop; import UI.LogIn.Game.GameLoop;
import UI.LogIn.MainPanel;
import UI.LogIn.Setting; import UI.LogIn.Setting;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
...@@ -157,7 +158,6 @@ public class NWGRendering { ...@@ -157,7 +158,6 @@ public class NWGRendering {
myTank.gameOver = true; myTank.gameOver = true;
} }
} else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) { } else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) {
System.out.println("has ");
myTank.setHasMoreLife(false); myTank.setHasMoreLife(false);
if (myTank.getTankLife() > 100) if (myTank.getTankLife() > 100)
myTank.setTankLife(myTank.getTankLife() - 10); myTank.setTankLife(myTank.getTankLife() - 10);
......
...@@ -6,7 +6,7 @@ import javax.swing.*; ...@@ -6,7 +6,7 @@ import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
public class Setting { public class Setting {
private float playedTime = 0; private long playedTime = 0;
private String userName = InitialPanel.userName.getText() ; private String userName = InitialPanel.userName.getText() ;
private int numOfWinsSingle = 0; private int numOfWinsSingle = 0;
private int numOfLoosesSingle = 0; private int numOfLoosesSingle = 0;
...@@ -19,13 +19,14 @@ public class Setting { ...@@ -19,13 +19,14 @@ public class Setting {
private ArrayList<String> urls = new ArrayList<>(); private ArrayList<String> urls = new ArrayList<>();
public void updateSettingAfterASingleGame(float startTime , float endTime , boolean isWin ){ public void updateSettingAfterASingleGame(long startTime , long endTime , boolean isWin ){
System.out.println(endTime +" "+ startTime);
playedTime += endTime - startTime ; playedTime += endTime - startTime ;
if (isWin)numOfWinsSingle++; if (isWin)numOfWinsSingle++;
else numOfLoosesSingle++; else numOfLoosesSingle++;
} }
public void updateSettingAfterAMultiGame(float startTime , float endTime , boolean isWin ){ public void updateSettingAfterAMultiGame(long startTime , long endTime , boolean isWin ){
playedTime += endTime - startTime ; playedTime += endTime - startTime ;
if (isWin)numOfWinsMulti++; if (isWin)numOfWinsMulti++;
else numOfLoosesMulti++; else numOfLoosesMulti++;
...@@ -40,7 +41,7 @@ public class Setting { ...@@ -40,7 +41,7 @@ public class Setting {
return numOfLoosesMulti; return numOfLoosesMulti;
} }
public float getPlayedTime() { public long getPlayedTime() {
return playedTime; return playedTime;
} }
......
...@@ -12,7 +12,7 @@ import java.io.IOException; ...@@ -12,7 +12,7 @@ import java.io.IOException;
public class SettingPanel extends JPanel { public class SettingPanel extends JPanel {
private Setting setting = new Setting(); public static Setting setting = new Setting();
private String chosenTankPath ="C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\tank_blue.png"; private String chosenTankPath ="C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\tank_blue.png";
private Image image; private Image image;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment