diff --git a/.project b/.project index 7528829..b35e96c 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - Exploration V3.6.0 + Exploration Server V1.0.0 diff --git a/bin/calculate/Bag$AItemNode.class b/bin/calculate/Bag$AItemNode.class deleted file mode 100644 index aa23e95..0000000 Binary files a/bin/calculate/Bag$AItemNode.class and /dev/null differ diff --git a/bin/calculate/Bag$Dictionary.class b/bin/calculate/Bag$Dictionary.class deleted file mode 100644 index 067d0bf..0000000 Binary files a/bin/calculate/Bag$Dictionary.class and /dev/null differ diff --git a/bin/calculate/Bag.class b/bin/calculate/Bag.class deleted file mode 100644 index 47bf690..0000000 Binary files a/bin/calculate/Bag.class and /dev/null differ diff --git a/bin/calculate/ChangeableItemList$ChangeableItemNode.class b/bin/calculate/ChangeableItemList$ChangeableItemNode.class deleted file mode 100644 index b7f9de9..0000000 Binary files a/bin/calculate/ChangeableItemList$ChangeableItemNode.class and /dev/null differ diff --git a/bin/calculate/ChangeableItemList.class b/bin/calculate/ChangeableItemList.class deleted file mode 100644 index 0775ed9..0000000 Binary files a/bin/calculate/ChangeableItemList.class and /dev/null differ diff --git a/bin/calculate/Constant.class b/bin/calculate/Constant.class deleted file mode 100644 index 3f5fdac..0000000 Binary files a/bin/calculate/Constant.class and /dev/null differ diff --git a/bin/calculate/Door.class b/bin/calculate/Door.class deleted file mode 100644 index 31e6b9e..0000000 Binary files a/bin/calculate/Door.class and /dev/null differ diff --git a/bin/calculate/FoodCalculator$Array.class b/bin/calculate/FoodCalculator$Array.class deleted file mode 100644 index f28b5ee..0000000 Binary files a/bin/calculate/FoodCalculator$Array.class and /dev/null differ diff --git a/bin/calculate/FoodCalculator$Node.class b/bin/calculate/FoodCalculator$Node.class deleted file mode 100644 index 49a06bc..0000000 Binary files a/bin/calculate/FoodCalculator$Node.class and /dev/null differ diff --git a/bin/calculate/FoodCalculator$Stack.class b/bin/calculate/FoodCalculator$Stack.class deleted file mode 100644 index 0e92057..0000000 Binary files a/bin/calculate/FoodCalculator$Stack.class and /dev/null differ diff --git a/bin/calculate/FoodCalculator.class b/bin/calculate/FoodCalculator.class deleted file mode 100644 index 0cf4124..0000000 Binary files a/bin/calculate/FoodCalculator.class and /dev/null differ diff --git a/bin/calculate/FoodDictionary.class b/bin/calculate/FoodDictionary.class deleted file mode 100644 index 212894f..0000000 Binary files a/bin/calculate/FoodDictionary.class and /dev/null differ diff --git a/bin/calculate/LinkQueue$QueueNode.class b/bin/calculate/LinkQueue$QueueNode.class deleted file mode 100644 index b5a5cc8..0000000 Binary files a/bin/calculate/LinkQueue$QueueNode.class and /dev/null differ diff --git a/bin/calculate/LinkQueue.class b/bin/calculate/LinkQueue.class deleted file mode 100644 index cb921c5..0000000 Binary files a/bin/calculate/LinkQueue.class and /dev/null differ diff --git a/bin/calculate/MyData.class b/bin/calculate/MyData.class deleted file mode 100644 index 57f0152..0000000 Binary files a/bin/calculate/MyData.class and /dev/null differ diff --git a/bin/calculate/PathSearcher$Arr.class b/bin/calculate/PathSearcher$Arr.class deleted file mode 100644 index cde80b9..0000000 Binary files a/bin/calculate/PathSearcher$Arr.class and /dev/null differ diff --git a/bin/calculate/PathSearcher$MinHeap.class b/bin/calculate/PathSearcher$MinHeap.class deleted file mode 100644 index 1577068..0000000 Binary files a/bin/calculate/PathSearcher$MinHeap.class and /dev/null differ diff --git a/bin/calculate/PathSearcher$Node.class b/bin/calculate/PathSearcher$Node.class deleted file mode 100644 index 1ba1e74..0000000 Binary files a/bin/calculate/PathSearcher$Node.class and /dev/null differ diff --git a/bin/calculate/PathSearcher$PriorityQueue.class b/bin/calculate/PathSearcher$PriorityQueue.class deleted file mode 100644 index 007c3a0..0000000 Binary files a/bin/calculate/PathSearcher$PriorityQueue.class and /dev/null differ diff --git a/bin/calculate/PathSearcher$S.class b/bin/calculate/PathSearcher$S.class deleted file mode 100644 index a57c88c..0000000 Binary files a/bin/calculate/PathSearcher$S.class and /dev/null differ diff --git a/bin/calculate/PathSearcher.class b/bin/calculate/PathSearcher.class deleted file mode 100644 index 756ca18..0000000 Binary files a/bin/calculate/PathSearcher.class and /dev/null differ diff --git a/bin/calculate/Room$RoomImage.class b/bin/calculate/Room$RoomImage.class deleted file mode 100644 index 0e41665..0000000 Binary files a/bin/calculate/Room$RoomImage.class and /dev/null differ diff --git a/bin/calculate/Room.class b/bin/calculate/Room.class deleted file mode 100644 index 4176b2b..0000000 Binary files a/bin/calculate/Room.class and /dev/null differ diff --git a/bin/main/ServerFrame$1.class b/bin/main/ServerFrame$1.class new file mode 100644 index 0000000..663cb5f Binary files /dev/null and b/bin/main/ServerFrame$1.class differ diff --git a/bin/main/ServerFrame$1serverAcceptThread.class b/bin/main/ServerFrame$1serverAcceptThread.class new file mode 100644 index 0000000..aa2640c Binary files /dev/null and b/bin/main/ServerFrame$1serverAcceptThread.class differ diff --git a/bin/main/ServerFrame$2.class b/bin/main/ServerFrame$2.class new file mode 100644 index 0000000..039f568 Binary files /dev/null and b/bin/main/ServerFrame$2.class differ diff --git a/bin/main/ServerFrame$ReaderThread.class b/bin/main/ServerFrame$ReaderThread.class new file mode 100644 index 0000000..08dbbc6 Binary files /dev/null and b/bin/main/ServerFrame$ReaderThread.class differ diff --git a/bin/main/ServerFrame.class b/bin/main/ServerFrame.class new file mode 100644 index 0000000..4a3099e Binary files /dev/null and b/bin/main/ServerFrame.class differ diff --git a/bin/main/Start.class b/bin/main/Start.class deleted file mode 100644 index 1876ca6..0000000 Binary files a/bin/main/Start.class and /dev/null differ diff --git a/bin/service/CreateRoomLAN$1serverAcceptThread.class b/bin/service/CreateRoomLAN$1serverAcceptThread.class deleted file mode 100644 index 416e61b..0000000 Binary files a/bin/service/CreateRoomLAN$1serverAcceptThread.class and /dev/null differ diff --git a/bin/service/CreateRoomLAN$ReaderThread$1.class b/bin/service/CreateRoomLAN$ReaderThread$1.class deleted file mode 100644 index bfc56ec..0000000 Binary files a/bin/service/CreateRoomLAN$ReaderThread$1.class and /dev/null differ diff --git a/bin/service/CreateRoomLAN$ReaderThread.class b/bin/service/CreateRoomLAN$ReaderThread.class deleted file mode 100644 index 2bfb126..0000000 Binary files a/bin/service/CreateRoomLAN$ReaderThread.class and /dev/null differ diff --git a/bin/service/CreateRoomLAN$WriterThread.class b/bin/service/CreateRoomLAN$WriterThread.class deleted file mode 100644 index 7d3cc08..0000000 Binary files a/bin/service/CreateRoomLAN$WriterThread.class and /dev/null differ diff --git a/bin/service/CreateRoomLAN.class b/bin/service/CreateRoomLAN.class deleted file mode 100644 index 8593c13..0000000 Binary files a/bin/service/CreateRoomLAN.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN$1.class b/bin/service/CreateRoomWAN$1.class deleted file mode 100644 index b67e4ac..0000000 Binary files a/bin/service/CreateRoomWAN$1.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN$1serverAcceptThread.class b/bin/service/CreateRoomWAN$1serverAcceptThread.class deleted file mode 100644 index 85e2aa2..0000000 Binary files a/bin/service/CreateRoomWAN$1serverAcceptThread.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN$ReaderThread$1.class b/bin/service/CreateRoomWAN$ReaderThread$1.class deleted file mode 100644 index 304ee80..0000000 Binary files a/bin/service/CreateRoomWAN$ReaderThread$1.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN$ReaderThread.class b/bin/service/CreateRoomWAN$ReaderThread.class deleted file mode 100644 index 797dde1..0000000 Binary files a/bin/service/CreateRoomWAN$ReaderThread.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN$WriterThread.class b/bin/service/CreateRoomWAN$WriterThread.class deleted file mode 100644 index 0c6c9d7..0000000 Binary files a/bin/service/CreateRoomWAN$WriterThread.class and /dev/null differ diff --git a/bin/service/CreateRoomWAN.class b/bin/service/CreateRoomWAN.class deleted file mode 100644 index 6740cbd..0000000 Binary files a/bin/service/CreateRoomWAN.class and /dev/null differ diff --git a/bin/service/EnterRoomLAN$1ClientEnterRoomThread.class b/bin/service/EnterRoomLAN$1ClientEnterRoomThread.class deleted file mode 100644 index 1c7b571..0000000 Binary files a/bin/service/EnterRoomLAN$1ClientEnterRoomThread.class and /dev/null differ diff --git a/bin/service/EnterRoomLAN$ReaderThread$1.class b/bin/service/EnterRoomLAN$ReaderThread$1.class deleted file mode 100644 index 313c488..0000000 Binary files a/bin/service/EnterRoomLAN$ReaderThread$1.class and /dev/null differ diff --git a/bin/service/EnterRoomLAN$ReaderThread.class b/bin/service/EnterRoomLAN$ReaderThread.class deleted file mode 100644 index 26549bd..0000000 Binary files a/bin/service/EnterRoomLAN$ReaderThread.class and /dev/null differ diff --git a/bin/service/EnterRoomLAN$WriterThread.class b/bin/service/EnterRoomLAN$WriterThread.class deleted file mode 100644 index 6d39061..0000000 Binary files a/bin/service/EnterRoomLAN$WriterThread.class and /dev/null differ diff --git a/bin/service/EnterRoomLAN.class b/bin/service/EnterRoomLAN.class deleted file mode 100644 index b4bfe06..0000000 Binary files a/bin/service/EnterRoomLAN.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN$1.class b/bin/service/EnterRoomWAN$1.class deleted file mode 100644 index 57192ca..0000000 Binary files a/bin/service/EnterRoomWAN$1.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN$1ClientEnterRoomThread.class b/bin/service/EnterRoomWAN$1ClientEnterRoomThread.class deleted file mode 100644 index 49f1779..0000000 Binary files a/bin/service/EnterRoomWAN$1ClientEnterRoomThread.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN$ReaderThread$1.class b/bin/service/EnterRoomWAN$ReaderThread$1.class deleted file mode 100644 index e3ad7ff..0000000 Binary files a/bin/service/EnterRoomWAN$ReaderThread$1.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN$ReaderThread.class b/bin/service/EnterRoomWAN$ReaderThread.class deleted file mode 100644 index 5dc18b9..0000000 Binary files a/bin/service/EnterRoomWAN$ReaderThread.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN$WriterThread.class b/bin/service/EnterRoomWAN$WriterThread.class deleted file mode 100644 index 013e6d3..0000000 Binary files a/bin/service/EnterRoomWAN$WriterThread.class and /dev/null differ diff --git a/bin/service/EnterRoomWAN.class b/bin/service/EnterRoomWAN.class deleted file mode 100644 index e955b53..0000000 Binary files a/bin/service/EnterRoomWAN.class and /dev/null differ diff --git a/bin/service/FileDataHandler.class b/bin/service/FileDataHandler.class deleted file mode 100644 index 232c22a..0000000 Binary files a/bin/service/FileDataHandler.class and /dev/null differ diff --git a/bin/service/GameKeyListener.class b/bin/service/GameKeyListener.class deleted file mode 100644 index c0d6926..0000000 Binary files a/bin/service/GameKeyListener.class and /dev/null differ diff --git a/bin/service/MoveThread$LinkQueue$QueueNode.class b/bin/service/MoveThread$LinkQueue$QueueNode.class deleted file mode 100644 index 1d3f13b..0000000 Binary files a/bin/service/MoveThread$LinkQueue$QueueNode.class and /dev/null differ diff --git a/bin/service/MoveThread$LinkQueue.class b/bin/service/MoveThread$LinkQueue.class deleted file mode 100644 index 74a52f8..0000000 Binary files a/bin/service/MoveThread$LinkQueue.class and /dev/null differ diff --git a/bin/service/MoveThread.class b/bin/service/MoveThread.class deleted file mode 100644 index c02f0a8..0000000 Binary files a/bin/service/MoveThread.class and /dev/null differ diff --git a/bin/service/MusicPlayer.class b/bin/service/MusicPlayer.class deleted file mode 100644 index 2779537..0000000 Binary files a/bin/service/MusicPlayer.class and /dev/null differ diff --git a/bin/service/NumberProcesser.class b/bin/service/NumberProcesser.class deleted file mode 100644 index 3e16525..0000000 Binary files a/bin/service/NumberProcesser.class and /dev/null differ diff --git a/bin/service/Sound.class b/bin/service/Sound.class deleted file mode 100644 index 97d2ec0..0000000 Binary files a/bin/service/Sound.class and /dev/null differ diff --git a/bin/view/BagDialog$1.class b/bin/view/BagDialog$1.class deleted file mode 100644 index 9d524bd..0000000 Binary files a/bin/view/BagDialog$1.class and /dev/null differ diff --git a/bin/view/BagDialog$2.class b/bin/view/BagDialog$2.class deleted file mode 100644 index 175d180..0000000 Binary files a/bin/view/BagDialog$2.class and /dev/null differ diff --git a/bin/view/BagDialog$3.class b/bin/view/BagDialog$3.class deleted file mode 100644 index 2269371..0000000 Binary files a/bin/view/BagDialog$3.class and /dev/null differ diff --git a/bin/view/BagDialog$4.class b/bin/view/BagDialog$4.class deleted file mode 100644 index 178a4b2..0000000 Binary files a/bin/view/BagDialog$4.class and /dev/null differ diff --git a/bin/view/BagDialog$5.class b/bin/view/BagDialog$5.class deleted file mode 100644 index d362398..0000000 Binary files a/bin/view/BagDialog$5.class and /dev/null differ diff --git a/bin/view/BagDialog.class b/bin/view/BagDialog.class deleted file mode 100644 index 33e7877..0000000 Binary files a/bin/view/BagDialog.class and /dev/null differ diff --git a/bin/view/ChatDialog$1.class b/bin/view/ChatDialog$1.class deleted file mode 100644 index 2808af9..0000000 Binary files a/bin/view/ChatDialog$1.class and /dev/null differ diff --git a/bin/view/ChatDialog$2.class b/bin/view/ChatDialog$2.class deleted file mode 100644 index 828d483..0000000 Binary files a/bin/view/ChatDialog$2.class and /dev/null differ diff --git a/bin/view/ChatDialog.class b/bin/view/ChatDialog.class deleted file mode 100644 index 12e4d4a..0000000 Binary files a/bin/view/ChatDialog.class and /dev/null differ diff --git a/bin/view/CreateRoomDialog$1.class b/bin/view/CreateRoomDialog$1.class deleted file mode 100644 index 29b3587..0000000 Binary files a/bin/view/CreateRoomDialog$1.class and /dev/null differ diff --git a/bin/view/CreateRoomDialog$2.class b/bin/view/CreateRoomDialog$2.class deleted file mode 100644 index bc455f5..0000000 Binary files a/bin/view/CreateRoomDialog$2.class and /dev/null differ diff --git a/bin/view/CreateRoomDialog$3.class b/bin/view/CreateRoomDialog$3.class deleted file mode 100644 index d43c63c..0000000 Binary files a/bin/view/CreateRoomDialog$3.class and /dev/null differ diff --git a/bin/view/CreateRoomDialog.class b/bin/view/CreateRoomDialog.class deleted file mode 100644 index 4988db1..0000000 Binary files a/bin/view/CreateRoomDialog.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog$1.class b/bin/view/EnterRoomDialog$1.class deleted file mode 100644 index 078edb2..0000000 Binary files a/bin/view/EnterRoomDialog$1.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog$2.class b/bin/view/EnterRoomDialog$2.class deleted file mode 100644 index 690c4c1..0000000 Binary files a/bin/view/EnterRoomDialog$2.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog$3.class b/bin/view/EnterRoomDialog$3.class deleted file mode 100644 index 805f93c..0000000 Binary files a/bin/view/EnterRoomDialog$3.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog$4.class b/bin/view/EnterRoomDialog$4.class deleted file mode 100644 index 7e5d178..0000000 Binary files a/bin/view/EnterRoomDialog$4.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog$5.class b/bin/view/EnterRoomDialog$5.class deleted file mode 100644 index fbdcd31..0000000 Binary files a/bin/view/EnterRoomDialog$5.class and /dev/null differ diff --git a/bin/view/EnterRoomDialog.class b/bin/view/EnterRoomDialog.class deleted file mode 100644 index a940006..0000000 Binary files a/bin/view/EnterRoomDialog.class and /dev/null differ diff --git a/bin/view/GameFrame$1.class b/bin/view/GameFrame$1.class deleted file mode 100644 index 780a092..0000000 Binary files a/bin/view/GameFrame$1.class and /dev/null differ diff --git a/bin/view/GameFrame$10.class b/bin/view/GameFrame$10.class deleted file mode 100644 index 69f7608..0000000 Binary files a/bin/view/GameFrame$10.class and /dev/null differ diff --git a/bin/view/GameFrame$11.class b/bin/view/GameFrame$11.class deleted file mode 100644 index 8ff7b92..0000000 Binary files a/bin/view/GameFrame$11.class and /dev/null differ diff --git a/bin/view/GameFrame$12.class b/bin/view/GameFrame$12.class deleted file mode 100644 index 006414d..0000000 Binary files a/bin/view/GameFrame$12.class and /dev/null differ diff --git a/bin/view/GameFrame$13.class b/bin/view/GameFrame$13.class deleted file mode 100644 index a6cd13e..0000000 Binary files a/bin/view/GameFrame$13.class and /dev/null differ diff --git a/bin/view/GameFrame$14.class b/bin/view/GameFrame$14.class deleted file mode 100644 index 0e07c93..0000000 Binary files a/bin/view/GameFrame$14.class and /dev/null differ diff --git a/bin/view/GameFrame$2.class b/bin/view/GameFrame$2.class deleted file mode 100644 index ce1ed58..0000000 Binary files a/bin/view/GameFrame$2.class and /dev/null differ diff --git a/bin/view/GameFrame$3.class b/bin/view/GameFrame$3.class deleted file mode 100644 index 27e6a60..0000000 Binary files a/bin/view/GameFrame$3.class and /dev/null differ diff --git a/bin/view/GameFrame$4.class b/bin/view/GameFrame$4.class deleted file mode 100644 index 9bf35b2..0000000 Binary files a/bin/view/GameFrame$4.class and /dev/null differ diff --git a/bin/view/GameFrame$5.class b/bin/view/GameFrame$5.class deleted file mode 100644 index 2aa9d42..0000000 Binary files a/bin/view/GameFrame$5.class and /dev/null differ diff --git a/bin/view/GameFrame$6.class b/bin/view/GameFrame$6.class deleted file mode 100644 index 750d0b1..0000000 Binary files a/bin/view/GameFrame$6.class and /dev/null differ diff --git a/bin/view/GameFrame$7.class b/bin/view/GameFrame$7.class deleted file mode 100644 index 99bc51c..0000000 Binary files a/bin/view/GameFrame$7.class and /dev/null differ diff --git a/bin/view/GameFrame$8.class b/bin/view/GameFrame$8.class deleted file mode 100644 index c4b2136..0000000 Binary files a/bin/view/GameFrame$8.class and /dev/null differ diff --git a/bin/view/GameFrame$9.class b/bin/view/GameFrame$9.class deleted file mode 100644 index dfa1728..0000000 Binary files a/bin/view/GameFrame$9.class and /dev/null differ diff --git a/bin/view/GameFrame$FriendMoveController.class b/bin/view/GameFrame$FriendMoveController.class deleted file mode 100644 index 13fcc25..0000000 Binary files a/bin/view/GameFrame$FriendMoveController.class and /dev/null differ diff --git a/bin/view/GameFrame$SetChatMessageThread.class b/bin/view/GameFrame$SetChatMessageThread.class deleted file mode 100644 index acaab04..0000000 Binary files a/bin/view/GameFrame$SetChatMessageThread.class and /dev/null differ diff --git a/bin/view/GameFrame.class b/bin/view/GameFrame.class deleted file mode 100644 index 8f864c2..0000000 Binary files a/bin/view/GameFrame.class and /dev/null differ diff --git a/bin/view/LoadingFrame$1.class b/bin/view/LoadingFrame$1.class deleted file mode 100644 index 2287c64..0000000 Binary files a/bin/view/LoadingFrame$1.class and /dev/null differ diff --git a/bin/view/LoadingFrame.class b/bin/view/LoadingFrame.class deleted file mode 100644 index 1028435..0000000 Binary files a/bin/view/LoadingFrame.class and /dev/null differ diff --git a/bin/view/MenuFrame$1.class b/bin/view/MenuFrame$1.class deleted file mode 100644 index 753d254..0000000 Binary files a/bin/view/MenuFrame$1.class and /dev/null differ diff --git a/bin/view/MenuFrame$2.class b/bin/view/MenuFrame$2.class deleted file mode 100644 index 5b6f844..0000000 Binary files a/bin/view/MenuFrame$2.class and /dev/null differ diff --git a/bin/view/MenuFrame$3.class b/bin/view/MenuFrame$3.class deleted file mode 100644 index 329149f..0000000 Binary files a/bin/view/MenuFrame$3.class and /dev/null differ diff --git a/bin/view/MenuFrame$4.class b/bin/view/MenuFrame$4.class deleted file mode 100644 index 1965713..0000000 Binary files a/bin/view/MenuFrame$4.class and /dev/null differ diff --git a/bin/view/MenuFrame$5.class b/bin/view/MenuFrame$5.class deleted file mode 100644 index 1b06d35..0000000 Binary files a/bin/view/MenuFrame$5.class and /dev/null differ diff --git a/bin/view/MenuFrame$6.class b/bin/view/MenuFrame$6.class deleted file mode 100644 index 7ea6851..0000000 Binary files a/bin/view/MenuFrame$6.class and /dev/null differ diff --git a/bin/view/MenuFrame.class b/bin/view/MenuFrame.class deleted file mode 100644 index abd15f3..0000000 Binary files a/bin/view/MenuFrame.class and /dev/null differ diff --git a/bin/view/TextDialog.class b/bin/view/TextDialog.class deleted file mode 100644 index 5c0ef75..0000000 Binary files a/bin/view/TextDialog.class and /dev/null differ diff --git a/data/Setting b/data/Setting deleted file mode 100644 index e030176..0000000 --- a/data/Setting +++ /dev/null @@ -1 +0,0 @@ -80,80,80,0 \ No newline at end of file diff --git a/image/Boy/actor_d.gif b/image/Boy/actor_d.gif deleted file mode 100644 index c195cd9..0000000 Binary files a/image/Boy/actor_d.gif and /dev/null differ diff --git a/image/Boy/actor_d.png b/image/Boy/actor_d.png deleted file mode 100644 index b4f172c..0000000 Binary files a/image/Boy/actor_d.png and /dev/null differ diff --git a/image/Boy/actor_l.gif b/image/Boy/actor_l.gif deleted file mode 100644 index 69ab378..0000000 Binary files a/image/Boy/actor_l.gif and /dev/null differ diff --git a/image/Boy/actor_l.png b/image/Boy/actor_l.png deleted file mode 100644 index 52369d3..0000000 Binary files a/image/Boy/actor_l.png and /dev/null differ diff --git a/image/Boy/actor_r.gif b/image/Boy/actor_r.gif deleted file mode 100644 index c1b5c8d..0000000 Binary files a/image/Boy/actor_r.gif and /dev/null differ diff --git a/image/Boy/actor_r.png b/image/Boy/actor_r.png deleted file mode 100644 index 175dc2a..0000000 Binary files a/image/Boy/actor_r.png and /dev/null differ diff --git a/image/Boy/actor_u.gif b/image/Boy/actor_u.gif deleted file mode 100644 index 200fdf7..0000000 Binary files a/image/Boy/actor_u.gif and /dev/null differ diff --git a/image/Boy/actor_u.png b/image/Boy/actor_u.png deleted file mode 100644 index 2a53970..0000000 Binary files a/image/Boy/actor_u.png and /dev/null differ diff --git a/image/GameFrame/black.png b/image/GameFrame/black.png deleted file mode 100644 index e0ea023..0000000 Binary files a/image/GameFrame/black.png and /dev/null differ diff --git a/image/GameFrame/icon.png b/image/GameFrame/icon.png deleted file mode 100644 index 1bda6d0..0000000 Binary files a/image/GameFrame/icon.png and /dev/null differ diff --git a/image/Girl/actor_d.gif b/image/Girl/actor_d.gif deleted file mode 100644 index f8c7220..0000000 Binary files a/image/Girl/actor_d.gif and /dev/null differ diff --git a/image/Girl/actor_d.png b/image/Girl/actor_d.png deleted file mode 100644 index 46adac3..0000000 Binary files a/image/Girl/actor_d.png and /dev/null differ diff --git a/image/Girl/actor_l.gif b/image/Girl/actor_l.gif deleted file mode 100644 index 9ce953b..0000000 Binary files a/image/Girl/actor_l.gif and /dev/null differ diff --git a/image/Girl/actor_l.png b/image/Girl/actor_l.png deleted file mode 100644 index cad579a..0000000 Binary files a/image/Girl/actor_l.png and /dev/null differ diff --git a/image/Girl/actor_r.gif b/image/Girl/actor_r.gif deleted file mode 100644 index 189d420..0000000 Binary files a/image/Girl/actor_r.gif and /dev/null differ diff --git a/image/Girl/actor_r.png b/image/Girl/actor_r.png deleted file mode 100644 index 436bc17..0000000 Binary files a/image/Girl/actor_r.png and /dev/null differ diff --git a/image/Girl/actor_u.gif b/image/Girl/actor_u.gif deleted file mode 100644 index 1f0d661..0000000 Binary files a/image/Girl/actor_u.gif and /dev/null differ diff --git a/image/Girl/actor_u.png b/image/Girl/actor_u.png deleted file mode 100644 index aef6cbb..0000000 Binary files a/image/Girl/actor_u.png and /dev/null differ diff --git a/image/LoadingFrame/Exploration.png b/image/LoadingFrame/Exploration.png deleted file mode 100644 index 0abcbda..0000000 Binary files a/image/LoadingFrame/Exploration.png and /dev/null differ diff --git a/image/LoadingFrame/background.jpg b/image/LoadingFrame/background.jpg deleted file mode 100644 index b93b555..0000000 Binary files a/image/LoadingFrame/background.jpg and /dev/null differ diff --git a/image/LoadingFrame/icon.png b/image/LoadingFrame/icon.png deleted file mode 100644 index 1bda6d0..0000000 Binary files a/image/LoadingFrame/icon.png and /dev/null differ diff --git a/image/LoadingFrame/projectTeam.png b/image/LoadingFrame/projectTeam.png deleted file mode 100644 index 4432017..0000000 Binary files a/image/LoadingFrame/projectTeam.png and /dev/null differ diff --git a/image/MenuFrame/background.jpg b/image/MenuFrame/background.jpg deleted file mode 100644 index da113ce..0000000 Binary files a/image/MenuFrame/background.jpg and /dev/null differ diff --git a/image/MenuFrame/icon.png b/image/MenuFrame/icon.png deleted file mode 100644 index 1bda6d0..0000000 Binary files a/image/MenuFrame/icon.png and /dev/null differ diff --git a/image/MenuFrame/title.png b/image/MenuFrame/title.png deleted file mode 100644 index 24c1c4f..0000000 Binary files a/image/MenuFrame/title.png and /dev/null differ diff --git a/image/T3502/blackboard.jpg b/image/T3502/blackboard.jpg deleted file mode 100644 index f5159a6..0000000 Binary files a/image/T3502/blackboard.jpg and /dev/null differ diff --git a/image/T3502/door.png b/image/T3502/door.png deleted file mode 100644 index 0d95af2..0000000 Binary files a/image/T3502/door.png and /dev/null differ diff --git a/image/T3502/floor.png b/image/T3502/floor.png deleted file mode 100644 index 6610678..0000000 Binary files a/image/T3502/floor.png and /dev/null differ diff --git a/image/T3502/longDesk.png b/image/T3502/longDesk.png deleted file mode 100644 index fbbe79a..0000000 Binary files a/image/T3502/longDesk.png and /dev/null differ diff --git a/image/T3502/longSeat.png b/image/T3502/longSeat.png deleted file mode 100644 index 7d8f901..0000000 Binary files a/image/T3502/longSeat.png and /dev/null differ diff --git a/image/T3502/math.png b/image/T3502/math.png deleted file mode 100644 index e6a8cd5..0000000 Binary files a/image/T3502/math.png and /dev/null differ diff --git a/image/T3502/paperParcel.png b/image/T3502/paperParcel.png deleted file mode 100644 index 51d3b9e..0000000 Binary files a/image/T3502/paperParcel.png and /dev/null differ diff --git a/image/T3502/shortDesk.png b/image/T3502/shortDesk.png deleted file mode 100644 index 7471cdc..0000000 Binary files a/image/T3502/shortDesk.png and /dev/null differ diff --git a/image/T3502/shortSeat.png b/image/T3502/shortSeat.png deleted file mode 100644 index d076212..0000000 Binary files a/image/T3502/shortSeat.png and /dev/null differ diff --git a/image/T3502/teacherDesk.png b/image/T3502/teacherDesk.png deleted file mode 100644 index 6851aa0..0000000 Binary files a/image/T3502/teacherDesk.png and /dev/null differ diff --git a/image/TextDialog/1.jpg b/image/TextDialog/1.jpg deleted file mode 100644 index 85f9ab2..0000000 Binary files a/image/TextDialog/1.jpg and /dev/null differ diff --git a/image/itemPhotoPng/100.png b/image/itemPhotoPng/100.png deleted file mode 100644 index 03c4dea..0000000 Binary files a/image/itemPhotoPng/100.png and /dev/null differ diff --git a/image/itemPhotoPng/101.png b/image/itemPhotoPng/101.png deleted file mode 100644 index a42a9da..0000000 Binary files a/image/itemPhotoPng/101.png and /dev/null differ diff --git a/image/itemPhotoPng/102.png b/image/itemPhotoPng/102.png deleted file mode 100644 index cef9759..0000000 Binary files a/image/itemPhotoPng/102.png and /dev/null differ diff --git a/image/itemPhotoPng/200.png b/image/itemPhotoPng/200.png deleted file mode 100644 index f29b2ca..0000000 Binary files a/image/itemPhotoPng/200.png and /dev/null differ diff --git a/music/bgmGame1.wav b/music/bgmGame1.wav deleted file mode 100644 index f5631d0..0000000 Binary files a/music/bgmGame1.wav and /dev/null differ diff --git a/music/bgmMenu.wav b/music/bgmMenu.wav deleted file mode 100644 index 677c828..0000000 Binary files a/music/bgmMenu.wav and /dev/null differ diff --git a/src/calculate/Bag.java b/src/calculate/Bag.java deleted file mode 100644 index fbfae62..0000000 --- a/src/calculate/Bag.java +++ /dev/null @@ -1,372 +0,0 @@ -package calculate; - -import java.util.Arrays; -import service.NumberProcesser; -import view.BagDialog; -import view.GameFrame; - -//;该类为存放物品的背包,其中存放了道具的头节点与存放消耗品的数组 -/*存放链表与数组相关的操作*/ - -public class Bag{ - private final int AMax = Constant.A_MAX; //A最大数量 - private final int BMax = Constant.B_MAX; //B数组长度 - private Dictionary dictionary = new Dictionary(); - private FoodDictionary foodDictionary = new FoodDictionary(); - private FoodCalculator foodCalculator = new FoodCalculator(this); - private int BItemArray[] = new int[BMax]; //设置存放B类物品的数组 - private AItemNode AItemHead = new AItemNode(); //A类道具链表的头结点 - private NumberProcesser numberProcesser = new NumberProcesser(); //数字处理器 - private GameFrame gameFrame; - private BagDialog bagDialog; - private MyData myData; - - //构造函数:初始化背包信息 - public Bag(MyData myData) - { - this.myData=myData; - gameFrame=myData.getGameFrame(); - Arrays.fill(BItemArray,0); - } - - //快速就餐 - public void quickEat() { - int calculatedBItems[] = foodCalculator.Calculate((int)myData.getPower()); - int usedAmount; - for(int i=0;i0) { - useItem(200+i,usedAmount); - myData.changePower(usedAmount*foodDictionary.getFoodPower(200+i)); - } - } - } - - //查看是否有物品 - public boolean checkItem(int code) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - for(AItemNode node = AItemHead.next;node!=null;node=node.next) { - if(node.item==code) return true; - } - return false; - } - else if(itemKind==2) { //消耗品 - if(BItemArray[itemNumber]>0) return true; - else return false; - } - else return false; - } - - //查看该物品数量 - public int getThisItemQuantity(int code) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - for(AItemNode node = AItemHead.next;node!=null;node=node.next) { - if(node.item==code) return 1; - } - return 0; - } - else if(itemKind==2) { //消耗品 - return BItemArray[itemNumber]; - } - else return -1; - } - - //获得物品 - public void addItem(int code) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(!checkItem(code)) { - AItemNode node = new AItemNode(code,AItemHead.next); - AItemHead.next=node; - if(myData.getPlayerStatus()!=3||myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,1,"+code+",1"); - } - } - else if(itemKind==2) { //消耗品 - BItemArray[itemNumber]++; - if(myData.getPlayerStatus()!=3||myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)+" *1"); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,1,"+code+",1"); - } - } - - //获得物品 - public void addItem(int code,int quantity) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(!checkItem(code)) { - AItemNode node = new AItemNode(code,AItemHead.next); - AItemHead.next=node; - if(myData.getPlayerStatus()!=3&&myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,1,"+code+","+quantity); - } - } - else if(itemKind==2) { //消耗品 - BItemArray[itemNumber]+=quantity; - if(myData.getPlayerStatus()!=3&&myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)+" *"+quantity); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,1,"+code+","+quantity); - } - } - - //共同获得物品 - public void addItemTogether(int code,int quantity) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(!checkItem(code)) { - AItemNode node = new AItemNode(code,AItemHead.next); - AItemHead.next=node; - if(myData.getPlayerStatus()!=3||myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)); - } - } - else if(itemKind==2) { //消耗品 - BItemArray[itemNumber]+=quantity; - if(myData.getPlayerStatus()!=3||myData.getPlayerStatus()!=6) gameFrame.showLeftMessage("获得 "+getItemName(code)+" *"+quantity); - } - } - - //使用物品 - public boolean useItem(int code) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - for(AItemNode node = AItemHead;node.next!=null;node=node.next) { - if(node.next.item==code) { - node.next=node.next.next; - gameFrame.showLeftMessage("使用 "+getItemName(code)); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,2,"+code+",1"); - return true; - } - } - return false; - } - else if(itemKind==2) { //消耗品 - if(BItemArray[itemNumber]>0) { - BItemArray[itemNumber]--; - gameFrame.showLeftMessage("消耗 "+getItemName(code)+" *1"); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,2,"+code+",1"); - return true; - } - else return false; - } - else return false; - } - - //使用物品 - public boolean useItem(int code,int quantity) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(quantity!=1) return false; - for(AItemNode node = AItemHead;node.next!=null;node=node.next) { - if(node.next.item==code) { - node.next=node.next.next; - gameFrame.showLeftMessage("使用 "+getItemName(code)); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,2,"+code+","+quantity); - return true; - } - } - return false; - } - else if(itemKind==2) { //消耗品 - if(BItemArray[itemNumber]>=quantity) { - BItemArray[itemNumber]-=quantity; - gameFrame.showLeftMessage("消耗 "+getItemName(code)+" *"+quantity); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) myData.sendMessage("3,2,"+code+","+quantity); - return true; - } - else return false; - } - else return false; - } - - //共同使用物品 - public boolean useItemTogether(int code,int quantity) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(quantity!=1) return false; - for(AItemNode node = AItemHead;node.next!=null;node=node.next) { - if(node.next.item==code) { - node.next=node.next.next; - gameFrame.showLeftMessage("使用 "+getItemName(code)); - return true; - } - } - return false; - } - else if(itemKind==2) { //消耗品 - if(BItemArray[itemNumber]>=quantity) { - BItemArray[itemNumber]-=quantity; - gameFrame.showLeftMessage("消耗 "+getItemName(code)+" *"+quantity); - return true; - } - else return false; - } - else return false; - } - - //获得总物品种类数 - public int getTotalItemKinds() { - return getAItemKinds()+getBItemKinds(); - } - - //获得物品名 - public String getItemName(int code) { - return dictionary.getName(code); - } - - //获得物品描述 - public String getItemDescription(int code) { - return dictionary.getDescription(code); - } - - //AItemNode内部类: A物品 存放只可获得一次的物品的链表节点,其中实现了基本元素的存取 - class AItemNode { - //物品的序号对应数组存放的位置 - - private int item; //物品的序号 - private AItemNode next; //下一个结点 - - //构造函数:物品信息的初始化 - public AItemNode(int item){ - this.item = item; - next=null; - } - - //构造函数:物品信息的初始化 - public AItemNode(int item,AItemNode next){ - this.item = item; - this.next=next; - } - - //构造函数:用于头节点的构造 - public AItemNode(){ - next = null; - } - } - - //获取背包中A物品种类数 - public int getAItemKinds(){ - int length=0; - for(AItemNode node = AItemHead;node.next!=null;node=node.next) { - length++; - } - return length; - } - - //遍历A表中物品 - public int[] getAItems(){ - int length=getAItemKinds(); - int[] AItems = new int[length]; - int i=0; - for(AItemNode node = AItemHead.next;node!=null;node=node.next,i++) { - AItems[i]=node.item; - } - return AItems; - } - - //获取背包中B物品种类数 - public int getBItemKinds(){ - int length=0; - for(int i=0;i0) length++; - } - return length; - } - - //遍历B表中物品 - public int[] getBItems(){ - int length=getBItemKinds(); - int[] BItems = new int[length]; - int j=0; - for(int i=0;i0){ - BItems[j]=200+i; - j++; - } - } - return BItems; - } - - //词典类 查找背包中物品信息字典 - class Dictionary { - private String[] nameA=new String[AMax]; - private String[] descriptionA=new String[AMax]; - private String[] nameB=new String[AMax]; - private String[] descriptionB=new String[AMax]; - private NumberProcesser numberProcesser = new NumberProcesser(); //数字处理器 - - public Dictionary() { - initialDictionary(); - } - - //从词典中获取物品名 - public String getName(int code) { - //System.out.println("getName: "+code); - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - return nameA[itemNumber]; - } - else if(itemKind==2) { //消耗品 - return nameB[itemNumber]; - } - else return null; - } - - //从词典中获取物品描述 - public String getDescription(int code) { - //System.out.println("getDescription: "+code); - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - return descriptionA[itemNumber]; - } - else if(itemKind==2) { //消耗品 - return descriptionB[itemNumber]; - } - else return null; - } - - //在词典中添加词条 - public void addDirectoryItem(int code,String name,String description) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==1) { //游戏道具 - if(itemNumber" - + "WASD/上下左右箭头: 移动   " - + "Shift: 加速跑   " - + "空格: 语句跳过
" - + "F:find 交互   " - + "E:eat 饮食   " - + "B:bag 背包   " - + "V:volume 音量
" - + "ESC: 退出游戏   " - + "H:help 帮助   " - + "O:online 联机
Enter: 联机聊天   " - + "P:progress 保存进度   " - + "



