Skip to content

Commit

Permalink
Images & alot of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OhMyGuus committed Jan 26, 2021
1 parent 8c63439 commit c4fa08a
Show file tree
Hide file tree
Showing 71 changed files with 135 additions and 51 deletions.
Binary file modified android/app/src/main/res/drawable-land-hdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-land-mdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-land-xhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-land-xxhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-land-xxxhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-port-hdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-port-mdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-port-xhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-port-xxhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-port-xxxhdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
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.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
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.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
5 changes: 1 addition & 4 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Bettercrewlink</name>
<description></description>
<description />
<author email="[email protected]" href="https://bettercrewlink.app">OhMyGuus</author>
<content src="index.html" />
<access origin="*" />
Expand All @@ -20,7 +20,6 @@
<preference name="SplashScreenDelay" value="3000" />
<platform name="android">
<preference name="APP_SECRET" value="968c50f3-eb43-4ceb-9b3d-55458601a601" />

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
Expand Down Expand Up @@ -100,6 +99,4 @@
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />


</widget>
Binary file added resources/android/icon-background.png
Binary file added resources/android/icon-foreground.png
Binary file modified resources/android/icon/drawable-hdpi-icon.png
Binary file modified resources/android/icon/drawable-ldpi-icon.png
Binary file modified resources/android/icon/drawable-mdpi-icon.png
Diff not rendered.
Binary file modified resources/android/icon/drawable-xhdpi-icon.png
Binary file modified resources/android/icon/drawable-xxhdpi-icon.png
Binary file modified resources/android/icon/drawable-xxxhdpi-icon.png
Binary file added resources/android/icon/hdpi-background.png
Binary file added resources/android/icon/hdpi-foreground.png
Binary file added resources/android/icon/ldpi-background.png
Binary file added resources/android/icon/ldpi-foreground.png
Binary file added resources/android/icon/mdpi-background.png
Binary file added resources/android/icon/mdpi-foreground.png
Binary file removed resources/android/icon/mipmap-hdpi/ic_launcher.png
Diff not rendered.
Binary file removed resources/android/icon/mipmap-ldpi/ic_launcher.png
Diff not rendered.
Binary file removed resources/android/icon/mipmap-mdpi/ic_launcher.png
Diff not rendered.
Binary file removed resources/android/icon/mipmap-xhdpi/ic_launcher.png
Diff not rendered.
Binary file removed resources/android/icon/mipmap-xxhdpi/ic_launcher.png
Diff not rendered.
Diff not rendered.
Binary file added resources/android/icon/xhdpi-background.png
Binary file added resources/android/icon/xhdpi-foreground.png
Binary file added resources/android/icon/xxhdpi-background.png
Binary file added resources/android/icon/xxhdpi-foreground.png
Binary file added resources/android/icon/xxxhdpi-background.png
Binary file added resources/android/icon/xxxhdpi-foreground.png
Binary file modified resources/android/splash/drawable-land-hdpi-screen.png
Binary file modified resources/android/splash/drawable-land-ldpi-screen.png
Binary file modified resources/android/splash/drawable-land-mdpi-screen.png
Binary file modified resources/android/splash/drawable-land-xhdpi-screen.png
Binary file modified resources/android/splash/drawable-land-xxhdpi-screen.png
Binary file modified resources/android/splash/drawable-land-xxxhdpi-screen.png
Binary file modified resources/android/splash/drawable-port-hdpi-screen.png
Binary file modified resources/android/splash/drawable-port-ldpi-screen.png
Binary file modified resources/android/splash/drawable-port-mdpi-screen.png
Binary file modified resources/android/splash/drawable-port-xhdpi-screen.png
Binary file modified resources/android/splash/drawable-port-xxhdpi-screen.png
Binary file modified resources/android/splash/drawable-port-xxxhdpi-screen.png
151 changes: 111 additions & 40 deletions src/app/comp/AudioController.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ export default class AudioController extends EventEmitterO {
const muffle = context.createBiquadFilter();
muffle.type = 'lowpass';
muffle.Q.value = 0;
// const reverb = context.createConvolver();
// reverb.buffer = convolverBuffer.current;

source.connect(pan);
pan.connect(muffle);
muffle.connect(gain);
pan.connect(gain);

const audioContext = pan.context;
const panPos = [3, 0];
Expand All @@ -85,99 +86,170 @@ export default class AudioController extends EventEmitterO {
gain,
pan,
muffle,
destination: context.destination,
muffleConnected: false,
} as AudioElement;
}

applyEffect(gain: AudioNode, effectNode: AudioNode, destination: AudioNode, player: Player) {
try {
gain.disconnect(destination);
gain.connect(effectNode);
effectNode.connect(destination);
} catch {
console.log('error with applying effect: ', player.name, effectNode);
}
}

