Skip to content

Commit

Permalink
Added friendly fire for teams
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinBoers committed Jul 27, 2021
1 parent 7e1e5a0 commit 7956799
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/scenes/gameScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ export class gameScene extends Phaser.Scene {

if (GAMEVARS.deadPlayers[player.name] === true) return;

// Friendly fire
if(this.teamsEnabled) {
console.log(player.name);
console.log(bomb.name);
console.log(this.teamdex[player.name]);
console.log(this.teamdex[bomb.name]);
if(this.teamdex[player.name] == this.teamdex[bomb.name]) return;
}

this.cameras.main.shake(GAMEVARS.shakeDuration, GAMEVARS.shakeAmount);

// Knockback
Expand Down Expand Up @@ -454,6 +463,7 @@ export class gameScene extends Phaser.Scene {

if (!bomb) return;

bomb.name = i;
bomb.setActive(true);
bomb.setVisible(true);
bomb.setVelocityX(-10 * GAMEVARS.playerSpeed);
Expand All @@ -472,6 +482,9 @@ export class gameScene extends Phaser.Scene {

if (!bomb) return;

bomb.name = i;
bomb.setActive(true);
bomb.setVisible(true);
bomb.setVelocityX(10 * GAMEVARS.playerSpeed);
bomb.setVelocityY(Phaser.Math.Between(200, -200));
bomb.setBounce(1);
Expand Down Expand Up @@ -536,6 +549,7 @@ export class gameScene extends Phaser.Scene {
if (GAMEVARS.deadPlayers[i] === false) {
console.log("Found winner: "+(i+1));

// Get winning team if teams are enabled
let winningTeam;

if(this.teamsEnabled) {
Expand All @@ -550,14 +564,16 @@ export class gameScene extends Phaser.Scene {

let winningSkins = [];

// Get skins of winning team
for(let x = 0;x<5;x++) {
if(this.teamdex[x] == winningTeam) {
winningSkins.push(GAMEVARS.playerSkins[x] + "_idle" + (x + 1));
if(this.teamsEnabled) {

// Get skins of winning team
for(let x = 0;x<5;x++) {
if(this.teamdex[x] == winningTeam) {
winningSkins.push(GAMEVARS.playerSkins[x] + "_idle" + (x + 1));
}
}
}

console.log(winningSkins);
}

// Stop current scene / game
this.scene.stop(CST.SCENES.GAME);
Expand Down

0 comments on commit 7956799

Please sign in to comment.