" - + "
中文输入法会对键盘读取产生干扰," - + "
强烈建议将输入法改成ENG英语以获得流畅的游戏体验!" - +"

如果有其他任何问题,请联系制作人: QQ 1731019653," - + "Tel 18646393118
感谢您体验Exploration!祝您玩的愉快!"; - - public final static String DEVELOPER_TEXT="本游戏由Exploration项目组进行开发、维护与更新。
" - + "Exploration项目组成立于哈尔滨工业大学(深圳)软A任务。
Exploration项目组成员:
 董天泽" - + "
 周雨琦

联系我们:
 QQ:1731019653 Tel:18646393118

" - + "测试者信息:

感谢测试者对游戏开发的大力支持!
" - + "本游戏中部分素材来自于网络或实拍,仅可用作体验或学习交流," - + "
不会用作商业用途。如有侵权请联系开发者!


"; - - public final static String UPDATELOG_TEXT="

当前版本为V3.6.0 Version:V3.6.0

" - + "V3.6.0:游戏进度存取存储和读取功能开放 2020.10.29
" - + "V3.5.1:信息发送和处理延迟降低 2020.10.28
" - + "V3.5.0:聊天系统开放 好友角色移动朝向bug修复 2020.10.28
" - + "V3.4.0:快速饮食开放 鼠标点击自动寻路移动开放 2020.10.27
" - + "V3.3.0:广域网联机开放 2020.10.27
" - + "V3.2.0:局域网联机开放 2020.10.26
" - + "V3.1.2:背包系统逻辑优化 2020.10.10
" - + "V3.1.1:更新背包系统 2020.10.10
" - + "V3.1.0:增加背包系统,增加初始地图 2020.10.10
" - + "V3.0.0:游戏大幅度重做,人机交互优化,界面重做 2020.9.29
" - + "V2.0.0:游戏大幅度重做,新功能添加,人机交互优化 2020.8.24
" - + "
V1.2.0 beta:对音效文件与提示信息进行了更换 2020.7.12
V1.2.0:" - + "添加了帮助和更新日志功能 2020.7.11
" -+ "V1.1.2:修复了关闭提示窗口时音效无法停止的bug 2020.7.11
V1.1.1:修复了关闭主程序时音效无法停止的bug 2020.7.11
" -+ "V1.1.0:添加了音效功能 2020.7.11
V1.0.0:添加了成就功能 初代版本发布2020.7.10
V0.0.0:开始开发本游戏 2020.7.9

开发者信息:本游戏由Exploration项目组" -+ "进行开发、维护与更新。
QQ:1731019653 Tel:18646393118
感谢您体验Exploration!祝您玩的愉快!



"; -} diff --git a/src/calculate/Door.java b/src/calculate/Door.java deleted file mode 100644 index 684effe..0000000 --- a/src/calculate/Door.java +++ /dev/null @@ -1,62 +0,0 @@ -package calculate; - -public class Door { - //Door类:存储门数据 - - private int doorNumber; - private boolean canEnter; - private int targetRoom; - private int targetX; - private int targetY; - - //构造函数:创建门 - public Door(int doorNumber,int canEnterCode) { - this.doorNumber=doorNumber; - canEnter=false; - if(canEnterCode==1) { - canEnter=true; - createDoor(); - } - else if(canEnterCode==0){ - - } - } - - //初始化一个门 - public void createDoor() { - switch(doorNumber) { - case 50200: - - break; - default: - - break; - } - } - - //获取是否能进入 - public boolean getCanEnter() { - return canEnter; - } - - //获取目标房间 - public int getTargetRoom() { - if(canEnter) return targetRoom; - else return -1; - } - - //获取目标x坐标 - public int getTargetX() { - if(canEnter) return targetX; - else return -1; - } - - //获取目标y坐标 - public int getTargetY() { - if(canEnter) return targetY; - else return -1; - } - - - -} diff --git a/src/calculate/FoodCalculator.java b/src/calculate/FoodCalculator.java deleted file mode 100644 index 99a4be2..0000000 --- a/src/calculate/FoodCalculator.java +++ /dev/null @@ -1,226 +0,0 @@ -package calculate; - -import java.util.Arrays; - -//计算回复体力值的方案 -public class FoodCalculator{ - private int[] num; //消耗品的数量数组 - private int[] cost; //消耗品回复体力数组 - private final int BMAX = Constant.B_MAX; - private FoodDictionary dictionary = new FoodDictionary(); //初始化词典 - private int max; //需要补充的体力 - private Bag bag; //背包 - - //构造函数:根据B类数组初始化num数组,根据词典初始化cost数组 - public FoodCalculator(Bag bag) { //TODO:为了测试删去了bag,还需添加一个bag进去 - num = new int[BMAX]; - cost = new int[BMAX]; - this.bag = bag; - Arrays.fill(num, 0); - } - - //计算不超过max的消耗品组合 - public int[] Calculate(int strength) { - Stack stack = new Stack(); //初始化一个栈 - int nowMax = -1; - max = 100 - strength; - for(int i = 0; i < BMAX ; i++) { - cost[i] = dictionary.getFoodPower(i + 200); - if(bag.checkItem(i + 200)) { - num[i] = bag.getThisItemQuantity(i + 200); - } - } //num和cost数组的初始化 - - Node nowNode = new Node(500, 0, num); //树根的初始化 - Node maxNode = nowNode; //记录当前的恢复体力最大的树节点 - nowNode.setFatherNode(null); //设置根的父节点为空 - nowNode.setCostAdd(0); //初始化树根的累计回复体力值 - - //第一次初始化树 - for(int i = 0; i < num.length; i++) { - if(num[i] > 0) { - Node treeNode = new Node(i + 200,cost[i],num); - treeNode.setFatherNode(nowNode); - stack.push(treeNode); - } - } - - //当栈空时退出搜索 - while(!stack.isEmpty()) { - nowNode = stack.pop(); - nowNode.setCostAdd(nowNode.fatherNode.costAdd + nowNode.cost); //设置累积回复体力值 - - //判断是否找到最大值,同时更新最大值 - if(nowNode.costAdd > max) { - continue; - }else if (nowNode.costAdd == max) { - maxNode = nowNode; - nowMax = max; - break; - }else { - if(nowNode.costAdd > nowMax) { - maxNode = nowNode; - nowMax = nowNode.costAdd; - } - } - - //扩展树 - for(int i = 0; i < num.length; i++) { - if(!isBagEmpty(nowNode.num)) { - if(nowNode.num[i] > 0) { - Node treeNode = new Node(i + 200, cost[i], nowNode.num); - treeNode.setFatherNode(nowNode); - stack.push(treeNode); - } - } - } - } - - int[] newnum =changeNum(num,cost,nowMax); //通过贪心算法改变解的结构 -// //实例测试 -// System.out.println("测试实例"); -// System.out.println("一共恢复了"+nowMax+"点体力"); -// for(int i = 0; i < BMAX; i++) { -// if(newnum[i] < num[i]) { -// System.out.println("使用了"+(num[i]-newnum[i])+"个"+(200+i)+"B类物品"+","+"并且回复了"+ -// (num[i] - newnum[i])*dictionary.getFoodPower(200+i)+"点体力"); -// } -// } - return newnum; - } - - //利用贪心算法改变num数组的组成 - private int[] changeNum(int[] num,int[]cost,int max) { - int[] newnum = new int[BMAX]; - int j = BMAX-1; - for(int i = 0; i < BMAX; i++) { - newnum[i] = num[i]; - } - while(j >= 0){ - if(max - cost[j] < 0 || newnum[j] - 1 < 0) { - j--; - }else { - max = max - cost[j]; - newnum[j]--; - } - if(max == 0) { - break; - } - } - return newnum; - } - - //判断背包内是否有物品 - private boolean isBagEmpty(int[] num) { - int sum = 0; - for(int i = 0; i < BMAX; i++) { - sum = sum + num[i]; - } - if(0 == sum) { - return true; - }else { - return false; - } - } - - //数据结构:数组,栈的底层数据结构 - class Array{ - private int length; //数组的长度 - private int num; //数组中元素的个数 - private Node[] array; //数组 - - public Array(){ - this.length = 500; - this.num = 0; - array = new Node[length]; - } - - //向数组末尾添加元素,node是添加的元素 - public void add(Node node) { - array[num] = node; - num++; - } - - //判断数组是否为空 - public boolean isEmpty() { - return 0 == num; - } - - //删除数组末尾的元素 - public Node delete() { - if(true == isEmpty()) { - try { - throw new Exception("数组为空"); - }catch(Exception e3) { - e3.printStackTrace(); - } - } - Node node = array[num - 1]; - array[num - 1] = null; - num--; - return node; - } - } - - //数据结构栈,底层数据结构为数组 - class Stack{ - int top; //栈顶 - int maxSize; //栈的最大长度 - Array arr; //数组 - - //构造函数:初始化栈 - public Stack(){ - top = -1; - arr = new Array(); - maxSize = arr.length; - } - - //压栈,压入的元素为node - public void push(Node node) { - arr.add(node); - top++; - } - - //出栈,弹出的元素为node - public Node pop() { - top--; - return arr.delete(); - } - - //判断栈是否为空 - public boolean isEmpty() { - return arr.isEmpty(); - } - } - - //内部类,存储食品回复值、种类以及该节点的父节点 - class Node{ - private int cost; //恢复体力值 - private int code; //物品的种类 - private int costAdd; //到该节点已经恢复的体力值 - private Node fatherNode; //父亲节点 - private int[] num = new int[BMAX]; - //构造函数:初始化cost、code - public Node(int code, int cost,int[] num) { - this.code = code; - this.cost = cost; - for(int i = 0; i < num.length; i++) { - if(i != code - 200) { - this.num[i] = num[i]; - }else { - this.num[i] = num[i] - 1; - } - } - } - - //设置父节点 - public void setFatherNode(Node fatherNode) { - this.fatherNode = fatherNode; - } - - //设置costAdd - public void setCostAdd(int costAdd) { - this.costAdd = costAdd; - } - } -} diff --git a/src/calculate/FoodDictionary.java b/src/calculate/FoodDictionary.java deleted file mode 100644 index 25695d8..0000000 --- a/src/calculate/FoodDictionary.java +++ /dev/null @@ -1,42 +0,0 @@ -package calculate; - -import service.NumberProcesser; - -//FoodDictionary类:食物体力表 -public class FoodDictionary { - private final int foodKinds = Constant.B_MAX; //B数组长度 - private int foodPowers[] = new int [foodKinds]; - private NumberProcesser numberProcesser = new NumberProcesser(); - - //构造方法 初始化食物体力表 - public FoodDictionary(){ - initialFoodDictionary(); - } - - //添加食物词条 - public void addFoodItem(int code,int power) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==2){ - foodPowers[itemNumber]=power; - } - - } - - //查询食物体力 - public int getFoodPower(int code) { - int itemKind=numberProcesser.headSplit(code); - int itemNumber=numberProcesser.endSplit(code); - if(itemKind==2){ - return foodPowers[itemNumber]; - } - else return -1; - } - - //初始化食物体力表 - public void initialFoodDictionary() { -/////////////////////////////////////////////////////////////////////////////////////////////////// - addFoodItem(200,10); - - } -} diff --git a/src/calculate/LinkQueue.java b/src/calculate/LinkQueue.java deleted file mode 100644 index d29312c..0000000 --- a/src/calculate/LinkQueue.java +++ /dev/null @@ -1,64 +0,0 @@ -package calculate; - -//Queue 队列 -public class LinkQueue{ - private QueueNode front; //队首 - private QueueNode rear; //队尾 - private int size; - public LinkQueue() { - front=new QueueNode(null); - rear=front; - size=0; - } - - // 判断队列是否为空 - public boolean QueueEmpty(){ - return size==0; - } - - //入队 - public void EnQueue(String message){ - QueueNode node = new QueueNode(message); - rear.next=node; - rear=node; - size++; - } - - //出队 - public String DeQueue(){ - if(QueueEmpty()) return null; - String tempMessage; - if(front.next==rear) rear=front; - QueueNode p=front.next; - tempMessage=p.message; - front.next=p.next; - size--; - return tempMessage; - } - - //返回队头 - public String GetHead(){ - if(QueueEmpty()) return null; - return front.next.message; - } - - //返回队尾 - public String GetRear(){ - if(QueueEmpty()) return null; - return rear.message; - } - - //QueueNode 内部类 队列结点 - class QueueNode{ - private String message; - private QueueNode next; - public QueueNode(String message,QueueNode next) { - this.message=message; - this.next=next; - } - public QueueNode(String message) { - this.message=message; - next=null; - } - } -} diff --git a/src/calculate/MyData.java b/src/calculate/MyData.java deleted file mode 100644 index 7de6ff8..0000000 --- a/src/calculate/MyData.java +++ /dev/null @@ -1,597 +0,0 @@ -package calculate; - -import service.CreateRoomLAN; -import service.CreateRoomWAN; -import service.EnterRoomLAN; -import service.EnterRoomWAN; -import service.FileDataHandler; -import service.NumberProcesser; -import view.GameFrame; -import view.TextDialog; - -public class MyData { - //MyData类:角色个人数据 - - private Room room; - private int x=Constant.INITIAL_X; //角色x坐标 - private int y=Constant.INITIAL_Y; //角色y坐标 - private final double fullPower=Constant.FULL_POWER; //满体力值 - private final int maxRoom = Constant.MAX_ROOM; - private NumberProcesser numberProcesser = new NumberProcesser(); //数字处理器 - private ChangeableItemList[] changeableItemLists = new ChangeableItemList[maxRoom]; - private int direction; //方向 - private GameFrame gameFrame; - private int RMB ; //钱 - private double power=fullPower; //当前体力值 - private Bag bag; //背包 - private int playerStatus = 5; //0:单机模式初始化 1:联机模式发送信息阶段 2:联机模式开房间游戏阶段 - // 3:联机模式加房间接收信息阶段 4:联机模式加房间游戏阶段 5:单机模式 6:继续游戏传入数据中 - private EnterRoomLAN enterRoomLAN; - private EnterRoomWAN enterRoomWAN; - private CreateRoomLAN createRoomLAN; - private CreateRoomWAN createRoomWAN; - - //构造函数:初始化成员变量值 - public MyData(GameFrame gameFrame,int[][] map,int x,int y,int z,Bag bag){ - this.bag=bag; - this.x=x; - this.y=y; - } - public MyData(GameFrame gameFrame,int playerStatus) { - this.gameFrame=gameFrame; - this.playerStatus=playerStatus; - initial(); - } - - //初始化角色数据 - public void initial() { - x=Constant.INITIAL_X; - y=Constant.INITIAL_Y; - room = new Room(502); - direction=0; - RMB=0; - bag = new Bag(this); - } - - //加入房间模式 - public void enterRoomLANMode(EnterRoomLAN enterRoomLAN) { - createRoomLAN = null; - createRoomWAN = null; - enterRoomWAN = null; - this.enterRoomLAN=enterRoomLAN; - } - - //创建房间模式 - public void createRoomLANMode(CreateRoomLAN createRoomLAN) { - enterRoomLAN = null; - createRoomWAN = null; - enterRoomWAN = null; - this.createRoomLAN=createRoomLAN; - } - - //创建房间模式 - public void createRoomWANMode(CreateRoomWAN createRoomWAN) { - enterRoomLAN = null; - createRoomLAN = null; - enterRoomWAN = null; - this.createRoomWAN=createRoomWAN; - } - - //加入房间模式 - public void enterRoomWANMode(EnterRoomWAN enterRoomWAN) { - enterRoomLAN = null; - createRoomLAN = null; - createRoomWAN = null; - this.enterRoomWAN=enterRoomWAN; - } - - //设定游戏模式 - public void setPlayerStatus(int targetStatus) { - playerStatus = targetStatus; - } - - //获取游戏模式 - public int getPlayerStatus() { - //System.out.println("playerStatus:"+playerStatus); - return playerStatus; - } - - //角色移动 输入int方向,返回boolean移动是否成功 - public boolean move(int direction) { - switch (direction){ - case 0: - if(numberProcesser.headSplit(room.seeLocation(x,y-1))!=1) return false; - else { - y--; - return true; - } - case 1: - if(numberProcesser.headSplit(room.seeLocation(x,y+1))!=1) return false; - else{ - y++; - return true; - } - case 2: - if(numberProcesser.headSplit(room.seeLocation(x-1,y))!=1) return false; - else { - x--; - return true; - } - case 3: - if(numberProcesser.headSplit(room.seeLocation(x+1,y))!=1) return false; - else { - x++; - return true; - } - default: - return false; - } - } - - //访问坐标 - public void visit() { - int visitX=x; - int visitY=y; - switch(direction){ - case 0: - visitY--; - break; - case 1: - visitY++; - break; - case 2: - visitX--; - break; - case 3: - visitX++; - break; - } - int leftLessage=room.seeLocation(visitX,visitY); - System.out.println("visit:"+visitX+","+visitY+":"+leftLessage); - int head=numberProcesser.headSplit(leftLessage); - leftLessage=numberProcesser.endSplit(leftLessage); -//////////////////////////////////////////////////////////////////////////////////////////////////// - switch(head) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - switch(leftLessage) { - case 1: - changeImageLabel(35,false); - bag.addItem(101); - changeLocation(visitX,visitY,201); - break; - case 2: - changeImageLabel(36,false); - bag.addItem(102); - changeLocation(visitX,visitY,202); - break; - case 3: - break; - default: - break; - } - break; - case 5: - head=numberProcesser.headSplit(leftLessage); - leftLessage=numberProcesser.endSplit(leftLessage); - switch(head) { - case 1: - String text="这个门紧锁着,再用力
也无法打开..."; - new TextDialog(gameFrame,"提示",250,180,text); - break; - case 2: - break; - case 3: - break; - default: - break; - } - default: - break; - } - } - - //改变标签 - public void changeImageLabel(int labelNumber,int layer) { - gameFrame.changeImageLabel(labelNumber,layer); - if(playerStatus==2||playerStatus==4) sendMessage("4,"+room.getRoomNumber()+","+labelNumber+","+layer); - } - - //改变标签 - public void changeImageLabel(int labelNumber,boolean isToShow) { - changeImageLabel(labelNumber,isToShow?800:50); - } - - //共同改变标签 - public void changeImageLabelTogether(int roomNumber,int labelNumber,int layer) { - if(roomNumber==room.getRoomNumber()) gameFrame.changeImageLabel(labelNumber,layer); - } - - //返回x - public int getX() { - return x; - } - - //返回y - public int getY() { - return y; - } - - //返回room - public Room getRoom() { - return room; - } - - //返回体力 - public double getPower() { - return power; - } - - //返回方向 - public int getDirection() { - return direction; - } - - //改变方向 - public void setDirection(int targetDirection) { - direction=targetDirection; - } - - //改变体力 - public void changePower(double change) { - if(change<0) { - if(power+change>0) power+=change; - else power=0; - } - else { - if(power+change=useRMB) { - RMB-=useRMB; - gameFrame.showLeftMessage("消耗 RMB * "+useRMB); - gameFrame.refreshBagDialogMoney(); - if(playerStatus==2||playerStatus==4) sendMessage("3,3,"+(-useRMB)); - return true; - } - else return false; - } - - //共同改变钱 - public void changeRMBTogether(int changeMoney) { - if(changeMoney>0) { - RMB+=changeMoney; - if(playerStatus!=3) { - gameFrame.showLeftMessage("获得 RMB * "+changeMoney); - gameFrame.refreshBagDialogMoney(); - } - } - else if(changeMoney<0) { - if(RMB+changeMoney>=0) { - RMB+=changeMoney; - gameFrame.showLeftMessage("消耗 RMB * "+(-changeMoney)); - gameFrame.refreshBagDialogMoney(); - } - } - } - - //获得背包 - public Bag getBag() { - return bag; - } - - //改变房间中坐标值 - public void changeLocation(int x,int y,int targetNumber) { - if(playerStatus==2||playerStatus==4) sendMessage("2,"+room.getRoomNumber()+","+x+","+y+","+targetNumber); - room.changeLocation(x, y, targetNumber); - int saveNullNumber=-1; - for(int i=0;i= 0 && i < map.length && j >= 0 && j < map[0].length && this.map[i][j] == 1) { - if(enableFlag[i][j] == S.OPEN) { - if(nodes[i][j].getCost() > currentNode.g + PRICE_HW + nodes[i][j].getCost() - nodes[i][j].g) { - - nodes[i][j].setFatherNode(currentNode); //新的路径更好,重新计算g值,改写父节点 - nodes[i][j].setG(currentNode.getG() + PRICE_HW); - openQueue.nodeEnqueue(nodes[i][j]); - openQueue.enqueue(nodes[i][j]); - } - }else if(enableFlag[i][j] == S.CLOSE) { - - continue;//如果该节点进入CLOSE表则进入下一次循环 - }else { - - nodes[i][j].setFatherNode(currentNode); //如果该节点未进入open,则将其放入open,计算g值,设置父节点 - nodes[i][j].setG(currentNode.getG() + PRICE_HW); - openQueue.enqueue(nodes[i][j]); - enableFlag[i][j] = S.OPEN; - } - } - } - } - } - actionArr = calculateActionArr(nodes); //计算执行动作数组 -// System.out.println("寻路:"+start_column+","+start_row+"->"+dest_column+","+dest_row); -// for(int i = 0; i < actionArr.length; i++) { -// System.out.print(actionArr[i]); -// } -// System.out.println(); - return actionArr; - } - - //将i转换为0或1 - private int calculate(int i) { - if(-1 == i || 1 == i ) { - return 0; - }else { - return 1; - } - } - - //判断坐标的输入是否合法 - public boolean isLegal(int row,int column) { - if(row < 0 || row > map.length) { - return false; - }else if(column < 0 || column > map[0].length) { - return false; - }else if(1 != map[row][column]) { - return false; - }else { - return true; - } - } - - //计算出如何执行行走动作的数组 - private int[] calculateActionArr(Node[][] nodes) { - int length = 0; //记录路径长度 - Node node = nodes[dest_row][dest_column]; - Node fatherNode = node.fathernode; - while(node.fathernode != null) { - length++; - node = node.fathernode; - } //计算出路径的长度 - node = nodes[dest_row][dest_column]; - - int[] actionArr = new int[length]; - for(int i = length - 1; i >= 0; i--) { - if(node.row == fatherNode.row) { - if(node.column - fatherNode.column == 1) { - actionArr[i] = 3; - }else { - actionArr[i] = 2; - } - }else { - if(node.row - fatherNode.row == 1) { - actionArr[i] = 1; - }else { - actionArr[i] = 0; - } - } - node = node.fathernode; - fatherNode = fatherNode.fathernode; - } - return actionArr; - } - - //初始化坐标 - private void initial(int dest_row,int dest_column) { - this.dest_column = dest_column; - this.dest_row = dest_row; - } - - //动态数组:堆的底层数据结构 - class Arr { - private Node[] data; //创建一个数组 - private int num; //数组中元素的个数 - - //自定义构造器初始化数组 capacity数组的长度 - public Arr(int capacity) { - data = new Node[capacity]; - num = 0; - } - - //默认构造方法 capacity 数组的长度等于10 - public Arr() { - this(10); - } - - //根据传来的的数组生成动态数组 - public Arr(Node[] arr) { - data = new Node[arr.length]; - for(int i = 0;i < arr.length;i++) { - data[i] = arr[i]; - } - num = arr.length; - } - - //获取数组中元素的个数 - public int getNum() { - return this.num; - } - - //获取数组的长度 - public int getLength() { - return data.length; - } - - //判断数组是否为空 - public boolean isEmpty() { - return num == 0; - } - - //数组中添加元素 index是添加的元素的位置 node是插入的元素 - public void add(int index ,Node node) { - //扩容数组 - if(num == data.length) { - resize(2 * data.length); //扩容数组两倍 - } - - for(int i = num - 1; i >= index ;i--) { - data[i + 1] = data[i]; - } - data[index] = node; - num++; - } - - //数组扩容或者缩容 - private void resize(int newcapacity) { - Node []newData = new Node[newcapacity]; - for(int i = 0;i < num; i++) - { - newData[i] = data[i]; - } - data = newData; - } - - //在数组的末尾添加元素,添加的元素为node - public void addLast(Node node) { - add(num,node); - } - - //在数组的首部添加元素,添加的元素为node - public void addFirst(Node node) { - add(0,node); - } - - //获取数组中指定位置元素的值 - Node get(int index) { - return data[index]; - } - - //获取数组最后一个元素的值 - public Node getLast() { - return get(num - 1); - } - - //获取数组第一个元素的值 - public Node getFirst() { - return get(0); - } - - //修改数组指定位置的值,修改的位置为index,修改的后的值为node - void set(int index, Node node) { - data[index] = node; - } - - //查询是否包含元素node - public boolean contains(Node node) { - for(int i =0; i < num; i++) - { - if(node == data[i]) { - return true; - } - } - return false; - } - - //查找元素node若找到返回node的位置 - public int find(Node node) { - for( int i = 0; i < num; i++) { - if(node == data[i]) { - return i;//返回元素node的位置 - } - } - return -1;//如果找不到元素node,则返回-1 - } - - //删除指定位置的index的数组元素 - public Node remove(int index) { - //缩容 - if(num == data.length/2) { - resize(data.length/2); - } - Node ret = data[index]; - for(int i = index + 1; i < num; i++) { - data[i - 1] = data[i]; - } - num--; - data[num] = null; - return ret; - } - - //删除数组的最后一个元素 - public Node removeLast() { - return remove(num - 1); - } - - //删除数组的首个元素 - public Node removeFirst() { - return remove(0); - } - - //删除数组元素node - public void removeElement(Node node) { - int index = find(node); - if(index != -1) { - remove(index); - } - else { - System.out.println("数组中不存在元素node"); - } - } - - //元素交换 - public void swap(int i, int j) { - Node t = data[i]; - data[i] = data[j]; - data[j] = t; - } - } - - //最小堆 以动态数组为底层数据结构 - class MinHeap { - private Arr data; - - - //构造函数:创建一个大小为capacity的动态数组 - public MinHeap(int capacity) { - data = new Arr(capacity); - } - - //构造函数:创建一个大小为10的动态数组 - public MinHeap() { - data = new Arr(); - } - - //构造函数 将任意数组构造成最大堆的形状 - public MinHeap(Node[] arr) { - data = new Arr(arr);//根据传来的数组生成动态数组; - for(int i =parent(arr.length - 1); i >= 0; i--) { - siftDown(i); //从最后一个非叶子节点进行下沉,一直到根节点 - } - } - - //返回最大堆的元素个数 - public int num() { - return data.getNum(); - } - - //查询最大堆是否为空 - public boolean isEmpty() { - return data.isEmpty(); - } - - //返回一个数组中一个索引所表示元素的父亲节点的索引,如果没有父节点返回-1 - private int parent(int index) { - if(0 == index) { - return -1; - } - return (index - 1)/2; - } - - //获取左孩子节点的索引 - private int leftChild(int index) { - return 2*index + 1; - } - - //获取右孩子节点的索引 - private int rightChild(int index) { - return 2*index + 2; - } - - //向堆中添加元素 - public void add(Node node) { - data.addLast(node); - siftUp(data.getNum() - 1); //元素上浮 - } - - //堆中的元素上浮 - private void siftUp(int k) { - while(k > 0 && data.get(parent(k)).getCost() > data.get(k).getCost()) { - data.swap(k, parent(k)); //与父节点交换 - k = parent(k); //k变为其父节点的索引,准备下一次循环 - } - } - - //堆中元素的下沉 - private void siftDown(int k) { - while(leftChild(k) < data.getNum()) { - int j = leftChild(k); - if(j + 1 < data.getNum()) { - if(data.get(j + 1).getCost() < data.get(j).getCost()) { - j = rightChild(k); //j左右孩子中最小值的索引 - } - if(data.get(k).getCost() < data.get(j).getCost()) { - break; //如果无法下沉则不做任何处理 - } - }else { - if(data.get(k).getCost() < data.get(j).getCost()) { - break; - } - } - data.swap(k, j); //否则将元素与较小的那个孩子节点交换 - k = j; //将索引k变为j,准备下一次循环 - } - } - - //获得堆中最小元素的值,如果堆空则返回空 - public Node findMin() { - if(data.getNum() == 0) { - return null; - } - return data.get(0); - } - - //取出堆中最小元素的值 - public Node extractMin() { - Node ret = findMin(); - data.swap(0,data.getNum() - 1); - data.removeLast(); - siftDown(0); - return ret; - } - - //取出堆中的最小元素,并且替换成元素node - public Node replace(Node node) { - Node ret = findMin(); - data.set(0, node); - siftDown(0); - return ret; - } - - //删除堆中的Node - public void removeNode(Node node) { - data.swap(data.find(node),data.getNum() - 1); - data.removeLast(); - siftDown(0); - } - } - - //优先队列,底层结构为最大堆 实现队列接口 - class PriorityQueue{ - - private MinHeap minHeap; //建立一个最大堆 - - //构造函数:建立一个优先队列 - public PriorityQueue() { - minHeap = new MinHeap(); - } - - //元素node入队 - public void enqueue(Node node) { - minHeap.add(node); - } - - //最小的元素出队 - public Node dequeue() { - return minHeap.extractMin(); - } - - //获得优先队列队头元素的值 - public Node getFront() { - return minHeap.findMin(); - } - - //获取队列的长度 - public int getNum() { - return minHeap.num(); - } - - //判断队列是否为空 - public boolean isEmpty() { - return minHeap.isEmpty(); - } - - //删除元素node - public void nodeEnqueue(Node node) { - minHeap.removeNode(node); - } - } - - //节点:存放地图节点的信息 - class Node { - private int g; //搜索节点Node已花费的代价 - private int row,column; //节点的坐标 - private int type; //当前节点的类型 - private Node fathernode; //父节点 - - //构造函数:初始化节点的信息 - public Node(int row,int column,int type) { - this.row =row; - this.column = column; - this.type = type; - } - - //设置父节点 - public void setFatherNode(Node fathernode) { - this.fathernode = fathernode; - } - - //返回搜索Node已花费的代价 - public int getG() { - return g; - } - - //设置搜索Node已花费的代价 - public void setG(int g) { - this.g =g; - } - - //获取对于节点Node总的代价估计 - public int getCost() { - return getHValue() + g; - } - - //启发式函数 - private int getHValue() { - return (Math.abs(row - dest_row) + Math.abs(column - dest_column)); - } - - //设置类型 - public void setType(int type) { - this.type = type; - } - - //返回类型 - public int getType() { - return type; - } - } - - -} diff --git a/src/calculate/Room.java b/src/calculate/Room.java deleted file mode 100644 index 08eaffc..0000000 --- a/src/calculate/Room.java +++ /dev/null @@ -1,228 +0,0 @@ -package calculate; - -public class Room { - //Room类:当前房间数据 - - private final int roomMaxImage=Constant.ROOM_MAX_IMAGE; - private int roomNumber; - private String roomName; - private int xLength; - private int yLength; - private int[][] map; - private RoomImage[] images = new RoomImage[roomMaxImage]; - private int beginX; //人物起始像素X - private int beginY; //人物起始像素Y - private int imageX; //图片起始像素X - private int imageY; //图片起始像素Y - - //构造函数 - public Room(int roomNumber) { - this.roomNumber=roomNumber; - switch(roomNumber) { - case 502: - roomName="T3502"; - xLength=34; - yLength=27; - int tempMap[][]=new int[xLength][yLength]; - for(int i=0;i1&&i<8)||(i>9&&i<24)||(i>25&&i<32)) { - if(j>4&&j<22&&j%2==1) { - tempMap[i][j]=203; - } - if(j==23) { - tempMap[i][j]=202; - } - } - if(i==0||j==0||i==33||j==26) { - tempMap[i][j]=6; - } - } - } - tempMap[6][0]=5150; - tempMap[27][0]=5151; - tempMap[9][2]=401; - tempMap[2][21]=402; - tempMap[10][2]=201; - map=tempMap; - break; - default: - break; - } - initialEmptyRoom(); - } - - //初始化空房间 - public void initialEmptyRoom() { - switch(roomNumber) { - case 502: - beginX=240; - beginY=10; - imageX=240; - imageY=10; - - images[0]=new RoomImage("floor.png",960,810,imageX+30,10,200); - images[1]=new RoomImage("blackboard.jpg",1300,60,imageX+30,0,960,60,250); - images[2]=new RoomImage("door.png",30,60,imageX+180,0,300); - images[3]=new RoomImage("door.png",30,60,imageX+810,0,300); - images[4]=new RoomImage("teacherDesk.png",83,52,imageX+257,imageY+52,300); - for(int i=0;i<27;i++) { - images[5+i]=new RoomImage("shortDesk.png",200,40,imageX+50,imageY+145+20*i,300); - i++; - images[5+i]=new RoomImage("longDesk.png",438,47,imageX+292,imageY+120+20*i,300); - i++; - images[5+i]=new RoomImage("shortDesk.png",200,40,imageX+770,imageY+105+20*i,300); - } - images[32]=new RoomImage("shortSeat.png",200,40,imageX+50,imageY+685,300); - images[33]=new RoomImage("longSeat.png",438,47,imageX+292,imageY+682,300); - images[34]=new RoomImage("shortSeat.png",200,40,imageX+770,imageY+685,300); - break; - default: - break; - } - } - - //初始化房间物品image - public void initialItemImage() { - switch(roomNumber) { - case 502: - images[35]=new RoomImage("math.png",20,10,imageX+279,imageY+60,800,50,map[9][2]==401); - images[36]=new RoomImage("paperParcel.png",20,10,imageX+60,imageY+642,800,50,map[2][21]==402); - System.out.println("initialItemImage():2,21:"+map[2][21]); - break; - default: - break; - } - } - - //获取房间名 - public String getRoomName() { - return roomName; - } - - //image是否为空 - public boolean imageIsNull(int imageNumber) { - if(images[imageNumber]==null) return true; - else return false; - } - - //获取起始像素x - public int getBeginX() { - return beginX; - } - - //获取起始像素y - public int getBeginY() { - return beginY; - } - - //获取房间号 - public int getRoomNumber() { - return roomNumber; - } - - //查看map数组在(x,y)坐标的值 - public int seeLocation(int x,int y) { - return map[x][y]; - } - - //将map数组在(x,y)坐标改变 - public void changeLocation(int x,int y,int targetNumber) { - map[x][y]=targetNumber; - } - - //获取图片文件名 - public String getFileName(int number) { - return roomName+"/"+images[number].getFileName(); - } - - //获取图片边界位置 - public int[] getBounds(int number) { - return images[number].getBounds(); - } - - //获得数组 - public int[][] getMap() { - return map; - } - - //获得翻转数组 - public int[][] getTurnMap() { - int[][] turnMap = new int[yLength][xLength]; - for(int i=0;i=maxRoom) { + sendMessage("8,3",clientNumber); + } + else { + if(seatClient[roomNumber*2+1]==-1&&seatClient[roomNumber*2]!=-1) { + seatClient[roomNumber*2+1]=clientNumber; + clientSeat[clientNumber]=roomNumber*2+1; + sendMessage("8,4",clientNumber); + sendMessage("8,5",seatClient[roomNumber*2]); + } + else { + sendMessage("8,3",clientNumber); + } + } + refreshLabels(); + } + + //创建房间申请 + public void createRoom(int clientNumber) { + if(clientSeat[clientNumber]!=-1) return; + for(int i=0;i0&&myData.getPlayerStatus()<5) { - gameFrame.showChatDialog(); - } - break; - case 80: //P 保存进度 - gameFrame.whetherSaveProgress(); - break; - default: - - break; - } - } - - //键盘释放时 - public void keyReleased(KeyEvent e) { - int code = e.getKeyCode(); - switch (code) { - case 38: //w 上箭头 移动:上 - case 87: - moveThread.setDirection(0,false); - break; - case 40: //s 下箭头 移动:下 - case 83: - moveThread.setDirection(1,false); - break; - case 37: //a 左箭头 移动:左 - case 65: - moveThread.setDirection(2,false); - break; - case 39: //d 右箭头 移动:右 - case 68: - moveThread.setDirection(3,false); - break; - case 16: //shift 加速跑 - moveThread.setShift(false); - break; - default: - - break; - } - } -} diff --git a/src/service/MoveThread.java b/src/service/MoveThread.java deleted file mode 100644 index 28ed2ca..0000000 --- a/src/service/MoveThread.java +++ /dev/null @@ -1,214 +0,0 @@ -package service; - - -import calculate.Constant; -import calculate.LinkQueue; -import calculate.MyData; -import calculate.PathSearcher; -import view.GameFrame; - -public class MoveThread extends Thread { - //MoveThread类:移动线程 - - private GameFrame gameFrame; - private int direction = 4; //4:不移动 0:上,1:下,2:左,3:右 - private MyData myData; - private boolean pressShift=false; //是否按下shift - private boolean isContinue=true; //线程是否继续 - private PathSearcher pathSearcher; - private LinkQueue moveOrdersQueue = new LinkQueue(); - - private final int originSpeed=Constant.INITIAL_SPEED; //初始速度 - private final double powerCost=Constant.POWER_COST; //加速移动一格体力值消耗 - private final int refreshTime=1000/Constant.FRAME_RATE; //刷新间隔时间 - private final int shiftSpeed=Constant.SHIFT_SPEED; //加速跑速度倍数 - private final double fullPower=Constant.FULL_POWER; //满体力值 - private final int friendAccuracy=Constant.FRIEND_ACCURACY; //好友移动速度精确度 - - //构造函数:传入myFrame - public MoveThread(GameFrame gameFrame) { - this.gameFrame=gameFrame; - myData=gameFrame.getMyData(); - pathSearcher= new PathSearcher(myData); - } - - //线程开始 - @Override - public void run() { - int singleDirection; - while(isContinue) { - singleDirection=direction; - if(singleDirection==4) { - if(moveOrdersQueue.QueueEmpty()) { - try { - sleep(10); - } catch (InterruptedException e) { - e.printStackTrace(); - } - continue; - } - else { - singleDirection=moveOrdersQueue.DeQueue(); - } - } - else{ - if(!moveOrdersQueue.QueueEmpty()) moveOrdersQueue = new LinkQueue(); - } - myData.setDirection(singleDirection); - gameFrame.refreshStopLocation(singleDirection); -// System.out.println("run:"+singleDirection); - double originX=(double)myData.getX(); //保存起点x坐标 - double originY=(double)myData.getY(); //保存起点y坐标 - boolean canMove=myData.move(singleDirection); -// System.out.println("移动至"+myData.getX()+","+myData.getY()); - if(canMove) { //若能移动 - double changeX=(double)myData.getX()-originX; //x坐标改变总量 - double changeY=(double)myData.getY()-originY; //y坐标改变总量 - double speedRate=getSpeedRate(); - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) { - double doubleSpeed = speedRate*originSpeed; - int intSpeed = (int)doubleSpeed; - int speedAfterPoint=(int)((doubleSpeed-intSpeed)*friendAccuracy); - myData.sendMessage("5,1,"+myData.getRoom().getRoomNumber()+","+ - singleDirection+","+myData.getX()+","+myData.getY()+","+intSpeed+","+speedAfterPoint); - } -// System.out.println("速度倍率"+speedRate); - - try { //根据速度设定休眠时间 - int moveTimeCost=(int) (1000/speedRate/originSpeed); //每次移动时间消耗 - double targetX; - double targetY; - for(int usedTime=0;usedTime1) { - myData.changePower(-powerCost); - } - } - else { //若不能移动 - if(myData.getPlayerStatus()==2||myData.getPlayerStatus()==4) { - myData.sendMessage("5,0,"+direction); - } - try { - sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } - - //设定移动方向 - public void setDirection(int stateNumber,boolean targetState) { - if(stateNumber>=0&&stateNumber<4){ - if(targetState) { -// System.out.println("setDirection"+stateNumber); - if(direction==4) direction=stateNumber; - } - else { - if(direction==stateNumber) { - direction=4; - } - } - } - } - - //设定是否按下shift - public void setShift(boolean targetState) { -// System.out.println("setShift: "+targetState); - pressShift=targetState; - } - - //获得速度倍率 - public double getSpeedRate() { - if(myData.getPower()>fullPower/2) { - if(pressShift) return shiftSpeed; - else return 1; - } - else { - if(pressShift) return myData.getPower()*shiftSpeed/fullPower+1; - else return 1; - } - } - - //寻路 - public void pathSearch(int x, int y) { - moveOrdersQueue = new LinkQueue(); -// System.out.println("点击目标坐标: "+x+","+y); - int moveOrders[] = pathSearcher.search(x,y); - for(int i=0;i= 0) {// 如果读出有效数据 - auline.write(auBuffer, 0, byteCount);// 将有效数据写入数据行中 - } - } - } catch (IOException e) { - e.printStackTrace(); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - } catch (LineUnavailableException e) { - e.printStackTrace(); - } finally { - auline.drain();// 清空数据行 - auline.close();// 关闭数据行 - } - } while (circulate);// 根据循环标志判断是否循环播放 - } -} \ No newline at end of file diff --git a/src/service/NumberProcesser.java b/src/service/NumberProcesser.java deleted file mode 100644 index f9c85c3..0000000 --- a/src/service/NumberProcesser.java +++ /dev/null @@ -1,25 +0,0 @@ -package service; - -//numberProcesser类:数字处理器 -public class NumberProcesser { - - //获得编码的首位 - public int headSplit(int originCode) { - String numberString=""+originCode; - return Integer.parseInt(numberString.substring(0,1)); - } - - //获得编码的剩余位 - public int endSplit(int originCode) { - String numberString=""+originCode; - numberString=numberString.substring(1); - if(numberString.length()>0) return Integer.parseInt(numberString); - else return -1; - } - - //在编码的前面添加数字 - public int addHeadNumber(int originCode,int headNumber) { - String numberString=""+headNumber+originCode; - return Integer.parseInt(numberString); - } -} diff --git a/src/service/Sound.java b/src/service/Sound.java deleted file mode 100644 index 7e70288..0000000 --- a/src/service/Sound.java +++ /dev/null @@ -1,39 +0,0 @@ -package service; - -import java.io.FileNotFoundException; - -public class Sound { - //Sound类:找到需要播放的音乐进行播放 - - final String DIR = "music/"; - MusicPlayer player; - - //播放音乐 - public void play(String fileName,boolean circulate) { - if(fileName.indexOf(".wav")<0) { - play(DIR+fileName+".wav",FileDataHandler.getBGMPercent(),circulate); - } - else { - play(DIR+fileName,FileDataHandler.getBGMPercent(),circulate); - } - } - - //临时更改音量 - public void temporaryChangeVolumn(float volumePercent) { - player.temporaryChangeVolumn(volumePercent); - } - - //播放 - private void play(String file,float volumn,boolean circulate) { - try { - player = new MusicPlayer(file,volumn,circulate); // 创建播放器 - player.play();// 播放器开始播放 - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - public void stopPlay() { - if(player!=null) player.stop(); - } - -} diff --git a/src/view/BagDialog.java b/src/view/BagDialog.java deleted file mode 100644 index a1e0979..0000000 --- a/src/view/BagDialog.java +++ /dev/null @@ -1,285 +0,0 @@ -package view; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import calculate.*; -import service.NumberProcesser; - -public class BagDialog extends JDialog{ - //BagDialog类:背包窗口 - private static final long serialVersionUID = 1L; - private int[] items = new int[Math.max(Constant.A_MAX,Constant.B_MAX)]; - private int itemKind=0; - private GameFrame gameFrame; - private MyData myData; - private JPanel Panel = new JPanel(); - private JScrollPane ScrollPane; - private JButton[] buttons = new JButton[Math.max(Constant.A_MAX,Constant.B_MAX)]; - private JButton buttonA = new JButton("道具"); - private JButton buttonB = new JButton("消耗品"); - private JButton useButton = new JButton("使用"); - private int choosenItem; - private JButton choosenButton; - private JLabel nameLabel; - private JLabel photoLabel; - private JLabel descriptionLabel; - private JLabel moneyLabel; - private FoodDictionary foodDictionary = new FoodDictionary(); - private NumberProcesser numberProcesser = new NumberProcesser(); //数字处理器 - private Bag bag; - - - public BagDialog(GameFrame frame){ - super(frame,"背包", true); - gameFrame=frame; - myData=gameFrame.getMyData(); - bag=myData.getBag(); - - setSize(1000, 800); - setLocationRelativeTo(null); - setLayout(null); - Container container = getContentPane(); // 创建一个容器 - - JLabel jl=new JLabel("道具"); - jl.setFont(new Font("宋体", Font.BOLD, 20)); - jl.setForeground(Color.BLACK); - jl.setHorizontalAlignment(SwingConstants.CENTER); - jl.setBounds(20,20,100,30); - container.add(jl); // 在容器中添加标签 - - buttonA.setFont(new Font("宋体", Font.BOLD, 20)); - buttonA.setForeground(Color.BLACK); - buttonA.setHorizontalAlignment(SwingConstants.CENTER); - buttonA.setBounds(140,20,100,30); - buttonA.setBackground(Color.LIGHT_GRAY); - buttonA.setFocusPainted(false); - buttonA.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - buttonA.setBackground(Color.LIGHT_GRAY); - buttonB.setBackground(Color.WHITE); - jl.setText("道具"); - getAItems(); - } - }); - container.add(buttonA); - - buttonB.setFont(new Font("宋体", Font.BOLD, 20)); - buttonB.setForeground(Color.BLACK); - buttonB.setHorizontalAlignment(SwingConstants.CENTER); - buttonB.setBounds(260,20,100,30); - buttonB.setBackground(Color.WHITE); - buttonB.setFocusPainted(false); - buttonB.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - buttonA.setBackground(Color.WHITE); - buttonB.setBackground(Color.LIGHT_GRAY); - jl.setText("消耗品"); - getBItems(); - } - }); - container.add(buttonB); - - moneyLabel=new JLabel("RMB:"+myData.getRMB()); - moneyLabel.setFont(new Font("宋体", Font.BOLD, 20)); - moneyLabel.setForeground(Color.BLACK); - moneyLabel.setHorizontalAlignment(SwingConstants.CENTER); - moneyLabel.setBounds(380,20,100,30); - container.add(moneyLabel); // 在容器中添加标签 - - nameLabel=new JLabel(); - nameLabel.setFont(new Font("宋体", Font.BOLD, 20)); - nameLabel.setForeground(Color.BLACK); - nameLabel.setHorizontalAlignment(SwingConstants.CENTER); - nameLabel.setBounds(550,30,400,50); - nameLabel.setBackground(Color.LIGHT_GRAY); - nameLabel.setOpaque(true); - container.add(nameLabel); // 在容器中添加标签 - - photoLabel=new JLabel(); - photoLabel.setBounds(550,100,400,300); - photoLabel.setBackground(Color.LIGHT_GRAY); - photoLabel.setOpaque(true); - photoLabel.setHorizontalAlignment(SwingConstants.CENTER); - container.add(photoLabel); // 在容器中添加标签 - - descriptionLabel=new JLabel(); - descriptionLabel.setFont(new Font("宋体", Font.BOLD, 20)); - descriptionLabel.setForeground(Color.BLACK); - descriptionLabel.setHorizontalAlignment(SwingConstants.CENTER); - descriptionLabel.setBounds(550,420,400,300); - descriptionLabel.setBackground(Color.LIGHT_GRAY); - descriptionLabel.setOpaque(true); - container.add(descriptionLabel); // 在容器中添加标签 - - useButton.setFont(new Font("宋体", Font.BOLD, 20)); - useButton.setForeground(Color.BLACK); - useButton.setHorizontalAlignment(SwingConstants.CENTER); - useButton.setBounds(851,725,100,30); - useButton.setBackground(Color.WHITE); - useButton.setFocusPainted(false); - useButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - //System.out.println("choosenItem="+choosenItem); - if(choosenItem==0) { - new TextDialog(gameFrame,"提示",300,200,"请选择要使用的物品!"); - } - else { - if(numberProcesser.headSplit(choosenItem)==2) { - bag.useItem(choosenItem); - int gainPower=foodDictionary.getFoodPower(choosenItem); - myData.changePower(gainPower); - - if(bag.getThisItemQuantity(choosenItem)>0) { - choosenButton.setText(bag.getItemName(choosenItem)+" * "+bag.getThisItemQuantity(choosenItem)); - } - else { - getBItems(); - } - } - else if(numberProcesser.headSplit(choosenItem)==1){ - boolean itemLose=true; -///////////////////////////////////////////////////////////////////////////////////////////////////// - switch(numberProcesser.endSplit(choosenItem)) { - case 2: - bag.useItem(choosenItem); - myData.addRMB(416); - break; - - - - - - default: - itemLose=false; - new TextDialog(gameFrame,"提示",300,200,"使用失败"); - break; - - } - if(itemLose) getAItems(); - } - else { - new TextDialog(gameFrame,"提示",300,200,"请选择要使用的物品!"); - } - } - } - }); - container.add(useButton); - - Panel.setLayout(null); - Panel.setBounds(30,60,500,680); - - ScrollPane= new JScrollPane(Panel); - container.add(Panel); - - ScrollPane.setLayout(null); - ScrollPane.setBounds(30,60,500,680); - ScrollPane.getVerticalScrollBar().setUnitIncrement(25);//设置灵敏度 - container.add(ScrollPane); // 在容器中添加标签 - - getAItems(); - container.setBackground (Color.white); - setResizable(false); - } - - //刷新面板显示AItem - public void getAItems() { - Panel.removeAll(); - Panel.repaint(); - refreshRMB(); - itemKind=bag.getAItemKinds(); - items=bag.getAItems(); - //System.out.println("AItemKinds:"+itemKind); - for(int i=0;ilineLength;totalLength-=lineLength) { - resultDescription+=tempDescription.substring(0, lineLength); - tempDescription=tempDescription.substring(lineLength); - resultDescription+="
"; - } - resultDescription+=tempDescription; - resultDescription+=""; - descriptionLabel.setText(resultDescription); - //System.out.println("image/itemPhotoPng/"+code+".png"); - ImageIcon photoIcon = new ImageIcon("image/itemPhotoPng/"+code+".png"); - photoIcon.setImage(photoIcon.getImage().getScaledInstance(200,280,Image.SCALE_DEFAULT)); - photoLabel.setIcon(photoIcon); - } - - //刷新RMB - public void refreshRMB() { - moneyLabel.setText("RMB:"+myData.getRMB()); - } - -} \ No newline at end of file diff --git a/src/view/ChatDialog.java b/src/view/ChatDialog.java deleted file mode 100644 index be89e9e..0000000 --- a/src/view/ChatDialog.java +++ /dev/null @@ -1,100 +0,0 @@ -package view; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.*; - -public class ChatDialog extends JDialog{ - - private static final long serialVersionUID = 1L; - private String chatMessages; - private GameFrame gameFrame; - private JLabel label = new JLabel(); - private JScrollPane scrollPane; - private JTextField textField; - private JButton handInButton; - private Container container = getContentPane(); - - public ChatDialog(GameFrame gameFrame){ - super(gameFrame,"聊天", true); - chatMessages=""; - this.gameFrame = gameFrame; - - setLayout(null); - setSize(600, 400); - setLocationRelativeTo(null); - setBackground(Color.white); - setResizable(false); - - label = new JLabel(); - label.setFont(new Font("宋体", Font.BOLD, 20)); - label.setForeground(Color.BLACK); - label.setBackground(Color.WHITE); - label.setHorizontalAlignment(SwingConstants.LEFT); - label.setVerticalAlignment(SwingConstants.BOTTOM); - - scrollPane = new JScrollPane(label); - scrollPane.setForeground(Color.black); - scrollPane.setBackground(Color.white); - scrollPane.getVerticalScrollBar().setUnitIncrement(25); //设置灵敏度 - scrollPane.setBounds(0,0,587,323); - scrollPane.setOpaque(true); - scrollPane.getViewport().setOpaque(false); - container.add(scrollPane); // 在容器中添加标签 - - textField = new JTextField("",20); - textField.setFont(new Font("宋体", Font.BOLD, 18)); - textField.setForeground(Color.black); - textField.setBackground(Color.white); - textField.setBounds(1, 323, 485, 40); - textField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String messageToSend=textField.getText(); - if(messageToSend.equals("")) { - textField.requestFocus(); - return; - } - addMessage(messageToSend,true); - gameFrame.getMyData().sendMessage("9,"+messageToSend); - textField.setText(""); - scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); - textField.requestFocus(); - } - }); - container.add(textField); - - handInButton = new JButton("发送"); - handInButton.setFont(new Font("宋体", Font.BOLD, 18)); - handInButton.setForeground(Color.black); - handInButton.setBackground(Color.white); - handInButton.setFocusPainted(false); - handInButton.setBounds(485,323,100,39); - handInButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - public void actionPerformed(ActionEvent e) { - String messageToSend=textField.getText(); - if(messageToSend.equals("")) { - textField.requestFocus(); - return; - } - addMessage(messageToSend,true); - gameFrame.getMyData().sendMessage("9,"+messageToSend); - textField.setText(""); - scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); - textField.requestFocus(); - } - }); - container.add(handInButton); - - setDefaultCloseOperation(HIDE_ON_CLOSE); - } - - //增加信息 - public void addMessage(String message,boolean senderIsMe) { - String handledMessage=(senderIsMe?"我:":"好友:")+message; - chatMessages+=handledMessage; - chatMessages+="