restoreEffect(gain: AudioNode, effectNode: AudioNode, destination: AudioNode, player: Player) {
try {
effectNode.disconnect(destination);
gain.disconnect(effectNode);
gain.connect(destination);
} catch {
console.log('error with applying effect: ', player.name, effectNode);
}
}

// move to different controller
updateAudioLocation(currentGameState: AmongUsState, element: SocketElement, localPLayer: Player) {
updateAudioLocation(state: AmongUsState, element: SocketElement, localPLayer: Player): number {
// console.log('updateAudioLocation ->', { element });
if (!element.audioElement || !element.client || !element.player || !localPLayer) {
if (element?.audioElement?.gain?.gain) {
element.audioElement.gain.gain.value = 0;
}
return;
console.log(element.audioElement, element.client, element.player, localPLayer);
return 0;
}
// console.log('[updateAudioLocation]');
const pan = element.audioElement.pan;
const gain = element.audioElement.gain;
const muffle = element.audioElement.muffle;
const audioContext = pan.context;
// const reverb = element.audioElement.reverb;
const destination = element.audioElement.destination;
const lobbySettings = this.connectionController.lobbySettings;
let maxdistance = lobbySettings.maxDistance;

const other = element.player; // this.getPlayer(element.client?.clientId);
let panPos = [other.x - localPLayer.x, other.y - localPLayer.y];
switch (currentGameState.gameState) {
let endGain = 0;
switch (state.gameState) {
case GameState.MENU:
gain.gain.value = 0;
endGain = 0;
break;

case GameState.LOBBY:
gain.gain.value = 1;
endGain = 1;
break;

case GameState.TASKS:
gain.gain.value = 1;
endGain = 1;

if (
!localPLayer.isDead &&
this.connectionController.lobbySettings.commsSabotage &&
currentGameState.comsSabotaged
) {
gain.gain.value = 0;
if (lobbySettings.meetingGhostOnly) {
endGain = 0;
}

// Mute other players which are in a vent
if (other.inVent && !this.connectionController.lobbySettings.hearImpostorsInVents) {
gain.gain.value = 0;
if (!localPLayer.isDead && lobbySettings.commsSabotage && state.comsSabotaged && !localPLayer.isImpostor) {
endGain = 0;
}

// Mute other players which are in a vent
if (
!localPLayer.isDead &&
other.isDead &&
localPLayer.isImpostor &&
this.connectionController.lobbySettings.haunting
other.inVent &&
!(lobbySettings.hearImpostorsInVents || (lobbySettings.impostersHearImpostersInvent && localPLayer.inVent))
) {
gain.gain.value = gain.gain.value * 0.02; //0.005;
endGain = 0;
}

// if (
// lobbySettings.wallsBlockAudio &&
// !me.isDead &&
// poseCollide({ x: me.x, y: me.y }, { x: other.x, y: other.y }, gameState.map)
// ) {
// endGain = 0;
// }

if (!localPLayer.isDead && other.isDead && localPLayer.isImpostor && lobbySettings.haunting) {
// if (!element.audioElement.reverbConnected) {
// element.audioElement.reverbConnected = true;
// this.applyEffect(gain, reverb, destination, other);
// }
endGain = 0.2;
} else {
if (!localPLayer.isDead && (other.isDead || currentGameState.comsSabotaged)) {
gain.gain.value = 0;
if (other.isDead && !localPLayer.isDead) {
endGain = 0;
}
}

break;

case GameState.DISCUSSION:
panPos = [0, 0];
gain.gain.value = 1;

endGain = 1;
// Mute dead players for still living players
if (!localPLayer.isDead && other.isDead) {
gain.gain.value = 0;
endGain = 0;
}
break;

case GameState.UNKNOWN:
default:
gain.gain.value = 0;
endGain = 0;
break;
}

if (!other.isDead || state.gameState !== GameState.TASKS || !localPLayer.isImpostor || localPLayer.isDead) {
// if (element.audioElement.reverbConnected && reverb) {
// element.audioElement.reverbConnected = false;
// this.restoreEffect(gain, reverb, destination, other);
// }
}

if (lobbySettings.deadOnly) {
panPos = [0, 0];
if (!localPLayer.isDead || !other.isDead) {
endGain = 0;
}
}

const isOnCamera = false;
// Muffling in vents
if (localPLayer.inVent || other.inVent) {
muffle.frequency.value = 1200;
muffle.Q.value = 20;
if (gain.gain.value === 1) gain.gain.value = 0.7; // Too loud at 1
if (
((localPLayer.inVent && !localPLayer.isDead) || (other.inVent && !other.isDead)) &&
state.gameState === GameState.TASKS
) {
if (!element.audioElement.muffleConnected) {
element.audioElement.muffleConnected = true;
this.applyEffect(gain, muffle, destination, other);
}
maxdistance = isOnCamera ? 3 : 0.8;
muffle.frequency.value = isOnCamera ? 2300 : 2000;
muffle.Q.value = isOnCamera ? -15 : 20;
if (endGain === 1) {
endGain = isOnCamera ? 0.8 : 0.5;
} // Too loud at 1
} else {
muffle.frequency.value = 20000;
muffle.Q.value = 0;
if (element.audioElement.muffleConnected) {
element.audioElement.muffleConnected = false;
this.restoreEffect(gain, muffle, destination, other);
}
}

// Mute players if distancte between two players is too big
// console.log({ x: other.x, y: other.y }, Math.sqrt(panPos[0] * panPos[0] + panPos[1] * panPos[1]));
//console.log(state.currentCamera);
if (Math.sqrt(panPos[0] * panPos[0] + panPos[1] * panPos[1]) > maxdistance) {
return 0;
}

// if (!settings.enableSpatialAudio) {
// panPos = [0, 0];
// }

if (pan.positionZ) {
pan.positionZ.setValueAtTime(-0.5, audioContext.currentTime);
pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime);
pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime);
} else {
pan.setPosition(panPos[0], panPos[1], -0.5);
}
return endGain;
}

disconnect() {
Expand All @@ -190,7 +262,6 @@ export default class AudioController extends EventEmitterO {

if (!socketElement.audioElement) {
console.log('disconnectElement -> !socketElement.audioElement -> ', socketElement);

return;
}
console.log('disconnectElement -> !uff?');
Expand Down
9 changes: 6 additions & 3 deletions src/app/comp/ConnectionController.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export declare interface IConnectionController {
connect(voiceserver: string, gamecode: string, username: string, deviceID: string, natFix: boolean);
}


@Injectable({
providedIn: 'root',
})
Expand Down Expand Up @@ -211,8 +210,12 @@ export class ConnectionController extends EventEmitterO implements IConnectionCo
}

this.socketElements.forEach((value) => {
console.log(JSON.stringify(value));
this.audioController.updateAudioLocation(this.currentGameState, value, this.localPLayer);
value.updatePLayer(this);
if (value?.audioElement?.gain) {
const endGain = this.audioController.updateAudioLocation(this.currentGameState, value, this.localPLayer);
console.log(endGain);
value.audioElement.gain.gain.value = endGain;
}
});
}

Expand Down
16 changes: 15 additions & 1 deletion src/app/comp/smallInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,36 @@ export interface AudioElement {
gain: GainNode;
pan: PannerNode;
muffle: BiquadFilterNode;
// reverb: ConvolverNode;
destination: AudioNode;
// reverbConnected: boolean;
muffleConnected: boolean;
}


export interface ILobbySettings {
maxDistance: number;
haunting: boolean;
hearImpostorsInVents: boolean;
impostersHearImpostersInvent: boolean;
commsSabotage: boolean;
deadOnly: boolean;
meetingGhostOnly: boolean;
hearThroughCameras: boolean;
wallsBlockAudio: boolean;
}


export const DEFAULT_LOBBYSETTINGS: ILobbySettings = {
maxDistance: 5.6,
maxDistance: 5.32,
haunting: false,
hearImpostorsInVents: false,
impostersHearImpostersInvent: false,
commsSabotage: false,
deadOnly: false,
hearThroughCameras: false,
wallsBlockAudio: false,
meetingGhostOnly: false,
};

export class SocketElement {
Expand Down
4 changes: 2 additions & 2 deletions src/app/global-header/global-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<ion-title
*ngIf="gameHelper.cManager.connectionState !== 0"
class="ion-text-center"
>BetterCrewlink Mobile v0.0.8</ion-title
>BetterCrewlink Mobile v0.0.9</ion-title
>
<ion-title *ngIf="gameHelper.cManager.connectionState == 0" class="ion-text-center"
>BetterCrewlink Mobile v0.0.8</ion-title
>BetterCrewlink Mobile v0.0.9</ion-title
>

</ion-toolbar>
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/game/game.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ion-content color="secondary">
<ion-grid>
{{gameHelper.cManager.connectionState}}
<ng-container [ngSwitch]="gameHelper.cManager.connectionState">
<ng-container *ngSwitchDefault>
<ion-row class="ion-justify-content-center">
Expand Down

0 comments on commit c4fa08a

Please sign in to comment.