Skip to content

Commit 191b8df

Browse files
committed
Added C++ helper tool to handle the procedural generation of submarine tasks.
1 parent 1e023fc commit 191b8df

24 files changed

+322
-20
lines changed
-55 Bytes
Binary file not shown.
179 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Content/UI/submarine.uasset

0 Bytes
Binary file not shown.

Submariner Server/app.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ var app = require('express')();
22
var http = require('http').Server(app);
33
var io = require('socket.io')(http);
44
var util = require('util');
5+
var exec = require('child_process').exec;
6+
function execute(command, callback) {
7+
exec(command, function(error, stdout, stderr) { callback(stdout); });
8+
};
9+
510
var clients = [];
611

712
// Interactable object states
@@ -89,35 +94,41 @@ io.on('connection', function(socket) {
8994
// lose = wait 10 seconds.
9095
var loop = function() {
9196

92-
// Check for game start
97+
// Check for game start (all characters selected)
9398
if (captainSelect && gunnerSelect &&
9499
navigatorSelect && engineerSelect) {
95100
gameStart = true;
96101
}
97102

98-
// Check for victory
99-
if (buttonPress && leverPull && crankTurn && handlePull && !gameOver) {
100-
gameOver = true;
101-
console.log("sending win");
102-
io.sockets.emit('win', { text: 'You win!' });
103+
if (gameStart) {
104+
105+
// Generate a task
106+
generateTask(function(state) {
107+
console.log(state);
108+
});
109+
110+
// Check for victory
111+
if (buttonPress && leverPull && crankTurn && handlePull && !gameOver) {
112+
gameOver = true;
113+
console.log("sending win");
114+
io.sockets.emit('win', { text: 'You win!' });
103115

104-
// Reset the game
105-
resetGame();
106-
}
116+
// Reset the game
117+
resetGame();
118+
}
107119

108-
// Check for defeat; wait for game start (all characters selected)
109-
if (gameStart && deciseconds >= 100 && !gameOver) {
120+
// Check for defeat
121+
if (deciseconds >= 600 && !gameOver) {
110122

111-
gameOver = true;
112-
console.log("sending lose");
113-
io.sockets.emit('lose', { text: 'You lose!' });
123+
gameOver = true;
124+
console.log("sending lose");
125+
io.sockets.emit('lose', { text: 'You lose!' });
114126

115-
// Reset the game
116-
resetGame();
117-
}
127+
// Reset the game
128+
resetGame();
129+
}
118130

119-
// Increment timer
120-
if (gameStart) {
131+
// Increment timer
121132
deciseconds++;
122133
}
123134
};
@@ -138,7 +149,14 @@ var resetGame = function() {
138149
gameStart = false;
139150
gameOver = false;
140151
deciseconds = 0;
141-
}
152+
};
153+
154+
// Generate a task
155+
var generateTask = function(callback) {
156+
execute("SubmarinerHelper.exe", function(object) {
157+
callback({ state: object });
158+
});
159+
};
142160

143161
// Launch the server.
144162
http.listen(3000, function() {
415 KB
Binary file not shown.
908 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
 SubmarinerHelper.cpp
2+
SubmarinerHelper.vcxproj -> E:\Unreal Projects\Submariner\SubmarinerHelper\SubmarinerHelper\Debug\SubmarinerHelper.exe
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)