"; - label.setText(""+chatMessages+""); - if(!senderIsMe) gameFrame.refreshChatMessageText(handledMessage); - } -} diff --git a/src/view/CreateRoomDialog.java b/src/view/CreateRoomDialog.java deleted file mode 100644 index d41a8b2..0000000 --- a/src/view/CreateRoomDialog.java +++ /dev/null @@ -1,153 +0,0 @@ -package view; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import calculate.*; -import service.CreateRoomLAN; -import service.CreateRoomWAN; - -public class CreateRoomDialog extends JDialog { - //CreateRoomDialog类:创建房间窗口 - private static final long serialVersionUID = 1L; - private GameFrame gameFrame; - private JLabel textLabel; - private JButton startButton; - private JButton returnButton; - private boolean isLANMode; - private int status=0; //0:初始 1:房间创建成功 2:对方已加入房间 3:房间创建失败 4:正在传输数据 5:连接服务器失败 - private CreateRoomLAN createRoomLAN; - private CreateRoomWAN createRoomWAN; - - public CreateRoomDialog(GameFrame gameFrame,boolean isLANMode) { - super(gameFrame,"创建房间", true); - this.isLANMode=isLANMode; - this.gameFrame=gameFrame; - setSize(600, 400); - setLocationRelativeTo(null); - setLayout(null); - Container container = getContentPane(); // 创建一个容器 - container.setBackground (Color.white); - - textLabel=new JLabel("创建房间中..."); - textLabel.setBounds(100,50,400,150); - textLabel.setFont(new Font("宋体", Font.BOLD, 20)); - textLabel.setForeground(Color.BLACK); - textLabel.setHorizontalAlignment(SwingConstants.CENTER); - container.add(textLabel); // 在容器中添加标签 - - startButton=new JButton("开始游戏"); - startButton.setBounds(100,250,130,50); - startButton.setFont(new Font("宋体", Font.BOLD, 18)); - startButton.setForeground(Color.black); - startButton.setContentAreaFilled(false); - startButton.setFocusPainted(false); - startButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - switch(status) { - case 0: - new TextDialog(gameFrame,"提示",300,200,"正在创建房间,请稍候..."); - break; - case 1: - new TextDialog(gameFrame,"提示",300,200,"正在等待好友加入房间..."); - break; - case 2: - SendingMessage(); - if(isLANMode) { - createRoomLAN.sendMessage("0,0"); - } - else { - createRoomWAN.sendMessage("0,0"); - } - break; - case 3: - new TextDialog(gameFrame,"提示",300,200,"创建房间失败,请检查网络后重试!"); - break; - case 4: - new TextDialog(gameFrame,"提示",300,200,"正在传输数据,请稍候!"); - break; - case 5: - new TextDialog(gameFrame,"提示",300,200,"连接服务器失败,
请检查网络后重试!"); - break; - } - } - }); - container.add(startButton); - - returnButton=new JButton("返回"); - returnButton.setBounds(370,250,130,50); - returnButton.setFont(new Font("宋体", Font.BOLD, 18)); - returnButton.setForeground(Color.black); - returnButton.setContentAreaFilled(false); - returnButton.setFocusPainted(false); - returnButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - if(createRoomLAN!=null) createRoomLAN.stopConnect(); - if(createRoomWAN!=null) createRoomWAN.stopConnect(); - dispose(); - } - }); - container.add(returnButton); - - if(isLANMode) { - createRoomLAN = new CreateRoomLAN(this); - } - else { - createRoomWAN = new CreateRoomWAN(this); - } - - addWindowListener(new WindowAdapter() {// 添加窗体监听 - public void windowClosing(WindowEvent e) {// 窗体关闭前 - if(createRoomLAN!=null) createRoomLAN.stopConnect(); - if(createRoomWAN!=null) createRoomWAN.stopConnect(); - dispose(); - } - }); - setResizable(false); - setVisible(true); - } - - //房间创建成功 - public void RoomAlreadyCreate(String IP) { - status=1; - textLabel.setText("房间创建成功! 正在等待对手连接......
房间号:"+IP+ - "
把房间号告诉你的好友吧!"); - } - - //房间创建失败 - public void RoomFailCreate() { - status=3; - textLabel.setText("房间创建失败!请检查你的网络连接!"); - } - - //玩家已加入房间,等待开始游戏 - public void PlayerEnterRoom() { - status=2; - textLabel.setText("好友已连接,立刻开始游戏吧!"); - } - - //开始传输数据 - public void SendingMessage() { - status=4; - textLabel.setText("传输数据中,请稍候..."); - } - - //连接服务器失败 - public void failConnectServer() { - status=5; - textLabel.setText("连接服务器失败!
请检查你的网络!"); - } - - //获取GameFrame - public GameFrame getGameFrame() { - return gameFrame; - } - - //返回isLANMode - public boolean whetherLANMode() { - return isLANMode; - } -} diff --git a/src/view/EnterRoomDialog.java b/src/view/EnterRoomDialog.java deleted file mode 100644 index a90bf5f..0000000 --- a/src/view/EnterRoomDialog.java +++ /dev/null @@ -1,219 +0,0 @@ -package view; - -import javax.swing.JDialog; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import calculate.*; -import service.EnterRoomLAN; -import service.EnterRoomWAN; - -public class EnterRoomDialog extends JDialog{ - //CreateRoomDialog类:创建房间窗口 - private static final long serialVersionUID = 1L; - private MenuFrame menuFrame; - private JButton enterLANButton; - private JButton enterWANButton; - private JButton returnButton; - private JLabel textLabel; - private JTextField EnterRoomJT=new JTextField("",20); - private int status=0; //0:初始 1:正在连接房间 2:已连接房间 3:正在接收数据 4:连接服务器失败 - private EnterRoomLAN enterRoomLAN; - private EnterRoomWAN enterRoomWAN; - - public EnterRoomDialog(MenuFrame menuFrame) { - super(menuFrame,"加入房间", true); - - this.menuFrame=menuFrame; - setSize(600, 400); - setLocationRelativeTo(null); - setLayout(null); - Container container = getContentPane(); // 创建一个容器 - container.setBackground (Color.white); - - textLabel=new JLabel("请输入房间号:"); - textLabel.setBounds(100,50,400,70); - textLabel.setFont(new Font("宋体", Font.BOLD, 20)); - textLabel.setForeground(Color.BLACK); - textLabel.setHorizontalAlignment(SwingConstants.CENTER); - container.add(textLabel); - - EnterRoomJT.setFont(new Font("微软雅黑",0,18)); - EnterRoomJT.setBounds(100, 150, 400, 40); - EnterRoomJT.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - if(getRoomNumber().indexOf(".")==-1) { //广域网 - switch(status) { - case 0: - enterRoomWAN = new EnterRoomWAN(EnterRoomDialog.this); - break; - case 1: - new TextDialog(menuFrame,"提示",300,200,"正在连接房间..."); - break; - case 2: - new TextDialog(menuFrame,"提示",300,200,"已连接房间!"); - break; - case 3: - new TextDialog(menuFrame,"提示",300,200,"正在同步数据,请稍候..."); - break; - } - } - else { //局域网 - switch(status) { - case 0: - enterRoomLAN = new EnterRoomLAN(EnterRoomDialog.this); - break; - case 1: - new TextDialog(menuFrame,"提示",300,200,"正在连接房间..."); - break; - case 2: - new TextDialog(menuFrame,"提示",300,200,"已连接房间!"); - break; - case 3: - new TextDialog(menuFrame,"提示",300,200,"正在同步数据,请稍候..."); - break; - } - } - } - }); - container.add(EnterRoomJT); -// EnterRoomJT.requestFocus(); - - enterLANButton=new JButton("加入局域网房间"); - enterLANButton.setBounds(80,250,180,50); - enterLANButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterLANButton.setForeground(Color.black); - enterLANButton.setContentAreaFilled(false); - enterLANButton.setFocusPainted(false); - enterLANButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - switch(status) { - case 0: - case 4: - if(enterRoomWAN!=null) { - enterRoomWAN.stopConnect(); - enterRoomWAN=null; - } - enterRoomLAN = new EnterRoomLAN(EnterRoomDialog.this); - break; - case 1: - new TextDialog(menuFrame,"提示",300,200,"正在连接房间..."); - break; - case 2: - new TextDialog(menuFrame,"提示",300,200,"已连接房间!"); - break; - case 3: - new TextDialog(menuFrame,"提示",300,200,"正在同步数据,请稍候..."); - break; - } - } - }); - container.add(enterLANButton); - - enterWANButton=new JButton("加入广域网房间"); - enterWANButton.setBounds(340,250,180,50); - enterWANButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterWANButton.setForeground(Color.black); - enterWANButton.setContentAreaFilled(false); - enterWANButton.setFocusPainted(false); - enterWANButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - switch(status) { - case 0: - if(enterRoomWAN==null) enterRoomWAN = new EnterRoomWAN(EnterRoomDialog.this); - else enterRoomWAN.sendMessage("7,2,"+getRoomNumber()); - break; - case 1: - new TextDialog(menuFrame,"提示",300,200,"正在连接中..."); - break; - case 2: - new TextDialog(menuFrame,"提示",300,200,"已连接房间!"); - break; - case 3: - new TextDialog(menuFrame,"提示",300,200,"正在同步数据,请稍候..."); - break; - case 4: - new TextDialog(menuFrame,"提示",300,200,"连接服务器失败!请检查网络!"); - } - } - }); - container.add(enterWANButton); - - returnButton=new JButton("返回"); - returnButton.setBounds(20,10,100,30); - returnButton.setFont(new Font("宋体", Font.BOLD, 18)); - returnButton.setForeground(Color.black); - returnButton.setContentAreaFilled(false); - returnButton.setFocusPainted(false); - returnButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - if(enterRoomLAN!=null) enterRoomLAN.stopConnect(); - if(enterRoomWAN!=null) enterRoomWAN.stopConnect(); - dispose(); - } - }); - container.add(returnButton); - - addWindowListener(new WindowAdapter() {// 添加窗体监听 - @Override - public void windowClosing(WindowEvent e) {// 窗体关闭前 - if(enterRoomLAN!=null) enterRoomLAN.stopConnect(); - if(enterRoomWAN!=null) enterRoomWAN.stopConnect(); - dispose(); - } - @Override - public void windowOpened(WindowEvent e) { //弹出框打开时文本框获取焦点 - EnterRoomJT.requestFocus(); - } - }); - setResizable(false); - setVisible(true); - } - - //正在连接房间 - public void isConnecting() { - status=1; - textLabel.setText("正在连接中...
请稍候"); - } - - //已加入房间 - public void alreadyEnter() { - status=2; - textLabel.setText("成功加入房间!
等待房主开始游戏..."); - } - - //加入房间失败 - public void failEnter() { - status=0; - EnterRoomJT.requestFocus(); - textLabel.setText("加入房间失败!
请检查你的网络或房间号是否正确!"); - } - - //连接服务器失败 - public void failConnectServer() { - status=4; - textLabel.setText("连接服务器失败!
请检查你的网络!"); - } - - //正在接收数据 - public void receiveData() { - status=3; - textLabel.setText("正在同步数据中..."); - } - - //获得输入的房间号 - public String getRoomNumber() { - return EnterRoomJT.getText(); - } - - //获得MenuFrame - public MenuFrame getMenuFrame() { - return menuFrame; - } - -} diff --git a/src/view/GameFrame.java b/src/view/GameFrame.java deleted file mode 100644 index 5237c32..0000000 --- a/src/view/GameFrame.java +++ /dev/null @@ -1,884 +0,0 @@ -package view; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import calculate.*; -import service.*; - -public class GameFrame extends JFrame{ - //GameFrame类: 游戏界面 (继承JFrame类) - private static final long serialVersionUID = 1L; - private final int unitLength=Constant.UNIT_LENGTH; - private final int fullPower=(int)Constant.FULL_POWER; - private final int roomMaxImage=Constant.ROOM_MAX_IMAGE; - private MenuFrame menuFrame; - private int beginX; - private int beginY; - private int sex; - private MyData myData; //游戏数据 - private MoveThread moveThread; //移动线程 - private boolean leftLabelShowing; //左侧信息标签正在显示 - private boolean middleLabelShowing; //中侧信息标签正在显示 - private BagDialog bagDialog; - private LinkQueue leftMessageQueue = new LinkQueue(); - private LinkQueue middleMessageQueue = new LinkQueue(); - private Sound sound = new Sound(); - private FriendMoveController friendMoveController; - private SetChatMessageThread setChatMessageThread; - private ChatDialog chatDialog; - - private JLabel playerLabel; //玩家标签 - private JLabel friendLabel; //好友标签 - private JLabel powerLabel; //体力标签 - private JLabel blackLabel; //黑色背景标签 - private JLabel roomNameLabel; //房间名标签 - private JLabel leftMessageLabel; //左侧信息标签 - private JLabel middleMessageLabel; //中侧信息标签 - private JLabel chatMessageLabel; //聊天信息标签 - private JLabel[] labels = new JLabel[roomMaxImage]; - private JLayeredPane gameLayeredPane; //层级面板 - - private ImageIcon playerUpImageStop[] = new ImageIcon[2]; - private ImageIcon playerUpImageRun[] = new ImageIcon[2]; - private ImageIcon playerDownImageStop[] = new ImageIcon[2]; - private ImageIcon playerDownImageRun[] = new ImageIcon[2]; - private ImageIcon playerRightImageStop[] = new ImageIcon[2]; - private ImageIcon playerRightImageRun[] = new ImageIcon[2]; - private ImageIcon playerLeftImageStop[] = new ImageIcon[2]; - private ImageIcon playerLeftImageRun[] = new ImageIcon[2]; - - //构造函数:生成游戏界面 - public GameFrame(MenuFrame menuFrame,int playerStatus,int sex) { - this.menuFrame=menuFrame; - this.sex=sex; - myData=new MyData(this,playerStatus); - moveThread=new MoveThread(this); - moveThread.start(); - Room room=myData.getRoom(); - beginX=room.getBeginX(); - beginY=room.getBeginY(); - - setLayout(null); - setSize(1500, 830); - setLocationRelativeTo(null); - - gameLayeredPane= new JLayeredPane(); - gameLayeredPane.setLayout(null); - gameLayeredPane.setSize(1500, 830); - setContentPane(gameLayeredPane); - - KeyListener keyListener = new GameKeyListener(this); - addKeyListener(keyListener); - - playerUpImageStop[0] = new ImageIcon("image/Boy/actor_u.png"); - playerUpImageStop[0].setImage(playerUpImageStop[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerUpImageRun[0] = new ImageIcon("image/Boy/actor_u.gif"); - playerUpImageRun[0].setImage(playerUpImageRun[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerDownImageStop[0] = new ImageIcon("image/Boy/actor_d.png"); - playerDownImageStop[0].setImage(playerDownImageStop[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerDownImageRun[0] = new ImageIcon("image/Boy/actor_d.gif"); - playerDownImageRun[0].setImage(playerDownImageRun[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerRightImageStop[0] = new ImageIcon("image/Boy/actor_r.png"); - playerRightImageStop[0].setImage(playerRightImageStop[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerRightImageRun[0] = new ImageIcon("image/Boy/actor_r.gif"); - playerRightImageRun[0].setImage(playerRightImageRun[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerLeftImageStop[0] = new ImageIcon("image/Boy/actor_l.png"); - playerLeftImageStop[0].setImage(playerLeftImageStop[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerLeftImageRun[0] = new ImageIcon("image/Boy/actor_l.gif"); - playerLeftImageRun[0].setImage(playerLeftImageRun[0].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - - playerUpImageStop[1] = new ImageIcon("image/Girl/actor_u.png"); - playerUpImageStop[1].setImage(playerUpImageStop[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerUpImageRun[1] = new ImageIcon("image/Girl/actor_u.gif"); - playerUpImageRun[1].setImage(playerUpImageRun[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerDownImageStop[1] = new ImageIcon("image/Girl/actor_d.png"); - playerDownImageStop[1].setImage(playerDownImageStop[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerDownImageRun[1] = new ImageIcon("image/Girl/actor_d.gif"); - playerDownImageRun[1].setImage(playerDownImageRun[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerRightImageStop[1] = new ImageIcon("image/Girl/actor_r.png"); - playerRightImageStop[1].setImage(playerRightImageStop[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerRightImageRun[1] = new ImageIcon("image/Girl/actor_r.gif"); - playerRightImageRun[1].setImage(playerRightImageRun[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerLeftImageStop[1] = new ImageIcon("image/Girl/actor_l.png"); - playerLeftImageStop[1].setImage(playerLeftImageStop[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - playerLeftImageRun[1] = new ImageIcon("image/Girl/actor_l.gif"); - playerLeftImageRun[1].setImage(playerLeftImageRun[1].getImage().getScaledInstance(30,30,Image.SCALE_DEFAULT)); - - playerLabel=new JLabel(playerUpImageStop[sex]); - playerLabel.setBounds(unitLength*myData.getX()+beginX,unitLength*myData.getY()+beginY,unitLength,unitLength); - - friendLabel=new JLabel(playerUpImageStop[1-sex]); - friendLabel.setBounds(unitLength*myData.getX()+beginX,unitLength*myData.getY()+beginY,unitLength,unitLength); - - powerLabel=new JLabel(); - powerLabel.setFont(new Font("微软雅黑", Font.BOLD, 15)); - powerLabel.setForeground(Color.white); - powerLabel.setBounds(8,5,135,30); - powerLabel.setHorizontalAlignment(SwingConstants.CENTER); - - roomNameLabel=new JLabel(); - roomNameLabel.setFont(new Font("Times New Roman", Font.BOLD, 23)); - roomNameLabel.setForeground(Color.white); - roomNameLabel.setBounds(1385,10,100,30); - roomNameLabel.setHorizontalAlignment(SwingConstants.CENTER); - - leftMessageLabel=new JLabel(); - leftMessageLabel.setOpaque(true); - leftMessageLabel.setBackground(Color.white); - leftMessageLabel.setFont(new Font("宋体", Font.BOLD, 18)); - leftMessageLabel.setForeground(Color.black); - leftMessageLabel.setBounds(5,300,250,150); - leftMessageLabel.setHorizontalAlignment(SwingConstants.CENTER); - - middleMessageLabel=new JLabel(); - middleMessageLabel.setOpaque(true); - middleMessageLabel.setBackground(Color.white); - middleMessageLabel.setFont(new Font("宋体", Font.BOLD, 18)); - middleMessageLabel.setForeground(Color.black); - middleMessageLabel.setBounds(500,250,500,300); - middleMessageLabel.setHorizontalAlignment(SwingConstants.CENTER); - - chatMessageLabel=new JLabel(); - chatMessageLabel.setOpaque(true); - chatMessageLabel.setBackground(Color.white); - chatMessageLabel.setFont(new Font("宋体", Font.BOLD, 18)); - chatMessageLabel.setForeground(Color.black); - chatMessageLabel.setBounds(5,680,250,100); - chatMessageLabel.setHorizontalAlignment(SwingConstants.LEFT); - chatMessageLabel.setVerticalAlignment(SwingConstants.CENTER); - - ImageIcon blackIcon = new ImageIcon("image/GameFrame/black.png"); - blackIcon.setImage(blackIcon.getImage().getScaledInstance(1500,830,Image.SCALE_DEFAULT)); - blackLabel=new JLabel(blackIcon); - blackLabel.setBounds(0,0,1500,830); - - addMouseListener(new MouseAdapter(){ //匿名内部类,鼠标事件 - public void mouseClicked(MouseEvent e){ //鼠标完成点击事件 - if(e.getButton() == MouseEvent.BUTTON1){ //e.getButton就会返回点鼠标的那个键,左键还是右健,3代表右键 -// System.out.println("点击位置: "+e.getX()+","+e.getY()); - int x=e.getX(); - int y=e.getY(); - moveThread.pathSearch((x-beginX)/unitLength,(y-beginY-30)/unitLength); - } - } - }); - - ImageIcon icon = new ImageIcon("image/GameFrame/icon.png"); //窗口图标 - setIconImage(icon.getImage()); - setTitle("Exploratiaon"); // 标题 - setBackground(Color.BLACK); - setResizable(false); - addWindowListener(new WindowAdapter() {// 添加窗体监听 - public void windowClosing(WindowEvent e) {// 窗体关闭前 - System.exit(0); - } - }); - - } - - //加载房间界面组件 - public void loadComponents() { - Room room=myData.getRoom(); - room.initialItemImage(); - gameLayeredPane.removeAll(); - gameLayeredPane.repaint(); - - leftLabelShowing=false; - middleLabelShowing=false; - int[] bounds=new int[6]; - ImageIcon icon; - for(int i=0;i13) { - message=""+message.substring(0, 13)+"
"+message.substring(13)+""; - } - leftMessageQueue.EnQueue(message); - if(!leftLabelShowing) { - leftLabelShowing=true; - Runnable leftMessageThread = () -> { - do{ - leftMessageLabel.setText(leftMessageQueue.DeQueue()); - gameLayeredPane.setLayer(leftMessageLabel,new Integer(1000)); - try { - Thread.sleep(2500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - gameLayeredPane.setLayer(leftMessageLabel,new Integer(50)); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //System.out.println("队列size:"+leftMessageQueue.size); - }while(!leftMessageQueue.QueueEmpty()); - leftLabelShowing=false; - }; - Thread leftMessageLine = new Thread(leftMessageThread); - leftMessageLine.start(); - } - } - - //中侧提示信息 - public void showMiddleMessage(String message) { - int lineLength=20; - String tempMessage=message; - String resultMessage=""; - for(int totalLength = tempMessage.length();totalLength>lineLength;totalLength-=lineLength) { - resultMessage+=tempMessage.substring(0, lineLength); - tempMessage=tempMessage.substring(lineLength); - resultMessage+="
"; - } - resultMessage+=tempMessage; - resultMessage+= "

