mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-27 18:32:20 +00:00
add player list, scoreboard and working blast
This commit is contained in:
parent
b1af411014
commit
b3978bb9bb
11 changed files with 284 additions and 93 deletions
|
|
@ -230,8 +230,8 @@ class Marble extends GameObject {
|
|||
var minVelocityBounceSoft = 2.5;
|
||||
var minVelocityBounceHard = 12.0;
|
||||
var bounceMinGain = 0.2;
|
||||
var maxBlastRepulse = 60.0;
|
||||
var blastRepulseDist = 10.0;
|
||||
var blastShockwaveStrength = 5.0;
|
||||
var blastRechargeShockwaveStrength = 10.0;
|
||||
|
||||
public var _bounceRestitution = 0.5;
|
||||
|
||||
|
|
@ -600,12 +600,6 @@ class Marble extends GameObject {
|
|||
var force = cast(obj, ForceObject).getForce(this.collider.transform.getPosition());
|
||||
A.load(A.add(force.multiply(1 / mass)));
|
||||
}
|
||||
for (marble in level.marbles) {
|
||||
if ((marble != cast this) && !marble._firstTick) {
|
||||
var force = marble.getForce(this.collider.transform.getPosition(), timeState.ticks);
|
||||
A.load(A.add(force.multiply(1 / mass)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contacts.length != 0 && this.mode != Start) {
|
||||
|
|
@ -2194,8 +2188,10 @@ class Marble extends GameObject {
|
|||
public function getMass() {
|
||||
if (this.level == null)
|
||||
return 1;
|
||||
if (this.level.timeState.currentAttemptTime - this.megaMarbleEnableTime < 10) {
|
||||
return 5;
|
||||
if (this.level.timeState.currentAttemptTime - this.megaMarbleEnableTime < 10
|
||||
|| (Net.isHost && this.megaMarbleUseTick > 0 && (this.level.timeState.ticks - this.megaMarbleUseTick) < 312)
|
||||
|| (Net.isClient && this.megaMarbleUseTick > 0 && (this.serverTicks - this.megaMarbleUseTick) < 312)) {
|
||||
return 4;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -2217,6 +2213,21 @@ class Marble extends GameObject {
|
|||
},
|
||||
new Vector(1, 1, 1).add(new Vector(Math.abs(this.currentUp.x), Math.abs(this.currentUp.y), Math.abs(this.currentUp.z)).multiply(-0.8)));
|
||||
this.blastTicks = 0;
|
||||
// Now send the impulse to other marbles
|
||||
var strength = blastAmt * (blastAmt > 1 ? blastRechargeShockwaveStrength : blastShockwaveStrength);
|
||||
var ourPos = this.collider.transform.getPosition();
|
||||
for (marble in level.marbles) {
|
||||
if (marble != cast this) {
|
||||
var theirPos = marble.collider.transform.getPosition();
|
||||
var posDiff = ourPos.distance(theirPos);
|
||||
if (posDiff < strength) {
|
||||
var myMod = isMegaMarbleEnabled(timeState) ? 0.7 : 1.0;
|
||||
var theirMod = @:privateAccess marble.isMegaMarbleEnabled(timeState) ? 0.7 : 1.0;
|
||||
var impulse = theirPos.sub(ourPos).normalized().multiply(strength * (theirMod / myMod));
|
||||
marble.applyImpulse(impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.blastAmount < 0.2 || this.level.game != "ultra")
|
||||
return;
|
||||
|
|
@ -2232,33 +2243,6 @@ class Marble extends GameObject {
|
|||
}
|
||||
}
|
||||
|
||||
public function getForce(position:Vector, tick:Int) {
|
||||
var retForce = new Vector();
|
||||
if (tick - blastUseTick >= 12)
|
||||
return retForce;
|
||||
var delta = position.sub(newPos);
|
||||
var deltaLen = delta.length();
|
||||
|
||||
var maxDist = Math.max(blastRepulseDist, blastRepulseDist * blastPerc);
|
||||
var maxRepulse = maxBlastRepulse * blastPerc;
|
||||
|
||||
if (deltaLen > maxDist)
|
||||
return retForce;
|
||||
|
||||
if (deltaLen >= 0.05) {
|
||||
var dist = 0.0;
|
||||
if (deltaLen >= 1.0)
|
||||
dist = (1.0 / deltaLen - 1.0 / maxDist) * maxRepulse;
|
||||
else
|
||||
dist = maxRepulse / deltaLen;
|
||||
|
||||
retForce.load(retForce.add(delta.multiply(dist)));
|
||||
} else {
|
||||
retForce.load(retForce.add(this.currentUp.multiply(maxRepulse)));
|
||||
}
|
||||
return retForce;
|
||||
}
|
||||
|
||||
public function applyImpulse(impulse:Vector, contactImpulse:Bool = false) {
|
||||
this.appliedImpulses.push({impulse: impulse, contactImpulse: contactImpulse});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,14 +352,14 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
if (this.isMultiplayer) {
|
||||
// Add us
|
||||
// if (Net.isHost) {
|
||||
// this.playGui.addPlayer(0, Settings.highscoreName.substr(0, 15), true);
|
||||
// } else {
|
||||
// this.playGui.addPlayer(Net.clientId, Settings.highscoreName.substr(0, 15), true);
|
||||
// }
|
||||
// for (client in Net.clientIdMap) {
|
||||
// this.playGui.addPlayer(client.id, client.name.substr(0, 15), false);
|
||||
// }
|
||||
if (Net.isHost) {
|
||||
this.playGui.addPlayer(0, Settings.highscoreName.substr(0, 15), true);
|
||||
} else {
|
||||
this.playGui.addPlayer(Net.clientId, Settings.highscoreName.substr(0, 15), true);
|
||||
}
|
||||
for (client in Net.clientIdMap) {
|
||||
this.playGui.addPlayer(client.id, client.name.substr(0, 15), false);
|
||||
}
|
||||
}
|
||||
|
||||
this._ready = true;
|
||||
|
|
@ -557,8 +557,8 @@ class MarbleWorld extends Scheduler {
|
|||
this.initMarble(cc, () -> {
|
||||
var addedMarble = clientMarbles.get(cc);
|
||||
this.restart(addedMarble); // spawn it
|
||||
// this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||
// this.playGui.redrawPlayerList();
|
||||
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||
this.playGui.redrawPlayerList();
|
||||
|
||||
// Sort all the marbles so that they are updated in a deterministic order
|
||||
this.marbles.sort((a, b) -> @:privateAccess {
|
||||
|
|
@ -574,8 +574,8 @@ class MarbleWorld extends Scheduler {
|
|||
this.initMarble(cc, () -> {
|
||||
var addedMarble = clientMarbles.get(cc);
|
||||
this.restart(addedMarble); // spawn it
|
||||
// this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||
// this.playGui.redrawPlayerList();
|
||||
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||
this.playGui.redrawPlayerList();
|
||||
|
||||
// Sort all the marbles so that they are updated in a deterministic order
|
||||
this.marbles.sort((a, b) -> @:privateAccess {
|
||||
|
|
@ -713,7 +713,7 @@ class MarbleWorld extends Scheduler {
|
|||
marble.reset();
|
||||
marble.setMode(Start);
|
||||
}
|
||||
// this.playGui.resetPlayerScores();
|
||||
this.playGui.resetPlayerScores();
|
||||
}
|
||||
|
||||
var missionInfo:MissionElementScriptObject = cast this.mission.root.elements.filter((element) -> element._type == MissionElementType.ScriptObject
|
||||
|
|
@ -1496,7 +1496,7 @@ class MarbleWorld extends Scheduler {
|
|||
this.scene.removeChild(otherMarble);
|
||||
this.collisionWorld.removeMarbleEntity(otherMarble.collider);
|
||||
this.collisionWorld.removeMovingEntity(otherMarble.collider);
|
||||
// this.playGui.removePlayer(cc.id);
|
||||
this.playGui.removePlayer(cc.id);
|
||||
this.clientMarbles.remove(cc);
|
||||
otherMarble.dispose();
|
||||
this.marbles.remove(otherMarble);
|
||||
|
|
|
|||
|
|
@ -363,6 +363,13 @@ class Util {
|
|||
return keyName;
|
||||
}
|
||||
|
||||
public static inline function rightPad(str:String, len:Int, cutOff:Int) {
|
||||
str = str.substring(0, len - cutOff);
|
||||
while (str.length < len)
|
||||
str += " ";
|
||||
return str;
|
||||
}
|
||||
|
||||
public static function m_matF_x_vectorF(matrix:Matrix, v:Vector) {
|
||||
var m = matrix.clone();
|
||||
m.transpose();
|
||||
|
|
|
|||
|
|
@ -151,13 +151,18 @@ class CollisionWorld {
|
|||
}
|
||||
|
||||
public function addEntity(entity:CollisionEntity) {
|
||||
this.octree.insert(entity);
|
||||
this.entities.push(entity);
|
||||
if (this.octree.insert(entity))
|
||||
this.entities.push(entity);
|
||||
|
||||
// this.rtree.insert([entity.boundingBox.xMin, entity.boundingBox.yMin, entity.boundingBox.zMin],
|
||||
// [entity.boundingBox.xSize, entity.boundingBox.ySize, entity.boundingBox.zSize], entity);
|
||||
}
|
||||
|
||||
public function removeEntity(entity:CollisionEntity) {
|
||||
this.entities.remove(entity);
|
||||
this.octree.remove(entity);
|
||||
}
|
||||
|
||||
public function addMarbleEntity(entity:SphereCollisionEntity) {
|
||||
this.marbleEntities.push(entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class GuiTextListCtrl extends GuiControl {
|
|||
tobj.textColor = textColor;
|
||||
textObjs.push(tobj);
|
||||
|
||||
if (this.scrollable) {
|
||||
if (this.scrollable && this.flow != null) {
|
||||
if (this.flow.contains(tobj))
|
||||
this.flow.removeChild(tobj);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ class JoinServerGui extends GuiImage {
|
|||
var serverList = new GuiTextListCtrl(markerFelt18, [], 0xFFFFFF);
|
||||
serverList.position = new Vector(0, 0);
|
||||
serverList.extent = new Vector(475, 63);
|
||||
serverList.scrollable = true;
|
||||
serverList.textYOffset = -6;
|
||||
serverList.onSelectedFunc = (sel) -> {
|
||||
curSelection = sel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ class MPPlayMissionGui extends GuiImage {
|
|||
var previewToken:Int = 0;
|
||||
#end
|
||||
|
||||
var playerListCtrl:GuiTextListCtrl;
|
||||
var playerListCtrlDs:GuiTextListCtrl;
|
||||
|
||||
public function new(isHost:Bool = true) {
|
||||
MissionList.buildMissionList();
|
||||
function chooseBg() {
|
||||
|
|
@ -305,6 +308,20 @@ class MPPlayMissionGui extends GuiImage {
|
|||
playersBox.extent = new Vector(305, 229);
|
||||
window.addChild(playersBox);
|
||||
|
||||
playerListCtrlDs = new GuiTextListCtrl(markerFelt18, [], 0x000000);
|
||||
playerListCtrlDs.position = new Vector(-1, 25);
|
||||
playerListCtrlDs.extent = new Vector(305, 203);
|
||||
playerListCtrlDs.scrollable = true;
|
||||
playerListCtrlDs.textYOffset = -6;
|
||||
playersBox.addChild(playerListCtrlDs);
|
||||
|
||||
playerListCtrl = new GuiTextListCtrl(markerFelt18, [], 0xFFFFFF);
|
||||
playerListCtrl.position = new Vector(0, 26);
|
||||
playerListCtrl.extent = new Vector(305, 203);
|
||||
playerListCtrl.scrollable = true;
|
||||
playerListCtrl.textYOffset = -6;
|
||||
playersBox.addChild(playerListCtrl);
|
||||
|
||||
var playerListTitle = new GuiText(markerFelt24);
|
||||
playerListTitle.position = new Vector(7, 0);
|
||||
playerListTitle.extent = new Vector(275, 22);
|
||||
|
|
@ -505,6 +522,7 @@ class MPPlayMissionGui extends GuiImage {
|
|||
currentList = MissionList.missionList["multiplayer"]["beginner"];
|
||||
|
||||
setCategoryFunc(currentCategoryStatic, null, false);
|
||||
updateLobbyNames();
|
||||
}
|
||||
|
||||
public override function render(scene2d:Scene, ?parent:h2d.Flow) {
|
||||
|
|
@ -534,19 +552,16 @@ class MPPlayMissionGui extends GuiImage {
|
|||
}
|
||||
|
||||
public function updateLobbyNames() {
|
||||
return;
|
||||
var playerListArr = [];
|
||||
if (Net.isHost) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.lobbyHostReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
}
|
||||
if (Net.isClient) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.lobbyClientReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
}
|
||||
|
|
@ -554,34 +569,18 @@ class MPPlayMissionGui extends GuiImage {
|
|||
for (c => v in Net.clientIdMap) {
|
||||
playerListArr.push({
|
||||
name: v.name,
|
||||
state: v.lobbyReady,
|
||||
platform: v.platform
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var playerListCompiled = playerListArr.map(player -> player.name);
|
||||
playerListCtrlDs.setTexts(playerListCompiled);
|
||||
playerListCtrl.setTexts(playerListCompiled);
|
||||
|
||||
// if (!showingCustoms)
|
||||
// playerList.setTexts(playerListArr.map(player -> {
|
||||
// return '<img src="${player.state ? "ready" : "notready"}"></img><img src="${platformToString(player.platform)}"></img>${player.name}';
|
||||
// }));
|
||||
|
||||
var pubCount = 1; // Self
|
||||
var privCount = 0;
|
||||
for (cid => cc in Net.clientIdMap) {
|
||||
if (cc.isPrivate) {
|
||||
privCount++;
|
||||
} else {
|
||||
pubCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Net.isHost) {
|
||||
// updatePlayerCountFn(pubCount, privCount, Net.serverInfo.maxPlayers - Net.serverInfo.privateSlots, Net.serverInfo.privateSlots);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePlayerCount(pub:Int, priv:Int, publicTotal:Int, privateTotal:Int) {
|
||||
return;
|
||||
// updatePlayerCountFn(pub, priv, publicTotal, privateTotal);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package gui;
|
||||
|
||||
import net.NetPacket.ScoreboardPacket;
|
||||
import net.Net;
|
||||
import src.ProfilerUI;
|
||||
import hxd.App;
|
||||
|
|
@ -31,10 +32,22 @@ import hxd.res.Sound;
|
|||
import h3d.mat.Texture;
|
||||
import src.Settings;
|
||||
import src.Util;
|
||||
import src.AudioManager;
|
||||
|
||||
typedef MiddleMessage = {
|
||||
ctrl:GuiText,
|
||||
age:Float,
|
||||
@:publicFields
|
||||
@:structInit
|
||||
class MiddleMessage {
|
||||
var ctrl:GuiText;
|
||||
var age:Float;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
@:structInit
|
||||
class PlayerInfo {
|
||||
var id:Int;
|
||||
var name:String;
|
||||
var us:Bool;
|
||||
var score:Int;
|
||||
}
|
||||
|
||||
class PlayGui {
|
||||
|
|
@ -70,6 +83,13 @@ class PlayGui {
|
|||
var blastFill:GuiImage;
|
||||
var blastFrame:GuiImage;
|
||||
|
||||
var playerListContainer:GuiControl;
|
||||
var playerListCtrl:GuiMLTextListCtrl;
|
||||
var playerListScoresCtrl:GuiMLTextListCtrl;
|
||||
var playerListShadowCtrl:GuiMLTextListCtrl;
|
||||
var playerListScoresShadowCtrl:GuiMLTextListCtrl;
|
||||
var playerList:Array<PlayerInfo> = [];
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
|
@ -87,6 +107,20 @@ class PlayGui {
|
|||
public function dispose() {
|
||||
if (_init) {
|
||||
playGuiCtrl.dispose();
|
||||
|
||||
if (playerListContainer != null) {
|
||||
playerListContainer.dispose();
|
||||
playerListContainer = null;
|
||||
playerListCtrl.dispose();
|
||||
playerListCtrl = null;
|
||||
playerListShadowCtrl.dispose();
|
||||
playerListShadowCtrl = null;
|
||||
playerListScoresCtrl.dispose();
|
||||
playerListScoresCtrl = null;
|
||||
playerListScoresShadowCtrl.dispose();
|
||||
playerListScoresShadowCtrl = null;
|
||||
}
|
||||
|
||||
gemImageScene.dispose();
|
||||
gemImageSceneTarget.dispose();
|
||||
gemImageSceneTargetBitmap.remove();
|
||||
|
|
@ -161,6 +195,11 @@ class PlayGui {
|
|||
if (Settings.optionsSettings.frameRateVis)
|
||||
initFPSMeter();
|
||||
|
||||
if (MarbleGame.instance.world.isMultiplayer) {
|
||||
initPlayerList();
|
||||
// initChatHud();
|
||||
}
|
||||
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.showControls(this.playGuiCtrl, game == 'ultra');
|
||||
}
|
||||
|
|
@ -494,6 +533,139 @@ class PlayGui {
|
|||
this.blastBar.render(scene2d);
|
||||
}
|
||||
|
||||
function initPlayerList() {
|
||||
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
||||
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
||||
var bfont = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
||||
|
||||
playerListContainer = new GuiControl();
|
||||
playerListContainer.horizSizing = Right;
|
||||
playerListContainer.vertSizing = Height;
|
||||
playerListContainer.position = new Vector(20, 100);
|
||||
playerListContainer.extent = new Vector(300, 380);
|
||||
this.playGuiCtrl.addChild(playerListContainer);
|
||||
|
||||
var imgLoader = (s:String) -> {
|
||||
return null;
|
||||
}
|
||||
|
||||
playerListShadowCtrl = new GuiMLTextListCtrl(bfont, [], imgLoader);
|
||||
|
||||
playerListShadowCtrl.position = new Vector(34, 4);
|
||||
playerListShadowCtrl.extent = new Vector(210, 271);
|
||||
playerListShadowCtrl.scrollable = true;
|
||||
playerListShadowCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListShadowCtrl);
|
||||
|
||||
playerListScoresShadowCtrl = new GuiMLTextListCtrl(bfont, [], imgLoader);
|
||||
|
||||
playerListScoresShadowCtrl.position = new Vector(234, 4);
|
||||
playerListScoresShadowCtrl.extent = new Vector(210, 271);
|
||||
playerListScoresShadowCtrl.scrollable = true;
|
||||
playerListScoresShadowCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListScoresShadowCtrl);
|
||||
|
||||
playerListCtrl = new GuiMLTextListCtrl(bfont, [], imgLoader);
|
||||
|
||||
playerListCtrl.position = new Vector(33, 3);
|
||||
playerListCtrl.extent = new Vector(210, 271);
|
||||
playerListCtrl.scrollable = true;
|
||||
playerListCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListCtrl);
|
||||
|
||||
playerListScoresCtrl = new GuiMLTextListCtrl(bfont, [], imgLoader);
|
||||
|
||||
playerListScoresCtrl.position = new Vector(233, 3);
|
||||
playerListScoresCtrl.extent = new Vector(210, 271);
|
||||
playerListScoresCtrl.scrollable = true;
|
||||
playerListScoresCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListScoresCtrl);
|
||||
}
|
||||
|
||||
public function redrawPlayerList() {
|
||||
var pl = [];
|
||||
var plScores = [];
|
||||
var plShadow = [];
|
||||
var plShadowScores = [];
|
||||
var col0 = "#CFB52B";
|
||||
var col1 = "#CDCDCD";
|
||||
var col2 = "#D19275";
|
||||
var col3 = "#FFEE99";
|
||||
playerList.sort((a, b) -> a.score > b.score ? -1 : (a.score < b.score ? 1 : 0));
|
||||
for (i in 0...playerList.length) {
|
||||
var item = playerList[i];
|
||||
var color = switch (i) {
|
||||
case 0:
|
||||
col0;
|
||||
case 1:
|
||||
col1;
|
||||
case 2:
|
||||
col2;
|
||||
default:
|
||||
col3;
|
||||
};
|
||||
pl.push('<font color="${color}">${i + 1}. ${Util.rightPad(item.name, 25, 3)}</font>');
|
||||
plScores.push('<font color="${color}">${item.score}</font>');
|
||||
plShadow.push('<font color="#000000">${i + 1}. ${Util.rightPad(item.name, 25, 3)}</font>');
|
||||
plShadowScores.push('<font color="#000000">${item.score}</font>');
|
||||
}
|
||||
playerListCtrl.setTexts(pl);
|
||||
playerListScoresCtrl.setTexts(plScores);
|
||||
playerListShadowCtrl.setTexts(plShadow);
|
||||
playerListScoresShadowCtrl.setTexts(plShadowScores);
|
||||
}
|
||||
|
||||
public function addPlayer(id:Int, name:String, us:Bool) {
|
||||
if (playerListCtrl != null) {
|
||||
playerList.push({
|
||||
id: id,
|
||||
name: name,
|
||||
us: us,
|
||||
score: 0
|
||||
});
|
||||
redrawPlayerList();
|
||||
}
|
||||
}
|
||||
|
||||
public function removePlayer(id:Int) {
|
||||
if (playerListCtrl != null) {
|
||||
var f = playerList.filter(x -> x.id == id);
|
||||
if (f.length != 0)
|
||||
playerList.remove(f[0]);
|
||||
redrawPlayerList();
|
||||
}
|
||||
}
|
||||
|
||||
public function incrementPlayerScore(id:Int, score:Int) {
|
||||
var f = playerList.filter(x -> x.id == id);
|
||||
if (f.length != 0)
|
||||
f[0].score += score;
|
||||
|
||||
if (id == Net.clientId) {
|
||||
if (Net.isClient)
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/gotgem.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
} else if (Net.isClient)
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/opponentdiamond.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
|
||||
redrawPlayerList();
|
||||
}
|
||||
|
||||
public function updatePlayerScores(scoreboardPacket:ScoreboardPacket) {
|
||||
for (player in playerList) {
|
||||
player.score = scoreboardPacket.scoreBoard.exists(player.id) ? scoreboardPacket.scoreBoard.get(player.id) : 0;
|
||||
}
|
||||
redrawPlayerList();
|
||||
}
|
||||
|
||||
public function resetPlayerScores() {
|
||||
for (player in playerList) {
|
||||
player.score = 0;
|
||||
}
|
||||
|
||||
redrawPlayerList();
|
||||
}
|
||||
|
||||
public function setHelpTextOpacity(value:Float) {
|
||||
@:privateAccess helpTextForeground.text._textColorVec.a = value;
|
||||
@:privateAccess helpTextBackground.text._textColorVec.a = value;
|
||||
|
|
@ -569,6 +741,8 @@ class PlayGui {
|
|||
}
|
||||
|
||||
public function formatGemCounter(collected:Int, total:Int) {
|
||||
if (MarbleGame.instance.world.isMultiplayer)
|
||||
return;
|
||||
if (total == 0) {
|
||||
for (number in gemCountNumbers) {
|
||||
number.anim.visible = false;
|
||||
|
|
@ -599,6 +773,25 @@ class PlayGui {
|
|||
gemCountNumbers[5].anim.currentFrame = totalOnes;
|
||||
}
|
||||
|
||||
public function formatGemHuntCounter(collected:Int) {
|
||||
gemCountNumbers[0].anim.visible = true;
|
||||
gemCountNumbers[1].anim.visible = true;
|
||||
gemCountNumbers[2].anim.visible = true;
|
||||
gemCountNumbers[3].anim.visible = false;
|
||||
gemCountNumbers[4].anim.visible = false;
|
||||
gemCountNumbers[5].anim.visible = false;
|
||||
|
||||
var collectedHundredths = Math.floor(collected / 100);
|
||||
var collectedTenths = Math.floor(collected / 10) % 10;
|
||||
var collectedOnes = collected % 10;
|
||||
|
||||
gemCountNumbers[0].anim.currentFrame = collectedHundredths;
|
||||
gemCountNumbers[1].anim.currentFrame = collectedTenths;
|
||||
gemCountNumbers[2].anim.currentFrame = collectedOnes;
|
||||
gemCountSlash.bmp.visible = false;
|
||||
gemImageSceneTargetBitmap.visible = true;
|
||||
}
|
||||
|
||||
// 0: default
|
||||
// 1: green
|
||||
// 2: red
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ class HuntMode extends NullMode {
|
|||
this.gemSpawnPoints.push(spawn);
|
||||
this.gemOctree.insert(spawn);
|
||||
gem.setHide(true);
|
||||
this.level.collisionWorld.removeEntity(gem.boundingCollider); // remove from octree to make it easy
|
||||
if (level.isMultiplayer) {
|
||||
@:privateAccess level.gemPredictions.alloc();
|
||||
}
|
||||
|
|
@ -254,6 +255,7 @@ class HuntMode extends NullMode {
|
|||
var gem = gemSpawnPoints[spawn];
|
||||
gem.gem.setHide(false);
|
||||
gem.gem.pickedUp = false;
|
||||
this.level.collisionWorld.addEntity(gem.gem.boundingCollider);
|
||||
activeGems.push(gem.gem);
|
||||
if (gem.gemBeam == null) {
|
||||
gem.gemBeam = new GemBeam(StringTools.replace(gem.gem.gemColor, '.gem', ''));
|
||||
|
|
@ -327,6 +329,7 @@ class HuntMode extends NullMode {
|
|||
override function onRestart() {
|
||||
setupGems();
|
||||
points = 0;
|
||||
@:privateAccess level.playGui.formatGemHuntCounter(points);
|
||||
}
|
||||
|
||||
override function onClientRestart() {
|
||||
|
|
@ -350,7 +353,7 @@ class HuntMode extends NullMode {
|
|||
}
|
||||
|
||||
var incr = 0;
|
||||
switch (gem.gemColor) {
|
||||
switch (gem.gemColor.toLowerCase()) {
|
||||
case "red.gem":
|
||||
incr = 1;
|
||||
case "yellow.gem":
|
||||
|
|
@ -361,7 +364,7 @@ class HuntMode extends NullMode {
|
|||
|
||||
if (@:privateAccess !marble.isNetUpdate) {
|
||||
if (marble == level.marble) {
|
||||
switch (gem.gemColor) {
|
||||
switch (gem.gemColor.toLowerCase()) {
|
||||
case "red.gem":
|
||||
points += 1;
|
||||
@:privateAccess level.playGui.addMiddleMessage('+1', 0xFF6666);
|
||||
|
|
@ -372,7 +375,7 @@ class HuntMode extends NullMode {
|
|||
points += 5;
|
||||
@:privateAccess level.playGui.addMiddleMessage('+5', 0x6666FF);
|
||||
}
|
||||
// @:privateAccess level.playGui.formatGemHuntCounter(points);
|
||||
@:privateAccess level.playGui.formatGemHuntCounter(points);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +392,7 @@ class HuntMode extends NullMode {
|
|||
|
||||
// Settings.playStatistics.totalMPScore += incr;
|
||||
|
||||
// @:privateAccess level.playGui.incrementPlayerScore(packet.clientId, packet.scoreIncr);
|
||||
@:privateAccess level.playGui.incrementPlayerScore(packet.clientId, packet.scoreIncr);
|
||||
}
|
||||
if (this.level.isMultiplayer && Net.isClient) {
|
||||
gem.pickUpClient = @:privateAccess marble.connection == null ? Net.clientId : @:privateAccess marble.connection.id;
|
||||
|
|
|
|||
|
|
@ -712,7 +712,7 @@ class Net {
|
|||
var gemPickupPacket = new GemPickupPacket();
|
||||
gemPickupPacket.deserialize(input);
|
||||
if (MarbleGame.instance.world != null && !MarbleGame.instance.world._disposed) {
|
||||
// @:privateAccess MarbleGame.instance.world.playGui.incrementPlayerScore(gemPickupPacket.clientId, gemPickupPacket.scoreIncr);
|
||||
@:privateAccess MarbleGame.instance.world.playGui.incrementPlayerScore(gemPickupPacket.clientId, gemPickupPacket.scoreIncr);
|
||||
@:privateAccess MarbleGame.instance.world.gemPredictions.acknowledgeGemPickup(gemPickupPacket);
|
||||
}
|
||||
|
||||
|
|
@ -744,9 +744,6 @@ class Net {
|
|||
Net.lobbyClientReady = cready;
|
||||
}
|
||||
}
|
||||
if (newP) {
|
||||
// AudioManager.playSound(ResourceLoader.getAudio("sounds/spawn_alternate.wav").resource);
|
||||
}
|
||||
if (MarbleGame.canvas.content is MPPlayMissionGui) {
|
||||
cast(MarbleGame.canvas.content, MPPlayMissionGui).updateLobbyNames();
|
||||
}
|
||||
|
|
@ -754,9 +751,9 @@ class Net {
|
|||
case ScoreBoardInfo:
|
||||
var scoreboardPacket = new ScoreboardPacket();
|
||||
scoreboardPacket.deserialize(input);
|
||||
// if (MarbleGame.instance.world != null && !MarbleGame.instance.world._disposed) {
|
||||
// @:privateAccess MarbleGame.instance.world.playGui.updatePlayerScores(scoreboardPacket);
|
||||
// }
|
||||
if (MarbleGame.instance.world != null && !MarbleGame.instance.world._disposed) {
|
||||
@:privateAccess MarbleGame.instance.world.playGui.updatePlayerScores(scoreboardPacket);
|
||||
}
|
||||
|
||||
case _:
|
||||
Console.log("unknown command: " + packetType);
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ class Octree {
|
|||
public function insert(object:IOctreeObject) {
|
||||
var node = this.objectToNode.get(object);
|
||||
if (node != null)
|
||||
return; // Don't insert if already contained in the tree
|
||||
return false; // Don't insert if already contained in the tree
|
||||
while (!this.root.largerThan(object) || !this.root.containsCenter(object)) {
|
||||
// The root node does not fit the object; we need to grow the tree.
|
||||
if (this.root.depth == -32) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
this.grow(object);
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ class Octree {
|
|||
this.root.insert(object);
|
||||
if (emptyBefore)
|
||||
this.shrink(); // See if we can fit the octree better now that we actually have an element in it
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove(object:IOctreeObject) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue