pixi-rainman-game-engine 0.2.22 → 0.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,10 @@ export const UXSettings = observer(() => {
14
14
  <SwitchWithHeader header="Battery saver" description="Safe battery life by reducing animation speed" flag={settingStore.batterySaverFlag} setFlag={settingStore.setBatteryFlag}/>
15
15
  </div>
16
16
  <div className="ux-settings__switch">
17
- <SwitchWithHeader header="Ambient music" description="Turn on or off the game music" flag={settingStore.ambientMusicFlag} setFlag={settingStore.setAmbientMusicFlag}/>
17
+ <SwitchWithHeader header="Ambient music" description="Turn on or off the game music" flag={settingStore.shouldPlayAmbientMusic} setFlag={settingStore.setShouldPlayAmbientMusic}/>
18
18
  </div>
19
19
  <div className="ux-settings__switch">
20
- <SwitchWithHeader header="Sound fx" description="Turn on or off the game sounds" flag={settingStore.soundFxFlag} setFlag={settingStore.setSoundFxFlag}/>
20
+ <SwitchWithHeader header="Sound fx" description="Turn on or off the game sounds" flag={settingStore.shouldPlayFxSounds} setFlag={settingStore.setShouldPlayFxSounds}/>
21
21
  </div>
22
22
  <div className="ux-settings__switch">
23
23
  <SwitchWithHeader header="Full screen mode" description="Turn on or off game fullscreen" flag={settingStore.fullScreenFlag} setFlag={settingStore.setFullScreenFlag}/>
@@ -14,7 +14,10 @@ const onChange = (newVolumeLevel) => {
14
14
  };
15
15
  const onAfterChange = (newVolumeLevel) => {
16
16
  RainMan.settingsStore.flipSoundsEnabled(newVolumeLevel);
17
- if (RainMan.settingsStore.isSoundEnabled()) {
17
+ if (!RainMan.settingsStore.isSoundEnabled()) {
18
+ SoundManager.pauseAll();
19
+ }
20
+ else {
18
21
  SoundManager.resumeAll();
19
22
  }
20
23
  };
@@ -29,16 +32,16 @@ export const VolumeSettings = observer(() => {
29
32
  width: "7px",
30
33
  height: "24px",
31
34
  bottom: "-6px",
32
- borderRadius: "4px",
35
+ borderRadius: "4px"
33
36
  }} railStyle={{
34
- backgroundColor: "#fff",
37
+ backgroundColor: "#fff"
35
38
  }} trackStyle={{
36
39
  backgroundColor: COLOR,
37
40
  height: "5px",
38
- borderRadius: "1px",
41
+ borderRadius: "1px"
39
42
  }} onBeforeChange={onBeforeChange} onChange={onChange} onAfterChange={onAfterChange}/>
40
43
  <p className="volume-control__text" style={{
41
- color: COLOR,
44
+ color: COLOR
42
45
  }}>
43
46
  {settingStore.volumeLevel}
44
47
  </p>
@@ -196,8 +196,12 @@ export class ButtonsEventManager {
196
196
  RainMan.settingsStore.setUpdateVolumeButtonTexture(() => RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume());
197
197
  RainMan.componentRegistry.get(VolumeButton.registryName).setOnClick(() => {
198
198
  RainMan.settingsStore.flipSoundsEnabled();
199
- if (RainMan.settingsStore.isSoundEnabled())
199
+ if (RainMan.settingsStore.isSoundEnabled()) {
200
200
  SoundManager.resumeAll();
201
+ if (RainMan.settingsStore.shouldPlayAmbientMusic) {
202
+ SoundManager.setPlayStatus("music", RainMan.settingsStore.shouldPlayAmbientMusic);
203
+ }
204
+ }
201
205
  RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume();
202
206
  this.handleModalInvocation(UI_ITEMS.volume);
203
207
  });
@@ -86,7 +86,7 @@ export class SoundManagerInstance {
86
86
  * @param {SoundTrack} soundName - name of the sound
87
87
  */
88
88
  play(soundName) {
89
- if (!RainMan.settingsStore.soundFxFlag)
89
+ if (!RainMan.settingsStore.shouldPlayFxSounds)
90
90
  return;
91
91
  const overrideSoundName = this.overrides[soundName];
92
92
  const sound = overrideSoundName
@@ -94,7 +94,7 @@ export class SoundManagerInstance {
94
94
  : this.musicCatalogue.get(soundName);
95
95
  if (!sound)
96
96
  return;
97
- if (soundName === "music" && sound.isPlaying && !RainMan.settingsStore.ambientMusicFlag)
97
+ if (soundName === "music" && sound.isPlaying && !RainMan.settingsStore.shouldPlayAmbientMusic)
98
98
  return;
99
99
  sound.play({
100
100
  loop: soundsToLoop.includes(soundName),
@@ -110,7 +110,7 @@ export class SoundManagerInstance {
110
110
  this.musicCatalogue.forEach((sound, soundName) => {
111
111
  if (sound.paused && sound.isPlaying)
112
112
  sound.resume();
113
- if (RainMan.settingsStore.ambientMusicFlag && soundName === SoundTracks.music && sound.paused) {
113
+ if (RainMan.settingsStore.shouldPlayAmbientMusic && soundName === SoundTracks.music && sound.paused) {
114
114
  sound.resume();
115
115
  }
116
116
  });
@@ -20,6 +20,7 @@ export declare class SpinLogic {
20
20
  constructor(spinConfig: AdaptedSpinResponse, gameConfig: ApiConfig);
21
21
  get postSpinBalance(): number;
22
22
  get winTotalAmount(): number;
23
+ get winTotalStreakAmount(): number;
23
24
  get winTotalAmountWithoutMystery(): number;
24
25
  get onStopBlindsConfiguration(): SymbolReels;
25
26
  get finalBlindsConfiguration(): SymbolReels;
@@ -35,6 +35,10 @@ export class SpinLogic {
35
35
  get winTotalAmount() {
36
36
  return this._winTotalAmount;
37
37
  }
38
+ get winTotalStreakAmount() {
39
+ return this._winScenarios.reduce((accumulator, scenario) => accumulator +
40
+ scenario.wins.reduce((winAccumulator, currentWin) => currentWin.type === PossibleWins.streak ? winAccumulator + currentWin.amount : winAccumulator, 0), 0);
41
+ }
38
42
  get winTotalAmountWithoutMystery() {
39
43
  return this._winScenarios.reduce((accumulator, scenario) => accumulator +
40
44
  scenario.wins.reduce((winAccumulator, currentWin) => currentWin.type === PossibleWins.mystery ? winAccumulator : winAccumulator + currentWin.amount, 0), 0);
@@ -57,8 +57,9 @@ export class AbstractMainContainer extends Container {
57
57
  this.messageBox = new MessageBox();
58
58
  if (RainMan.settingsStore.isSoundEnabled()) {
59
59
  SoundManager.resumeAll();
60
- if (RainMan.settingsStore.ambientMusicFlag)
61
- SoundManager.play(SoundTracks.music);
60
+ if (RainMan.settingsStore.shouldPlayAmbientMusic) {
61
+ SoundManager.setPlayStatus(SoundTracks.music, RainMan.settingsStore.shouldPlayAmbientMusic);
62
+ }
62
63
  }
63
64
  RainMan.app.renderer.on("resize", () => this.resize());
64
65
  }
@@ -23,6 +23,7 @@ export declare abstract class AbstractColumnsContainer extends Container impleme
23
23
  quickReelsStop: boolean;
24
24
  protected playLineSoundOnEachStreak: boolean;
25
25
  protected abstract mapSymbolToSound: Record<string, SoundTrack>;
26
+ protected currentPlayingSoundName: Nullable<SoundTrack>;
26
27
  protected abstract maskCoordinates: {
27
28
  top: number;
28
29
  bottom: number;
@@ -24,6 +24,7 @@ export class AbstractColumnsContainer extends Container {
24
24
  playedSounds = [];
25
25
  quickReelsStop = false;
26
26
  playLineSoundOnEachStreak = false;
27
+ currentPlayingSoundName = null;
27
28
  constructor() {
28
29
  super();
29
30
  this.x = 0;
@@ -205,6 +206,10 @@ export class AbstractColumnsContainer extends Container {
205
206
  }
206
207
  stopPlayingSymbolsInColumns() {
207
208
  this.allColumns.forEach((column) => column.stopAllPlayingSymbols());
209
+ if (this.currentPlayingSoundName) {
210
+ SoundManager.stop(this.currentPlayingSoundName);
211
+ this.currentPlayingSoundName = null;
212
+ }
208
213
  }
209
214
  stopPlayingSymbolsTransformationInColumns() {
210
215
  this.allColumns.forEach((column) => column.stopTransformationPlayingSymbols());
@@ -1,6 +1,7 @@
1
1
  import { SpeedLevel, SymbolId } from "../application";
2
2
  import { ResumableContainer, SpineWithResumableContainer, SpriteWithResumableContainer } from "../components";
3
3
  import { InitDataInterface, Point, RangeQuantityValue, SpinData } from "../connectivity";
4
+ import { Nullable } from "../utils";
4
5
  import { PaytableData } from "./types";
5
6
  /**
6
7
  * This class represents global state of pixi and react application
@@ -12,8 +13,8 @@ export declare class SettingsStore {
12
13
  betChangeDisabled: boolean;
13
14
  bet: number;
14
15
  betText: string;
15
- ambientMusicFlag: boolean;
16
- soundFxFlag: boolean;
16
+ shouldPlayAmbientMusic: boolean;
17
+ shouldPlayFxSounds: boolean;
17
18
  fullScreenFlag: boolean;
18
19
  onAnyWin: boolean;
19
20
  totalNumberOfFreeSpins: number;
@@ -75,14 +76,14 @@ export declare class SettingsStore {
75
76
  * @param {boolean} flag - new value for ambient music flag
76
77
  * @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
77
78
  */
78
- setAmbientMusicFlag(flag: boolean, saveToLocalStorage?: boolean): void;
79
+ setShouldPlayAmbientMusic(flag: boolean, saveToLocalStorage?: boolean): void;
79
80
  /**
80
81
  * Sets flag for effect sounds
81
82
  * @param {boolean} flag - new value for sound fx flag
82
83
  * @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
83
84
  */
84
- setSoundFxFlag(flag: boolean, saveToLocalStorage?: boolean): void;
85
- flipSoundsEnabled(volumeLevel?: number | null): void;
85
+ setShouldPlayFxSounds(flag: boolean, saveToLocalStorage?: boolean): void;
86
+ flipSoundsEnabled(volumeLevel?: Nullable<number>): void;
86
87
  isSoundEnabled(): boolean;
87
88
  setFullScreenFlag(flag: boolean): void;
88
89
  setHiResolutionFlag(flag: boolean): void;
@@ -16,10 +16,8 @@ export class SettingsStore {
16
16
  betChangeDisabled = false;
17
17
  bet = 0;
18
18
  betText = "";
19
- ambientMusicFlag = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled) ??
20
- getFromLocalStorage(LOCAL_STORAGE.isSoundEnabled, true);
21
- soundFxFlag = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled) ??
22
- getFromLocalStorage(LOCAL_STORAGE.isSoundEnabled, true);
19
+ shouldPlayAmbientMusic = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled, false);
20
+ shouldPlayFxSounds = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, false);
23
21
  fullScreenFlag = false;
24
22
  onAnyWin = false;
25
23
  totalNumberOfFreeSpins = 0;
@@ -74,8 +72,8 @@ export class SettingsStore {
74
72
  }
75
73
  makeAutoObservable(this, {
76
74
  setBatteryFlag: action.bound,
77
- setAmbientMusicFlag: action.bound,
78
- setSoundFxFlag: action.bound,
75
+ setShouldPlayAmbientMusic: action.bound,
76
+ setShouldPlayFxSounds: action.bound,
79
77
  setFullScreenFlag: action.bound,
80
78
  setHiResolutionFlag: action.bound,
81
79
  setSpeedLevel: action.bound,
@@ -154,8 +152,8 @@ export class SettingsStore {
154
152
  * @param {boolean} flag - new value for ambient music flag
155
153
  * @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
156
154
  */
157
- setAmbientMusicFlag(flag, saveToLocalStorage = true) {
158
- this.ambientMusicFlag = flag;
155
+ setShouldPlayAmbientMusic(flag, saveToLocalStorage = true) {
156
+ this.shouldPlayAmbientMusic = flag;
159
157
  SoundManager.setPlayStatus(SoundTracks.music, flag);
160
158
  this.updateVolumeButtonTexture?.();
161
159
  if (saveToLocalStorage) {
@@ -168,8 +166,8 @@ export class SettingsStore {
168
166
  * @param {boolean} flag - new value for sound fx flag
169
167
  * @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
170
168
  */
171
- setSoundFxFlag(flag, saveToLocalStorage = true) {
172
- this.soundFxFlag = flag;
169
+ setShouldPlayFxSounds(flag, saveToLocalStorage = true) {
170
+ this.shouldPlayFxSounds = flag;
173
171
  if (!flag)
174
172
  SoundManager.stopPlayingFxSounds();
175
173
  this.updateVolumeButtonTexture?.();
@@ -179,23 +177,26 @@ export class SettingsStore {
179
177
  }
180
178
  }
181
179
  flipSoundsEnabled(volumeLevel = null) {
182
- const flag = volumeLevel !== null ? volumeLevel > 0 : !(this.ambientMusicFlag || this.soundFxFlag);
183
- const ambientMusicLocalStorageFlag = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled, true);
184
- const soundFxLocalStorageFlag = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, true);
185
- let ambientMusicFlag = flag && ambientMusicLocalStorageFlag;
186
- let soundFxFlag = flag && soundFxLocalStorageFlag;
187
- if (!ambientMusicLocalStorageFlag && !soundFxLocalStorageFlag) {
180
+ let shouldEnableSound = volumeLevel !== null ? volumeLevel > 0 : !this.isSoundEnabled();
181
+ const ambientEnabledInStorage = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled, true);
182
+ const fxEnabledInStorage = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, true);
183
+ let ambientMusicFlag = shouldEnableSound && ambientEnabledInStorage;
184
+ let soundFxFlag = shouldEnableSound && fxEnabledInStorage;
185
+ const bothDisabledInStorage = !ambientEnabledInStorage && !fxEnabledInStorage;
186
+ if (bothDisabledInStorage) {
188
187
  ambientMusicFlag = true;
189
188
  soundFxFlag = true;
189
+ shouldEnableSound = true;
190
190
  removeFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled);
191
191
  removeFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled);
192
+ removeFromLocalStorage(LOCAL_STORAGE.isSoundEnabled);
192
193
  }
193
- this.setAmbientMusicFlag(ambientMusicFlag, false);
194
- this.setSoundFxFlag(soundFxFlag, false);
195
- setToLocalStorage(LOCAL_STORAGE.isSoundEnabled, flag);
194
+ this.setShouldPlayAmbientMusic(ambientMusicFlag, true);
195
+ this.setShouldPlayFxSounds(soundFxFlag, true);
196
+ setToLocalStorage(LOCAL_STORAGE.isSoundEnabled, shouldEnableSound);
196
197
  }
197
198
  isSoundEnabled() {
198
- return this.soundFxFlag || this.ambientMusicFlag;
199
+ return this.shouldPlayFxSounds || this.shouldPlayAmbientMusic;
199
200
  }
200
201
  setFullScreenFlag(flag) {
201
202
  this.fullScreenFlag = flag;
@@ -2,5 +2,6 @@ export * from "./AnimableParticlesEmitter";
2
2
  export * from "./BigWinContainer";
3
3
  export * from "./MysteryWinContainer";
4
4
  export * from "./PositioningFrame";
5
+ export * from "./TexturedText";
5
6
  export * from "./UpdatableSpineContainer";
6
7
  export * from "./winFactory";
@@ -2,5 +2,6 @@ export * from "./AnimableParticlesEmitter";
2
2
  export * from "./BigWinContainer";
3
3
  export * from "./MysteryWinContainer";
4
4
  export * from "./PositioningFrame";
5
+ export * from "./TexturedText";
5
6
  export * from "./UpdatableSpineContainer";
6
7
  export * from "./winFactory";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "This repository contains all of the mechanics that used in rainman games.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",