mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
camera overview thing + rsg multiplayer (no sounds currently)
This commit is contained in:
parent
a1c4691466
commit
651726bb06
7 changed files with 120 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import mis.MisParser;
|
||||||
import h3d.col.Bounds;
|
import h3d.col.Bounds;
|
||||||
import h3d.col.Plane;
|
import h3d.col.Plane;
|
||||||
import h3d.mat.Material;
|
import h3d.mat.Material;
|
||||||
|
|
@ -68,6 +69,11 @@ class CameraController extends Object {
|
||||||
|
|
||||||
public var oob:Bool = false;
|
public var oob:Bool = false;
|
||||||
public var finish:Bool = false;
|
public var finish:Bool = false;
|
||||||
|
public var overview:Bool = false;
|
||||||
|
|
||||||
|
var overviewCenter:Vector;
|
||||||
|
var overviewWidth:Vector;
|
||||||
|
var overviewHeight:Float;
|
||||||
|
|
||||||
var _ignoreCursor:Bool = false;
|
var _ignoreCursor:Bool = false;
|
||||||
|
|
||||||
|
|
@ -164,10 +170,73 @@ class CameraController extends Object {
|
||||||
// CameraPitch = 0.001;
|
// CameraPitch = 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function startOverview() {
|
||||||
|
var worldBounds = new Bounds();
|
||||||
|
var center = new Vector(0, 0, 0);
|
||||||
|
for (itr in level.interiors) {
|
||||||
|
var itrBounds = itr.getBounds();
|
||||||
|
worldBounds.add(itrBounds);
|
||||||
|
center.load(center.add(itrBounds.getCenter().toVector()));
|
||||||
|
}
|
||||||
|
if (level.interiors.length == 0) {
|
||||||
|
worldBounds.xMin = -1;
|
||||||
|
worldBounds.xMax = 1;
|
||||||
|
worldBounds.yMin = -1;
|
||||||
|
worldBounds.yMax = 1;
|
||||||
|
worldBounds.zMin = -1;
|
||||||
|
worldBounds.zMax = 1;
|
||||||
|
} else
|
||||||
|
center.scale(1 / level.interiors.length);
|
||||||
|
|
||||||
|
overviewWidth = new Vector(worldBounds.xMax - worldBounds.xMin, worldBounds.yMax - worldBounds.yMin, worldBounds.zMax - worldBounds.zMin);
|
||||||
|
if (level.mission.missionInfo.overviewwidth != null) {
|
||||||
|
var parseTest = MisParser.parseVector3(level.mission.missionInfo.overviewwidth);
|
||||||
|
if (parseTest != null) {
|
||||||
|
overviewWidth = parseTest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
overviewHeight = level.mission.missionInfo.overviewheight != null ? Std.parseFloat(level.mission.missionInfo.overviewheight) : 0.0;
|
||||||
|
overviewCenter = center;
|
||||||
|
|
||||||
|
overview = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stopOverview() {
|
||||||
|
overview = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doOverviewCamera(currentTime:Float, dt:Float) {
|
||||||
|
var angle = Util.adjustedMod(2 * currentTime * Math.PI / 100.0, 2 * Math.PI);
|
||||||
|
var distance = overviewWidth.multiply(2.0 / 3.0);
|
||||||
|
var offset = new Vector(Math.sin(angle) * distance.x, Math.cos(angle) * distance.y);
|
||||||
|
var position = overviewCenter.add(offset);
|
||||||
|
|
||||||
|
var top = overviewCenter.z + (overviewWidth.z / 2) + overviewHeight;
|
||||||
|
position.z = top;
|
||||||
|
|
||||||
|
var posDist = Math.sqrt((position.x - overviewCenter.x) * (position.x - overviewCenter.x)
|
||||||
|
+ (position.y - overviewCenter.y) * (position.y - overviewCenter.y));
|
||||||
|
var upOffset = Math.tan(0.5) * posDist / 2;
|
||||||
|
// position.load(position.add(new Vector(0, 0, upOffset)));
|
||||||
|
|
||||||
|
var camera = level.scene.camera;
|
||||||
|
camera.pos.load(position);
|
||||||
|
camera.target.load(overviewCenter);
|
||||||
|
camera.up.x = 0;
|
||||||
|
camera.up.y = 0;
|
||||||
|
camera.up.z = 1;
|
||||||
|
}
|
||||||
|
|
||||||
public function update(currentTime:Float, dt:Float) {
|
public function update(currentTime:Float, dt:Float) {
|
||||||
// camera.position.set(marblePosition.x, marblePosition.y, marblePosition.z).sub(directionVector.clone().multiplyScalar(2.5));
|
// camera.position.set(marblePosition.x, marblePosition.y, marblePosition.z).sub(directionVector.clone().multiplyScalar(2.5));
|
||||||
// this.level.scene.camera.target = marblePosition.add(cameraVerticalTranslation);
|
// this.level.scene.camera.target = marblePosition.add(cameraVerticalTranslation);
|
||||||
// camera.position.add(cameraVerticalTranslation);
|
// camera.position.add(cameraVerticalTranslation);
|
||||||
|
|
||||||
|
if (overview) {
|
||||||
|
doOverviewCamera(currentTime, dt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var camera = level.scene.camera;
|
var camera = level.scene.camera;
|
||||||
|
|
||||||
var lerpt = Math.pow(0.5, dt / 0.032); // Math.min(1, 1 - Math.pow(0.6, dt / 0.032)); // hxd.Math.min(1, 1 - Math.pow(0.6, dt * 600));
|
var lerpt = Math.pow(0.5, dt / 0.032); // Math.min(1, 1 - Math.pow(0.6, dt / 0.032)); // hxd.Math.min(1, 1 - Math.pow(0.6, dt * 600));
|
||||||
|
|
|
||||||
|
|
@ -543,23 +543,25 @@ class MarbleWorld extends Scheduler {
|
||||||
return (aId > bId) ? 1 : (aId < bId) ? -1 : 0;
|
return (aId > bId) ? 1 : (aId < bId) ? -1 : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var cc = 0;
|
// var cc = 0;
|
||||||
for (client in Net.clients)
|
// for (client in Net.clients)
|
||||||
cc++;
|
// cc++;
|
||||||
if (Net.isHost && cc == 0) {
|
// if (Net.isHost && cc == 0) {
|
||||||
allClientsReady();
|
// allClientsReady();
|
||||||
Net.serverInfo.state = "PLAYING";
|
// Net.serverInfo.state = "PLAYING";
|
||||||
MasterServerClient.instance.sendServerInfo(Net.serverInfo); // notify the server of the playing state
|
// MasterServerClient.instance.sendServerInfo(Net.serverInfo); // notify the server of the playing state
|
||||||
}
|
// }
|
||||||
if (this.isMultiplayer) {
|
if (this.isMultiplayer) {
|
||||||
// Push the pre - game
|
// Push the pre - game
|
||||||
showPreGame();
|
showPreGame();
|
||||||
}
|
}
|
||||||
|
this.gameMode.onMissionLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showPreGame() {
|
public function showPreGame() {
|
||||||
MarbleGame.canvas.pushDialog(new MPPreGameDlg());
|
MarbleGame.canvas.pushDialog(new MPPreGameDlg());
|
||||||
this.setCursorLock(false);
|
this.setCursorLock(false);
|
||||||
|
this.marble.camera.startOverview();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addJoiningClient(cc:GameConnection, onAdded:() -> Void) {
|
public function addJoiningClient(cc:GameConnection, onAdded:() -> Void) {
|
||||||
|
|
@ -801,7 +803,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.setUp(marble, up, this.timeState, true);
|
this.setUp(marble, up, this.timeState, true);
|
||||||
|
|
||||||
if (marble == this.marble)
|
if (marble == this.marble)
|
||||||
this.playGui.setCenterText('');
|
this.playGui.setCenterText('none');
|
||||||
if (!this.isMultiplayer)
|
if (!this.isMultiplayer)
|
||||||
this.clearSchedule();
|
this.clearSchedule();
|
||||||
marble.outOfBounds = false;
|
marble.outOfBounds = false;
|
||||||
|
|
@ -841,12 +843,42 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.multiplayerStarted && this.finishTime == null) {
|
if (!this.multiplayerStarted && this.finishTime == null) {
|
||||||
|
if ((Net.isHost && (this.timeState.timeSinceLoad < startTime - 3.0)) // 3.5 == 109 ticks
|
||||||
|
|| (Net.isClient && this.serverStartTicks != 0 && @:privateAccess this.marble.serverTicks < this.serverStartTicks + 16)) {
|
||||||
|
this.playGui.setCenterText('none');
|
||||||
|
}
|
||||||
|
if ((Net.isHost
|
||||||
|
&& (this.timeState.timeSinceLoad > startTime - 3.0)
|
||||||
|
&& (this.timeState.timeSinceLoad < startTime - 1.5)) // 3.5 == 109 ticks
|
||||||
|
|| (Net.isClient
|
||||||
|
&& this.serverStartTicks != 0
|
||||||
|
&& @:privateAccess this.marble.serverTicks > this.serverStartTicks + 16
|
||||||
|
&& @:privateAccess this.marble.serverTicks < this.serverStartTicks + 63)) {
|
||||||
|
this.playGui.setCenterText('ready');
|
||||||
|
}
|
||||||
|
if ((Net.isHost
|
||||||
|
&& (this.timeState.timeSinceLoad > startTime - 1.5)
|
||||||
|
&& (this.timeState.timeSinceLoad < startTime)) // 3.5 == 109 ticks
|
||||||
|
|| (Net.isClient
|
||||||
|
&& this.serverStartTicks != 0
|
||||||
|
&& @:privateAccess this.marble.serverTicks > this.serverStartTicks + 63
|
||||||
|
&& @:privateAccess this.marble.serverTicks < this.serverStartTicks + 109)) {
|
||||||
|
this.playGui.setCenterText('set');
|
||||||
|
}
|
||||||
if ((Net.isHost && (this.timeState.timeSinceLoad >= startTime)) // 3.5 == 109 ticks
|
if ((Net.isHost && (this.timeState.timeSinceLoad >= startTime)) // 3.5 == 109 ticks
|
||||||
|| (Net.isClient && this.serverStartTicks != 0 && @:privateAccess this.marble.serverTicks >= this.serverStartTicks + 109)) {
|
|| (Net.isClient && this.serverStartTicks != 0 && @:privateAccess this.marble.serverTicks >= this.serverStartTicks + 109)) {
|
||||||
this.multiplayerStarted = true;
|
this.multiplayerStarted = true;
|
||||||
this.marble.setMode(Play);
|
this.marble.setMode(Play);
|
||||||
for (client => marble in this.clientMarbles)
|
for (client => marble in this.clientMarbles)
|
||||||
marble.setMode(Play);
|
marble.setMode(Play);
|
||||||
|
|
||||||
|
this.playGui.setCenterText('go');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.multiplayerStarted) {
|
||||||
|
if ((Net.isHost && (this.timeState.timeSinceLoad > startTime + 2.0)) // 3.5 == 109 ticks
|
||||||
|
|| (Net.isClient && this.serverStartTicks != 0 && @:privateAccess this.marble.serverTicks > this.serverStartTicks + 172)) {
|
||||||
|
this.playGui.setCenterText('none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ class MissionElementScriptObject extends MissionElementBase {
|
||||||
var maxgemsperspawn:String;
|
var maxgemsperspawn:String;
|
||||||
var radiusfromgem:String;
|
var radiusfromgem:String;
|
||||||
var spawnblock:String;
|
var spawnblock:String;
|
||||||
|
var overviewwidth:String;
|
||||||
|
var overviewheight:String;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
_type = MissionElementType.ScriptObject;
|
_type = MissionElementType.ScriptObject;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ interface GameMode {
|
||||||
public function getSpawnTransform():{position:Vector, orientation:Quat, up:Vector};
|
public function getSpawnTransform():{position:Vector, orientation:Quat, up:Vector};
|
||||||
public function getRespawnTransform(marble:Marble):{position:Vector, orientation:Quat, up:Vector};
|
public function getRespawnTransform(marble:Marble):{position:Vector, orientation:Quat, up:Vector};
|
||||||
public function missionScan(mission:Mission):Void;
|
public function missionScan(mission:Mission):Void;
|
||||||
|
public function onMissionLoad():Void;
|
||||||
public function getStartTime():Float;
|
public function getStartTime():Float;
|
||||||
public function timeMultiplier():Float;
|
public function timeMultiplier():Float;
|
||||||
public function getScoreType():ScoreType;
|
public function getScoreType():ScoreType;
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,10 @@ class HuntMode extends NullMode {
|
||||||
@:privateAccess level.playGui.formatGemHuntCounter(points);
|
@:privateAccess level.playGui.formatGemHuntCounter(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override function onMissionLoad() {
|
||||||
|
prepareGems();
|
||||||
|
}
|
||||||
|
|
||||||
override function onClientRestart() {
|
override function onClientRestart() {
|
||||||
prepareGems();
|
prepareGems();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,4 +136,6 @@ class NullMode implements GameMode {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function onClientRestart() {}
|
public function onClientRestart() {}
|
||||||
|
|
||||||
|
public function onMissionLoad() {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,7 @@ class NetCommands {
|
||||||
if (MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1] is MPPreGameDlg) {
|
if (MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1] is MPPreGameDlg) {
|
||||||
MarbleGame.canvas.popDialog(MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1]);
|
MarbleGame.canvas.popDialog(MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1]);
|
||||||
MarbleGame.instance.world.setCursorLock(true);
|
MarbleGame.instance.world.setCursorLock(true);
|
||||||
|
MarbleGame.instance.world.marble.camera.stopOverview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue