-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from saiblo/feat-generals_release
try to release general player
- Loading branch information
Showing
19 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body { padding: 0; margin: 0 } | ||
#unity-container { position: absolute } | ||
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) } | ||
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% } | ||
#unity-canvas { background: #231F20 } | ||
.unity-mobile #unity-canvas { width: 100%; height: 100% } | ||
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none } | ||
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center } | ||
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center } | ||
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center } | ||
#unity-footer { position: relative } | ||
.unity-mobile #unity-footer { display: none } | ||
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center } | ||
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px } | ||
#unity-fullscreen-button { cursor:pointer; float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center } | ||
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-us"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<title>Container</title> | ||
</head> | ||
|
||
<body> | ||
<iframe src="player.html" height="900" width="1600" id="player"> | ||
</iframe> | ||
<div id="GamePlay buttons"> | ||
<button id="play-button">Play</button> | ||
<input type="checkbox" id="guest-mode" checked> Guest </input> | ||
<button id="replay-button">Replay</button> | ||
<button id="spectate-button">Spectate</button> | ||
<button id="save-button">Save</button> | ||
<button id="next-frame-button"> >> </button> | ||
<label id ="__frame_cnt"></label> | ||
<input/> | ||
</div> | ||
<div id="DebugButtons"> | ||
Ant: ( | ||
<input id="ant_x" type="text"></input> | ||
, | ||
<input id="ant_y" type="text"></input> | ||
) | ||
<button id="Spawn_Ant"> Spawn Ant </button> | ||
Ant ID: | ||
<input id="Del_ant_id" type="text"></input> | ||
<button id="Del_Ant"> Delete Ant </button> | ||
<button id="Max_Coins"> Max Coins </button> | ||
<input id="Mitigate_Logic" type="checkbox" checked>Mitigate Logic</input> | ||
</div> | ||
<script> | ||
const player = document.querySelector('#player') | ||
var replayBtn = document.querySelector('#replay-button'); | ||
var nextFrameBtn = document.querySelector('#next-frame-button'); | ||
var saveBtn = document.querySelector('#save-button'); | ||
var playBtn = document.querySelector('#play-button'); | ||
var spectateBtn = document.querySelector('#spectate-button'); | ||
var frame_cnt_label = document.querySelector('#__frame_cnt'); | ||
var guestCheckBox = document.getElementById("guest-mode"); | ||
var SpawnAnt = document.querySelector('#Spawn_Ant') | ||
var DelAnt = document.querySelector('#Del_Ant') | ||
var MaxCoins = document.querySelector('#Max_Coins') | ||
var AntX = document.querySelector('#ant_x') | ||
var AntY = document.querySelector('#ant_y') | ||
var Mitigate_Logic = document.querySelector('#Mitigate_Logic') | ||
var Del_ant_id = document.querySelector('#Del_ant_id') | ||
|
||
var framecnt = 0 | ||
var currframe = 1 | ||
nextFrameBtn.onclick = () => { | ||
if(currframe >= framecnt) return | ||
SendToChild({ | ||
message: 'load_next_frame' | ||
}) | ||
currframe++ | ||
frame_cnt_label.innerHTML = currframe + ' / ' + framecnt | ||
}; | ||
|
||
saveBtn.onclick = () => { | ||
SendToChild({ | ||
message: 'save_result' | ||
}) | ||
}; | ||
|
||
playBtn.onclick = () => { | ||
SendToChild({ | ||
message: 'init_player_player', | ||
token: guestCheckBox.checked ? 'MTI3LjAuMC4xOjIzMDAx' : 'MTI3LjAuMC4xOjIzMDAw' | ||
}) | ||
}; | ||
|
||
spectateBtn.onclick = () => { | ||
SendToChild({ | ||
message: 'init_spectator_player', | ||
token: 'MTI3LjAuMC4xOjg3NjU=' | ||
}) | ||
}; | ||
|
||
replayBtn.onclick = () => { | ||
var input = document.createElement('input'); | ||
input.type = 'file'; | ||
|
||
input.onchange = e => { | ||
|
||
// getting a hold of the file reference | ||
var file = e.target.files[0]; | ||
SendToChild({ | ||
message: "init_replay_player", | ||
replay_data: file | ||
}) | ||
} | ||
|
||
input.click(); | ||
} | ||
const SendToChild = payload => | ||
player.contentWindow.postMessage(payload) | ||
let tokenB64 = null | ||
let ws = null | ||
window.onmessage = event => { | ||
const payload = event.data | ||
console.log(payload) | ||
switch(payload.message) { | ||
case 'init_successfully': | ||
framecnt = payload.number_of_frames | ||
frame_cnt_label.innerHTML = '1 / ' + framecnt | ||
break | ||
case 'resized': | ||
player.height = payload.height | ||
break | ||
case 'setB64': | ||
ws = payload.socket | ||
tokenB64 = payload.token | ||
break | ||
default: | ||
console.error('Type ' + payload.message + ' not implemented') | ||
break | ||
} | ||
} | ||
SpawnAnt.onclick = () => { | ||
const content = [{ | ||
id: -1, | ||
type: Mitigate_Logic.checked ? 7: 91, | ||
pos: { | ||
x: Number(AntX.value), | ||
y: Number(AntY.value), | ||
}, | ||
args: -1, | ||
}] | ||
const str_content = JSON.stringify(content) | ||
const send_packet = { | ||
message: 'ToSocket', | ||
request: 'action', | ||
token: tokenB64, | ||
content: str_content | ||
} | ||
SendToChild(send_packet) | ||
} | ||
DelAnt.onclick = () => { | ||
const content = [{ | ||
id: Number(Del_ant_id.value), | ||
type: Mitigate_Logic.checked ? 8: 92, | ||
pos: { | ||
x: -1, | ||
y: -1, | ||
}, | ||
args: -1, | ||
}] | ||
const str_content = JSON.stringify(content) | ||
const send_packet = { | ||
message: 'ToSocket', | ||
request: 'action', | ||
token: tokenB64, | ||
content: str_content | ||
} | ||
SendToChild(send_packet) | ||
} | ||
MaxCoins.onclick = () => { | ||
const content = [{ | ||
id: -1, | ||
type: Mitigate_Logic.checked ? 9: 93, | ||
pos: {x: -1, y: -1}, | ||
args: -1, | ||
}] | ||
const str_content = JSON.stringify(content) | ||
const send_packet = { | ||
message: 'ToSocket', | ||
request: 'action', | ||
token: tokenB64, | ||
content: str_content | ||
} | ||
SendToChild(send_packet) | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.