(点击空格以继续)"; - resultMessage+=""; - middleMessageQueue.EnQueue(resultMessage); - if(!middleLabelShowing) { - middleLabelShowing=true; - middleMessageLabel.setText(middleMessageQueue.DeQueue()); - gameLayeredPane.setLayer(middleMessageLabel,new Integer(1000)); - } - } - - //中侧信息翻页 - public void turnMiddleMessage() { - if(middleLabelShowing) { - if(middleMessageQueue.QueueEmpty()) { - gameLayeredPane.setLayer(middleMessageLabel,new Integer(50)); - middleLabelShowing=false; - } - else { - middleMessageLabel.setText(middleMessageQueue.DeQueue()); - } - } - } - - //询问是否退出游戏 - public void whetherExit() { - JDialog exitDialog = new JDialog(this,"提示",true); - exitDialog.setLayout(null); - exitDialog.setSize(400, 180); - exitDialog.setLocationRelativeTo(null); - Container container = exitDialog.getContentPane(); // 创建一个容器 - - JLabel exitLabel=new JLabel("是否退出游戏?"); - exitLabel.setFont(new Font("宋体", Font.BOLD, 20)); - exitLabel.setForeground(Color.BLACK); - exitLabel.setHorizontalAlignment(SwingConstants.CENTER); - exitLabel.setBounds(95,20,200,40); - container.add(exitLabel); // 在容器中添加标签 - - JButton exitButton = new JButton("退出"); - exitButton.setFont(new Font("宋体", Font.BOLD, 18)); - exitButton.setForeground(Color.BLACK); - exitButton.setContentAreaFilled(false); - exitButton.setFocusPainted(false); - exitButton.setBounds(25, 100, 100, 30); - exitButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - System.exit(0); - } - }); - container.add(exitButton); - - JButton menuButton = new JButton("主菜单"); - menuButton.setFont(new Font("宋体", Font.BOLD, 18)); - menuButton.setForeground(Color.BLACK); - menuButton.setContentAreaFilled(false); - menuButton.setFocusPainted(false); - menuButton.setBounds(145, 100, 100, 30); - menuButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - sound.stopPlay(); - dispose(); - menuFrame.visibleAndPlayBGM(); - } - }); - container.add(menuButton); - - JButton cancelButton = new JButton("取消"); - cancelButton.setFont(new Font("宋体", Font.BOLD, 18)); - cancelButton.setForeground(Color.BLACK); - cancelButton.setContentAreaFilled(false); - cancelButton.setFocusPainted(false); - cancelButton.setBounds(265, 100, 100, 30); - cancelButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - exitDialog.dispose(); - } - }); - container.add(cancelButton); - - container.setBackground (Color.white); - exitDialog.setResizable(false); - exitDialog.setVisible(true); - } - - //改变音量 - public void changeVolume() { - JDialog exitDialog = new JDialog(this,"音量",true); - exitDialog.setLayout(null); - exitDialog.setSize(320,200); - exitDialog.setLocationRelativeTo(null); - Container container = exitDialog.getContentPane(); // 创建一个容器 - - String text="主音量

 音乐

 音效"; - JLabel volumeLabel=new JLabel(text); - volumeLabel.setFont(new Font("宋体",Font.BOLD, 20)); - volumeLabel.setForeground(Color.BLACK); - volumeLabel.setHorizontalAlignment(SwingConstants.CENTER); - volumeLabel.setBounds(5,5,73,130); - container.add(volumeLabel); - - int volumes[]=FileDataHandler.getVolumes(); - JSlider masterVolumeSlider=getSlider(volumes[0]); - masterVolumeSlider.setBounds(80, 10,200, 40); - masterVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[0]=masterVolumeSlider.getValue(); - sound.temporaryChangeVolumn(((float)volumes[0]*volumes[1])/10000); - } - }); - container.add(masterVolumeSlider); - - JSlider bgmVolumeSlider=getSlider(volumes[1]); - bgmVolumeSlider.setBounds(80, 60, 200, 40); - bgmVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[1]=bgmVolumeSlider.getValue(); - sound.temporaryChangeVolumn(((float)volumes[0]*volumes[1])/10000); - } - }); - container.add(bgmVolumeSlider); - - JSlider soundEffectVolumnVolumeSlider=getSlider(volumes[2]); - soundEffectVolumnVolumeSlider.setBounds(80, 110, 200, 40); - soundEffectVolumnVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[2]=soundEffectVolumnVolumeSlider.getValue(); - } - }); - container.add(soundEffectVolumnVolumeSlider); - - container.setBackground (Color.white); - exitDialog.setResizable(false); - exitDialog.addWindowListener(new WindowAdapter() {// 添加窗体监听 - public void windowClosing(WindowEvent e) {// 窗体关闭前 - FileDataHandler.changeVolulmes(volumes); - FileDataHandler.saveSettings(); - } - }); - exitDialog.setVisible(true); - } - - //按格式创建一个滑块 - public JSlider getSlider(int unitValue) { - JSlider slider=new JSlider(0,100,unitValue); - slider.setMajorTickSpacing(20); // 设置主刻度间隔 - slider.setMinorTickSpacing(5); // 设置次刻度间隔 - slider.setPaintTicks(true); // 绘制 刻度 和 标签 - slider.setPaintLabels(true); - slider.setFont(new Font("微软雅黑",Font.BOLD, 10)); - slider.setForeground(Color.black); - slider.setOpaque(false); - return slider; - } - - //新游戏开头 - public void startNewGame() { - showMiddleMessage("你醒来了,揉了揉眼,站了起来。你面前是一本沾着你的口水的计算机导论"+ - "可能你计导课又睡着了...你发现了你的包,包里还有一些东西。这是哪?"); - showMiddleMessage("提示:如果忘记操作方式可以点击‘H’查看帮助。"); - showLeftMessage("背包 已解锁 点击'B'可查看背包!"); - myData.getBag().addItem(100); - myData.getBag().addItem(200); - myData.addRMB(200); - myData.setPlayerStatus(5); - } - - //询问是否创建房间 - public void whetherCreateRoom(){ - JDialog wcreateRoomDialog = new JDialog(this,"提示",true); - wcreateRoomDialog.setLayout(null); - wcreateRoomDialog.setSize(300, 400); - wcreateRoomDialog.setLocationRelativeTo(null); - Container container = wcreateRoomDialog.getContentPane(); // 创建一个容器 - - JLabel wcreateRoomLabel=new JLabel("是否创建房间?"); - wcreateRoomLabel.setFont(new Font("宋体", Font.BOLD, 25)); - wcreateRoomLabel.setForeground(Color.BLACK); - wcreateRoomLabel.setHorizontalAlignment(SwingConstants.CENTER); - wcreateRoomLabel.setBounds(45,30,200,40); - container.add(wcreateRoomLabel); // 在容器中添加标签 - - JButton enterLANButton = new JButton("创建局域网房间"); - enterLANButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterLANButton.setForeground(Color.BLACK); - enterLANButton.setContentAreaFilled(false); - enterLANButton.setFocusPainted(false); - enterLANButton.setBounds(60, 100, 180, 50); - enterLANButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - wcreateRoomDialog.dispose(); - new CreateRoomDialog(GameFrame.this,true); - } - }); - container.add(enterLANButton); - - JButton enterWANButton = new JButton("创建广域网房间"); - enterWANButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterWANButton.setForeground(Color.BLACK); - enterWANButton.setContentAreaFilled(false); - enterWANButton.setFocusPainted(false); - enterWANButton.setBounds(60, 180, 180, 50); - enterWANButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - wcreateRoomDialog.dispose(); - new CreateRoomDialog(GameFrame.this,false); - } - }); - container.add(enterWANButton); - - JButton cancelButton = new JButton("取消"); - cancelButton.setFont(new Font("宋体", Font.BOLD, 18)); - cancelButton.setForeground(Color.BLACK); - cancelButton.setContentAreaFilled(false); - cancelButton.setFocusPainted(false); - cancelButton.setBounds(60, 260, 180, 40); - cancelButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - wcreateRoomDialog.dispose(); - } - }); - container.add(cancelButton); - - container.setBackground (Color.white); - wcreateRoomDialog.setResizable(false); - wcreateRoomDialog.setVisible(true); - } - - //改变图片标签的层数 - public void changeImageLabel(int labelNumber,int layer) { - if(labels[labelNumber]!=null) gameLayeredPane.setLayer(labels[labelNumber],new Integer(layer)); - } - - //展示界面 - public void visible() { - setVisible(true); - sound.play("bgmGame1", true); - } - - //隐藏界面 - public void invisible() { - sound.stopPlay(); - setVisible(false); - } - - //改变 BagDialog的显示状态 - public void bagDialogSetVisible(boolean whetherShow) { - if(whetherShow) { - if(bagDialog==null) { - bagDialog = new BagDialog(this); - bagDialog.setVisible(true); - } - else { - bagDialog.getAItems(); - bagDialog.setVisible(true); - } - } - else { - if(bagDialog!=null) { - bagDialog.setVisible(false); - } - } - } - - //刷新BagDialog金币显示 - public void refreshBagDialogMoney() { - if(bagDialog!=null) { - bagDialog.refreshRMB(); - } - } - - //是否在界面上显示好友 - public void showFriendCharacter(boolean show) { - if(show) { - if(friendMoveController==null) { - friendMoveController = new FriendMoveController(); - } - } - gameLayeredPane.setLayer(friendLabel,new Integer(show?500:50)); - } - - //在界面上初始化好友标签 - public void initFriendCharacter() { - friendMoveController = new FriendMoveController(); - setChatMessageThread = new SetChatMessageThread(); - setChatMessageThread.start(); - chatDialog = new ChatDialog(this); - showFriendCharacter(true); - } - - //退出多人联机模式 - public void exitOnlineMode() { - showFriendCharacter(false); - if(setChatMessageThread!=null) { - setChatMessageThread.threadContinue=false; - setChatMessageThread=null; - } - if(chatDialog!=null) { - chatDialog.dispose(); - chatDialog=null; - } - } - - //处理收到的聊天信息 - public void receiveChatMessage(String message) { - if(chatDialog!=null) chatDialog.addMessage(message,false); - } - - //显示chatDialog - public void showChatDialog() { - if(chatDialog!=null) chatDialog.setVisible(true); - } - - //刷新好友的方向(静止) - public void refreshFriendDirection(int direction) { - friendMoveController.direction=direction; - switch(direction) { - case 0: - friendLabel.setIcon(playerUpImageStop[1-sex]); - break; - case 1: - friendLabel.setIcon(playerDownImageStop[1-sex]); - break; - case 2: - friendLabel.setIcon(playerLeftImageStop[1-sex]); - break; - case 3: - friendLabel.setIcon(playerRightImageStop[1-sex]); - break; - } -// System.out.println("refreshFriendDirection:"+direction); - } - - //刷新好友的方向(静止) - public void refreshFriendDirection() { - switch(friendMoveController.direction) { - case 0: - friendLabel.setIcon(playerUpImageStop[1-sex]); - break; - case 1: - friendLabel.setIcon(playerDownImageStop[1-sex]); - break; - case 2: - friendLabel.setIcon(playerLeftImageStop[1-sex]); - break; - case 3: - friendLabel.setIcon(playerRightImageStop[1-sex]); - break; - } -// System.out.println("refreshFriendDirection:"+direction); - } - - //FriendMoveController内部类: 控制好友移动 - class FriendMoveController{ - private boolean isMoving=false; - private int targetX; - private int targetY; - private double currentX; - private double currentY; - private double leftTime; - private int direction; - private final double frameTime = 1.0/Constant.FRAME_RATE; - private final int friendAccuracy=Constant.FRIEND_ACCURACY; //好友移动速度精确度 - - //构造函数:初始化好友角色标签 - public FriendMoveController() { - direction = myData.getDirection(); - switch(direction) { - case 0: - friendLabel.setIcon(playerUpImageStop[1-sex]); - break; - case 1: - friendLabel.setIcon(playerDownImageStop[1-sex]); - break; - case 2: - friendLabel.setIcon(playerLeftImageStop[1-sex]); - break; - case 3: - friendLabel.setIcon(playerRightImageStop[1-sex]); - break; - } - setXYLocation(myData.getX(),myData.getY()); - } - - //构造函数:初始化好友角色标签 - public FriendMoveController(int x,int y,int direction) { - refreshFriendDirection(direction); - setXYLocation(x,y); - } - - //按xy设定标签位置并保存xy - public void setXYLocation(int x,int y) { - currentX=x; - currentY=y; - friendLabel.setLocation(x*unitLength+beginX,y*unitLength+beginY); - } - - //按xy设定标签位置并保存xy(double) - public void setXYLocation(double x,double y) { - currentX=x; - currentY=y; - friendLabel.setLocation((int)(x*unitLength+beginX),(int)(y*unitLength+beginY)); - //System.out.println("标签位置:"+(int)(x*unitLength+beginX)+","+(int)(y*unitLength+beginY)); - } - - //好友移动指令 - public void move(int roomNumber,int direction,int x,int y,int intSpeed,int speedAfterPoint) { - if(roomNumber==myData.getRoom().getRoomNumber()) { - targetX=x; - targetY=y; - this.direction=direction; - if(JLayeredPane.getLayer(friendLabel)==50) { - setXYLocation(targetX,targetY); - refreshFriendDirection(this.direction); - gameLayeredPane.setLayer(friendLabel,new Integer(500)); - return; - } - //System.out.println("好友移动至"+targetX+","+targetY); - double speed=((double)speedAfterPoint)*friendAccuracy+intSpeed; - switch(this.direction) { - case 0: - friendLabel.setIcon(playerUpImageRun[1-sex]); - break; - case 1: - friendLabel.setIcon(playerDownImageRun[1-sex]); - break; - case 2: - friendLabel.setIcon(playerLeftImageRun[1-sex]); - break; - case 3: - friendLabel.setIcon(playerRightImageRun[1-sex]); - break; - } - leftTime = 1.0/speed; - if(!isMoving){ - isMoving=true; - Runnable moveThread = () -> { - double doubleX; - double doubleY; - while(leftTime>0) { - doubleX=((double)(targetX-currentX))*frameTime/leftTime+currentX; - doubleY=((double)(targetY-currentY))*frameTime/leftTime+currentY; - setXYLocation(doubleX,doubleY); - //System.out.println("好友标签位置:"+currentX+","+currentY); - leftTime-=frameTime; - try { - Thread.sleep((int)(1000*frameTime)); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - setXYLocation(targetX,targetY); - refreshFriendDirection(); - isMoving=false; - }; - Thread moveLine = new Thread(moveThread); - moveLine.start(); - } - } - else { - showFriendCharacter(false); - } - } - } - - //选择好友聊天信息提示标签显示的信息 - public void refreshChatMessageText(String message) { - if(setChatMessageThread==null) return; - setChatMessageThread.chatLabelLeftTime=5000; - chatMessageLabel.setText(message); - } - - //接收聊天信息线程类 - class SetChatMessageThread extends Thread{ - private boolean threadContinue=true; - private int chatLabelLeftTime=0; //左侧信息标签显示剩余时间 - @Override - public void run(){ - while(threadContinue) { - if(chatLabelLeftTime>0) { - gameLayeredPane.setLayer(chatMessageLabel,new Integer(1000)); - chatLabelLeftTime-=50; - } - else { - gameLayeredPane.setLayer(chatMessageLabel,new Integer(50)); - } - try { - Thread.sleep(50); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } - - //刷新好友移动角色位置 - public void refreshFriendRunLocation(int roomNumber,int direction,int x,int y,int intSpeed,int speedAfterPoint){ - friendMoveController.move(roomNumber, direction, x, y,intSpeed,speedAfterPoint); - } - - //询问是否保存进度 - public void whetherSaveProgress() { - JDialog saveDialog = new JDialog(this,"保存",true); - saveDialog.setLayout(null); - saveDialog.setSize(400, 220); - saveDialog.setLocationRelativeTo(null); - Container container = saveDialog.getContentPane(); // 创建一个容器 - - JLabel saveLabel=new JLabel(" 是否保存当前的游戏进度?
已保存的游戏进度将被覆盖"); - saveLabel.setFont(new Font("宋体", Font.BOLD, 18)); - saveLabel.setForeground(Color.BLACK); - saveLabel.setHorizontalAlignment(SwingConstants.CENTER); - saveLabel.setBounds(0,20,400,60); - container.add(saveLabel); // 在容器中添加标签 - - JButton enterButton = new JButton("确定"); - enterButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterButton.setForeground(Color.BLACK); - enterButton.setContentAreaFilled(false); - enterButton.setFocusPainted(false); - enterButton.setBounds(55, 120, 100, 30); - enterButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - myData.saveProgress(); - saveDialog.dispose(); - showLeftMessage("进度已保存"); - } - }); - container.add(enterButton); - - JButton cancelButton = new JButton("取消"); - cancelButton.setFont(new Font("宋体", Font.BOLD, 18)); - cancelButton.setForeground(Color.BLACK); - cancelButton.setContentAreaFilled(false); - cancelButton.setFocusPainted(false); - cancelButton.setBounds(235, 120, 100, 30); - cancelButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - saveDialog.dispose(); - } - }); - container.add(cancelButton); - - container.setBackground (Color.white); - saveDialog.setResizable(false); - saveDialog.setVisible(true); - } - -} diff --git a/src/view/LoadingFrame.java b/src/view/LoadingFrame.java deleted file mode 100644 index bc5a2f8..0000000 --- a/src/view/LoadingFrame.java +++ /dev/null @@ -1,156 +0,0 @@ -package view; - -import javax.swing.JFrame; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -import calculate.Constant; -import service.FileDataHandler; -import service.Sound; - -public class LoadingFrame extends JFrame implements MouseListener{ - //LoadingFrame类: 加载界面 - private static final long serialVersionUID = 1L; - private boolean canShowMenuFrame=false; - private MenuFrame menuFrame; -// private Sound sound = new Sound(); - private JLayeredPane loadingLayeredPane; //层级面板 - private JLabel backgroundLabel; //背景图片 - private JLabel explorationLabel; //Exploration图片 - private JLabel projectTeamLabel; //项目组图片 - private JLabel progressStatusLabel; //加载状态标签 - private JProgressBar progressBar; //进度条 - private int frameRate=Constant.FRAME_RATE; //动画帧率 - private int sleepTime=800/frameRate; //每帧休眠时间 - - - //构造方法:加载组件,创建加载MenuFrame线程 - public LoadingFrame() { - super("Exploration"); - //sound.playBGMMenu(); - setLayout(null); - setSize(600, 600); - setLocationRelativeTo(null); - - loadingLayeredPane= new JLayeredPane(); - loadingLayeredPane.setLayout(null); - loadingLayeredPane.setSize(600, 600); - - progressBar=new JProgressBar(); - progressBar.setStringPainted(true); - progressBar.setBounds(380,500,180,30); - setProgressValue(0); - - ImageIcon backgroundIcon = new ImageIcon("image/LoadingFrame/background.jpg"); - backgroundIcon.setImage(backgroundIcon.getImage().getScaledInstance(700,600,Image.SCALE_DEFAULT)); - backgroundLabel=new JLabel(backgroundIcon); - backgroundLabel.setBounds(-90, 0, 700, 600); - - ImageIcon explorationIcon = new ImageIcon("image/LoadingFrame/Exploration.png"); - explorationIcon.setImage(explorationIcon.getImage().getScaledInstance(500,110,Image.SCALE_DEFAULT)); - explorationLabel=new JLabel(explorationIcon); - explorationLabel.setBounds(50,70,500,110); - - ImageIcon projectTeamIcon = new ImageIcon("image/LoadingFrame/projectTeam.png"); - projectTeamIcon.setImage(projectTeamIcon.getImage().getScaledInstance(200,90,Image.SCALE_DEFAULT)); - projectTeamLabel=new JLabel(projectTeamIcon); - projectTeamLabel.setBounds(0,0,200,90); - - progressStatusLabel=new JLabel("加载中"); - progressStatusLabel.setFont(new Font("宋体", Font.BOLD, 20)); - progressStatusLabel.setForeground(Color.white); - progressStatusLabel.setBounds(50,500,150,30); - progressStatusLabel.setHorizontalAlignment(SwingConstants.CENTER); - - loadingLayeredPane.add(progressBar,new Integer(300)); - loadingLayeredPane.add(backgroundLabel,new Integer(200)); - loadingLayeredPane.add(explorationLabel,new Integer(300)); - loadingLayeredPane.add(progressStatusLabel,new Integer(300)); - loadingLayeredPane.add(projectTeamLabel,new Integer(300)); - - ImageIcon icon = new ImageIcon("image/LoadingFrame/icon.png"); //窗口图标 - setIconImage(icon.getImage()); - addWindowListener(new WindowAdapter() {// 添加窗体监听 - public void windowClosing(WindowEvent e) {// 窗体关闭前 - System.exit(0); - } - }); - addMouseListener(this); - setContentPane(loadingLayeredPane); - setResizable(false); - setVisible(true); - - Runnable projectTeamThread = () -> { - int singleFrameNumbers=frameRate/3; - int x; - for(int i=0;i { - setProgressValue(0); - FileDataHandler.initSettings(); - setProgressValue(50); - menuFrame=new MenuFrame(this); - setProgressValue(100); - canShowMenuFrame=true; - progressStatusLabel.setText("点击任意处继续"); - }; - Thread loadingLine = new Thread(loadingThread); - loadingLine.start(); - - } - - //设置加载进度 - public void setProgressValue(int n) { - progressBar.setValue(n); - } - - - //鼠标点击显示菜单界面 - @Override - public void mouseClicked(MouseEvent e) {} - - @Override - public void mousePressed(MouseEvent e) { - if(canShowMenuFrame) { - dispose(); - menuFrame.visibleAndPlayBGM(); - } - } - @Override - public void mouseReleased(MouseEvent e) {} - - @Override - public void mouseEntered(MouseEvent e) {} - - @Override - public void mouseExited(MouseEvent e) {} - - - - - -} diff --git a/src/view/MenuFrame.java b/src/view/MenuFrame.java deleted file mode 100644 index 719b1db..0000000 --- a/src/view/MenuFrame.java +++ /dev/null @@ -1,428 +0,0 @@ -package view; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -import calculate.Constant; -import calculate.MyData; -import service.FileDataHandler; -import service.Sound; - -public class MenuFrame extends JFrame implements ActionListener{ - //MenuFrame类: 菜单界面 - private static final long serialVersionUID = 1L; - private LoadingFrame loadingFrame; //加载窗口 - private JLayeredPane layeredPane; //层级面板 - - private JButton newGameButton; //创建游戏 - private JButton continueGameButton; //继续游戏 - private JButton enterRoomButton; //加入房间 - private JButton exitButton; //退出游戏 - private JButton updateLogButton; //更新日志 - private JButton helpButton; //帮助 - private JButton developerButton; //开发人员 - private JButton settingButton; //设置 - private JButton returnButton; //返回主菜单 - private JButton sexChangeButton; //改变性别 - private JLabel backgroundLabel; //背景图片 - private JLabel titleLabel; //标题图片 - private JLabel helpLabel; //帮助标签 - private JLabel developerLabel; //开发人员标签 - private JLabel updateLogLabel; //更新日志标签 - private JLabel sexLabel; //性别标签 - private JScrollPane updateLogScrollPane; //更新日志滚动条面板 - private JLabel volumeLabel; //音量标签 - private JSlider masterVolumeSlider; //主音量滑动条 - private JSlider bgmVolumeSlider; //音乐音量滑动条 - private JSlider soundEffectVolumnVolumeSlider; //音效音量滑动条 - - private int status=0; //当前显示状态 0:menu 1:update 2:help 3:developer 4:setting - private int[] volumes; - private int sex; - private Sound sound = new Sound(); //音乐选择 - private final String[] sexString = {"男","女"}; - - public MenuFrame(LoadingFrame sendLoadingFrame) { - super("Exploration"); - loadingFrame=sendLoadingFrame; - setLayout(null); - setSize(1000, 630); - setLocationRelativeTo(null); - - layeredPane= new JLayeredPane(); - layeredPane.setLayout(null); - layeredPane.setSize(1000, 630); - - ImageIcon backgroundIcon = new ImageIcon("image/MenuFrame/background.jpg"); - backgroundIcon.setImage(backgroundIcon.getImage().getScaledInstance(1000,630,Image.SCALE_DEFAULT)); - backgroundLabel=new JLabel(backgroundIcon); - backgroundLabel.setBounds(0, 0, 1000, 630); - - ImageIcon titleIcon = new ImageIcon("image/MenuFrame/title.png"); - titleIcon.setImage(titleIcon.getImage().getScaledInstance(800,180,Image.SCALE_DEFAULT)); - titleLabel=new JLabel(titleIcon); - titleLabel.setBounds(145,130,800,200); - loadingFrame.setProgressValue(55);// - - newGameButton=getButton("创建游戏",175, 380, 200, 50,25); - continueGameButton=getButton("继续游戏",610, 380, 200, 50,25); - enterRoomButton=getButton("加入房间",235, 470, 200, 50,25); - exitButton=getButton("退出游戏",550, 470, 200, 50,25); - updateLogButton=getButton("更新日志",25, 25, 130, 30,20); - helpButton=getButton("帮助",55, 80, 100, 30,20); - sexChangeButton=getButton("更改",550, 300, 100, 30,20); - developerButton=getButton("开发人员",835, 25, 130, 30,20); - settingButton=getButton("设置",835, 80, 100, 30,20); - returnButton=getButton("返回",835, 500, 100, 30,20); - - loadingFrame.setProgressValue(60);// - - helpLabel = new JLabel(Constant.HELP_TEXT); - helpLabel.setFont(new Font("宋体", Font.BOLD, 20)); - helpLabel.setForeground(Color.white); - helpLabel.setBounds(0, 0, 1000, 570); - helpLabel.setHorizontalAlignment(SwingConstants.CENTER); - loadingFrame.setProgressValue(67);// - - developerLabel = new JLabel(Constant.DEVELOPER_TEXT); - developerLabel.setFont(new Font("宋体", Font.BOLD, 20)); - developerLabel.setForeground(Color.white); - developerLabel.setBounds(0, 0, 1000, 570); - developerLabel.setHorizontalAlignment(SwingConstants.CENTER); - loadingFrame.setProgressValue(75);// - - updateLogLabel = new JLabel(Constant.UPDATELOG_TEXT); - updateLogLabel.setFont(new Font("宋体", Font.BOLD, 20)); - updateLogLabel.setForeground(Color.white); - updateLogLabel.setBounds(200,35,600,520); - updateLogLabel.setHorizontalAlignment(SwingConstants.CENTER); - - updateLogScrollPane = new JScrollPane(updateLogLabel); - updateLogScrollPane.getVerticalScrollBar().setUnitIncrement(15);//设置灵敏度 - updateLogScrollPane.getVerticalScrollBar().setOpaque(false); - updateLogScrollPane.setBounds(170,0,640,595); - updateLogScrollPane.setOpaque(false); - updateLogScrollPane.getViewport().setOpaque(false); - loadingFrame.setProgressValue(82); - - volumes=FileDataHandler.getVolumes(); - sex=FileDataHandler.getSex(); - - sexLabel = new JLabel("当前性别: "+sexString[sex]); - sexLabel.setFont(new Font("宋体", Font.BOLD, 20)); - sexLabel.setForeground(Color.white); - sexLabel.setBounds(300, 300, 150, 30); - sexLabel.setHorizontalAlignment(SwingConstants.CENTER); - - String text="主音量


 音乐


 音效"; - volumeLabel=new JLabel(text); - volumeLabel.setFont(new Font("宋体",Font.BOLD, 20)); - volumeLabel.setForeground(Color.white); - volumeLabel.setHorizontalAlignment(SwingConstants.CENTER); - volumeLabel.setBounds(220,40,75,200); - - masterVolumeSlider=getSlider(volumes[0]); - masterVolumeSlider.setBounds(300, 60, 400, 50); - masterVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[0]=masterVolumeSlider.getValue(); - sound.temporaryChangeVolumn(((float)volumes[0]*volumes[1])/10000); - } - }); - - bgmVolumeSlider=getSlider(volumes[1]); - bgmVolumeSlider.setBounds(300, 130, 400, 50); - bgmVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[1]=bgmVolumeSlider.getValue(); - sound.temporaryChangeVolumn(((float)volumes[0]*volumes[1])/10000); - } - }); - - soundEffectVolumnVolumeSlider=getSlider(volumes[2]); - soundEffectVolumnVolumeSlider.setBounds(300, 200, 400, 50); - soundEffectVolumnVolumeSlider.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - volumes[2]=soundEffectVolumnVolumeSlider.getValue(); - } - }); - loadingFrame.setProgressValue(90); - - layeredPane.add(backgroundLabel,new Integer(200)); - addMenuComponent(); - - ImageIcon icon = new ImageIcon("image/MenuFrame/icon.png"); //窗口图标 - setIconImage(icon.getImage()); - addWindowListener(new WindowAdapter() {// 添加窗体监听 - public void windowClosing(WindowEvent e) {// 窗体关闭前 - System.exit(0); - } - }); - setContentPane(layeredPane); - setResizable(false); - loadingFrame.setProgressValue(99); - } - - //添加主菜单的组件 - public void addMenuComponent() { - layeredPane.add(titleLabel,new Integer(300)); - layeredPane.add(newGameButton,new Integer(300)); - layeredPane.add(continueGameButton,new Integer(300)); - layeredPane.add(enterRoomButton,new Integer(300)); - layeredPane.add(exitButton,new Integer(300)); - layeredPane.add(updateLogButton,new Integer(300)); - layeredPane.add(helpButton,new Integer(300)); - layeredPane.add(developerButton,new Integer(300)); - layeredPane.add(settingButton,new Integer(300)); - } - - //移除主菜单的组件 - public void removeMenuComponent() { - layeredPane.remove(titleLabel); - layeredPane.remove(newGameButton); - layeredPane.remove(continueGameButton); - layeredPane.remove(enterRoomButton); - layeredPane.remove(exitButton); - layeredPane.remove(updateLogButton); - layeredPane.remove(helpButton); - layeredPane.remove(developerButton); - layeredPane.remove(settingButton); - } - - //添加更新日志的组件 - public void addUpdateLogComponent() { - layeredPane.add(updateLogScrollPane,new Integer(300)); - layeredPane.add(returnButton,new Integer(300)); - } - - //移除更新日志的组件 - public void removeUpdateLogComponent() { - layeredPane.remove(updateLogScrollPane); - layeredPane.remove(returnButton); - } - - //添加帮助的组件 - public void addHelpComponent() { - layeredPane.add(helpLabel,new Integer(300)); - layeredPane.add(returnButton,new Integer(300)); - } - - //移除帮助的组件 - public void removeHelpComponent() { - layeredPane.remove(helpLabel); - layeredPane.remove(returnButton); - } - - //添加开发人员的组件 - public void addDeveloperComponent() { - layeredPane.add(developerLabel,new Integer(300)); - layeredPane.add(returnButton,new Integer(300)); - } - - //移除开发人员的组件 - public void removeDeveloperComponent() { - layeredPane.remove(developerLabel); - layeredPane.remove(returnButton); - } - - //添加设置的组件 - public void addSettingComponent() { - layeredPane.add(volumeLabel,new Integer(300)); - layeredPane.add(masterVolumeSlider,new Integer(300)); - layeredPane.add(bgmVolumeSlider,new Integer(300)); - layeredPane.add(soundEffectVolumnVolumeSlider,new Integer(300)); - layeredPane.add(sexLabel,new Integer(300)); - layeredPane.add(sexChangeButton,new Integer(300)); - layeredPane.add(returnButton,new Integer(300)); - } - - //移除设置的组件 - public void removeSettingComponent() { - layeredPane.remove(volumeLabel); - layeredPane.remove(masterVolumeSlider); - layeredPane.remove(bgmVolumeSlider); - layeredPane.remove(soundEffectVolumnVolumeSlider); - layeredPane.remove(sexLabel); - layeredPane.remove(sexChangeButton); - layeredPane.remove(returnButton); - } - - //按格式创建一个滑块 - public JSlider getSlider(int unitValue) { - JSlider slider=new JSlider(0,100,unitValue); - slider.setMajorTickSpacing(20); // 设置主刻度间隔 - slider.setMinorTickSpacing(5); // 设置次刻度间隔 - slider.setPaintTicks(true); // 绘制 刻度 和 标签 - slider.setPaintLabels(true); - slider.setFont(new Font("微软雅黑",Font.BOLD, 18)); - slider.setForeground(Color.white); - slider.setOpaque(false); - return slider; - } - - //按格式创建一个按钮 - public JButton getButton(String buttonName,int x,int y,int width,int height,int fontSize) { - JButton button = new JButton(buttonName); - button.setFont(new Font("宋体", Font.BOLD, fontSize)); - button.setForeground(Color.white); - button.setContentAreaFilled(false); - button.setFocusPainted(false); - button.setBounds(x, y, width, height); - button.addActionListener(this); - return button; - } - - //按钮的事件监听器方法 - @Override - public void actionPerformed(ActionEvent e) { - if (e.getSource() == newGameButton) { - invisibleAndStopBGM(); - GameFrame gameFrame = new GameFrame(this,0,sex); - gameFrame.loadComponents(); - gameFrame.visible(); - gameFrame.startNewGame(); - } - if (e.getSource() == continueGameButton) { - if(FileDataHandler.progressFileExist()) { - invisibleAndStopBGM(); - GameFrame gameFrame = new GameFrame(this,6,sex); - gameFrame.getMyData().loadProgress(); - gameFrame.getMyData().setPlayerStatus(5); - gameFrame.initGameFrame(); - gameFrame.visible(); - } - else { - new TextDialog(this,"读取失败",350,200,"读取失败,无游戏进度文件!"); - } - } - if (e.getSource() == enterRoomButton) { - new EnterRoomDialog(this); - } - if (e.getSource() == exitButton) { - whetherExit(); - } - if (e.getSource() == updateLogButton) { - status=1; - removeMenuComponent(); - layeredPane.repaint(); - addUpdateLogComponent(); - layeredPane.revalidate(); - } - if (e.getSource() == helpButton) { - status=2; - removeMenuComponent(); - layeredPane.repaint(); - addHelpComponent(); - layeredPane.revalidate(); - } - if (e.getSource() == developerButton) { - status=3; - removeMenuComponent(); - layeredPane.repaint(); - addDeveloperComponent(); - layeredPane.revalidate(); - } - if (e.getSource() == settingButton) { - status=4; - volumes=FileDataHandler.getVolumes(); - sex=FileDataHandler.getSex(); - removeMenuComponent(); - layeredPane.repaint(); - addSettingComponent(); - layeredPane.revalidate(); - } - if(e.getSource() == sexChangeButton) { - sex=1-sex; - sexLabel.setText("当前性别: "+sexString[sex]); - } - if (e.getSource() == returnButton) { - switch(status) { - case 1: - removeUpdateLogComponent(); - break; - case 2: - removeHelpComponent(); - break; - case 3: - removeDeveloperComponent(); - break; - case 4: - removeSettingComponent(); - FileDataHandler.changeVolulmes(volumes); - FileDataHandler.changeSex(sex); - FileDataHandler.saveSettings(); - break; - } - status=0; - layeredPane.repaint(); - addMenuComponent(); - layeredPane.revalidate(); - } - } - - //显示界面并播放音乐 - public void visibleAndPlayBGM() { - setVisible(true); - sound.play("bgmMenu", true); - } - - //隐藏界面并停止播放音乐 - public void invisibleAndStopBGM() { - sound.stopPlay(); - setVisible(false); - } - - //询问是否退出游戏 - public void whetherExit() { - JDialog exitDialog = new JDialog(this,"提示",true); - exitDialog.setLayout(null); - exitDialog.setSize(300, 180); - exitDialog.setLocationRelativeTo(null); - Container container = exitDialog.getContentPane(); // 创建一个容器 - - JLabel exitLabel=new JLabel("是否退出游戏?"); - exitLabel.setFont(new Font("宋体", Font.BOLD, 20)); - exitLabel.setForeground(Color.BLACK); - exitLabel.setHorizontalAlignment(SwingConstants.CENTER); - exitLabel.setBounds(45,20,200,40); - container.add(exitLabel); // 在容器中添加标签 - - JButton enterButton = new JButton("确定"); - enterButton.setFont(new Font("宋体", Font.BOLD, 18)); - enterButton.setForeground(Color.BLACK); - enterButton.setContentAreaFilled(false); - enterButton.setFocusPainted(false); - enterButton.setBounds(30, 100, 80, 30); - enterButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - System.exit(0); - } - }); - container.add(enterButton); - - JButton cancelButton = new JButton("取消"); - cancelButton.setFont(new Font("宋体", Font.BOLD, 18)); - cancelButton.setForeground(Color.BLACK); - cancelButton.setContentAreaFilled(false); - cancelButton.setFocusPainted(false); - cancelButton.setBounds(180, 100, 80, 30); - cancelButton.addActionListener(new ActionListener() { // 为按钮添加鼠标单击事件 - @Override - public void actionPerformed(ActionEvent e) { - exitDialog.dispose(); - } - }); - container.add(cancelButton); - - container.setBackground (Color.white); - exitDialog.setResizable(false); - exitDialog.setVisible(true); - } - -} \ No newline at end of file diff --git a/src/view/TextDialog.java b/src/view/TextDialog.java deleted file mode 100644 index fe4aee4..0000000 --- a/src/view/TextDialog.java +++ /dev/null @@ -1,41 +0,0 @@ -package view; - -import java.awt.*; -import javax.swing.*; - -public class TextDialog extends JDialog { - //TextDialog类:弹出的文字窗口 - - private static final long serialVersionUID = 1L; - public TextDialog(JFrame frame,String title,int width,int height,String text){ - super(frame, title, true); - setSize(width, height); - setLocationRelativeTo(null); - Container container = getContentPane(); // 创建一个容器 - - JLabel jl=new JLabel(text); - jl.setFont(new Font("宋体", Font.BOLD, 20)); - jl.setForeground(Color.BLACK); - jl.setHorizontalAlignment(SwingConstants.CENTER); - container.add(jl); // 在容器中添加标签 - - container.setBackground (Color.white); - setVisible(true); - } - - public TextDialog(JFrame frame,String title,int width,int height,String text,boolean visible){ - super(frame, title, true); - setSize(width, height); - setLocationRelativeTo(null); - Container container = getContentPane(); // 创建一个容器 - - JLabel jl=new JLabel(text); - jl.setFont(new Font("宋体", Font.BOLD, 20)); - jl.setForeground(Color.BLACK); - jl.setHorizontalAlignment(SwingConstants.CENTER); - container.add(jl); // 在容器中添加标签 - - container.setBackground (Color.white); - setVisible(visible); - } -} \ No newline at end of file