pixi-rainman-game-engine 0.0.1 → 0.0.3
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.
- package/dist/buttons/BaseButton/BaseButton.d.ts +35 -0
- package/dist/buttons/BaseButton/BaseButton.js +131 -0
- package/dist/buttons/BaseButton/ButtonState.d.ts +8 -0
- package/dist/buttons/BaseButton/ButtonState.js +9 -0
- package/dist/buttons/BaseButton/index.d.ts +1 -0
- package/dist/buttons/BaseButton/index.js +1 -0
- package/dist/buttons/BaseButton/types.d.ts +3 -0
- package/dist/buttons/BaseButton/types.js +1 -0
- package/dist/buttons/index.d.ts +1 -0
- package/dist/buttons/index.js +1 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +3 -0
- package/dist/freeSpins/AbstractFreeSpinContainer/AbstractFreeSpinContainer.d.ts +5 -0
- package/dist/freeSpins/AbstractFreeSpinContainer/AbstractFreeSpinContainer.js +3 -0
- package/dist/freeSpins/AbstractFreeSpinContainer/index.d.ts +1 -0
- package/dist/freeSpins/AbstractFreeSpinContainer/index.js +1 -0
- package/dist/freeSpins/FreeSpinPlate/FreeSpinPlate.d.ts +28 -0
- package/dist/freeSpins/FreeSpinPlate/FreeSpinPlate.js +57 -0
- package/dist/freeSpins/FreeSpinPlate/index.d.ts +1 -0
- package/dist/freeSpins/FreeSpinPlate/index.js +1 -0
- package/dist/freeSpins/FreeSpinPlate/types.d.ts +14 -0
- package/dist/freeSpins/FreeSpinPlate/types.js +7 -0
- package/dist/freeSpins/FreeSpinSummary/FreeSpinSummary.d.ts +25 -0
- package/dist/freeSpins/FreeSpinSummary/FreeSpinSummary.js +51 -0
- package/dist/freeSpins/FreeSpinSummary/index.d.ts +2 -0
- package/dist/freeSpins/FreeSpinSummary/index.js +2 -0
- package/dist/freeSpins/FreeSpinSummary/types.d.ts +14 -0
- package/dist/freeSpins/FreeSpinSummary/types.js +7 -0
- package/dist/freeSpins/index.d.ts +3 -0
- package/dist/freeSpins/index.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/loading/ProgressiveLoader.d.ts +10 -0
- package/dist/loading/ProgressiveLoader.js +1 -0
- package/dist/loading/SpriteLoadingContainer.d.ts +32 -0
- package/dist/loading/SpriteLoadingContainer.js +71 -0
- package/dist/loading/index.d.ts +2 -0
- package/dist/loading/index.js +2 -0
- package/dist/utils/application/application.d.ts +3 -0
- package/dist/utils/application/application.js +2 -0
- package/dist/utils/application/index.d.ts +2 -0
- package/dist/utils/application/index.js +2 -0
- package/dist/utils/application/types.d.ts +2 -0
- package/dist/utils/application/types.js +1 -0
- package/dist/utils/assets/assetGetter.d.ts +5 -0
- package/dist/utils/assets/assetGetter.js +33 -0
- package/dist/utils/assets/index.d.ts +2 -0
- package/dist/utils/assets/index.js +2 -0
- package/dist/utils/assets/types.d.ts +8 -0
- package/dist/utils/assets/types.js +1 -0
- package/dist/utils/common/deviceOrientation.d.ts +2 -0
- package/dist/utils/common/deviceOrientation.js +14 -0
- package/dist/utils/common/functions.d.ts +4 -0
- package/dist/utils/common/functions.js +43 -0
- package/dist/utils/common/index.d.ts +3 -0
- package/dist/utils/common/index.js +3 -0
- package/dist/utils/common/types.d.ts +4 -0
- package/dist/utils/common/types.js +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/package.json +15 -13
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Sprite, Texture } from "pixi.js";
|
|
2
|
+
import { ButtonStates } from "./ButtonState";
|
|
3
|
+
import { TextureMap } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Class for basic button with states and textures
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @class BaseButton
|
|
9
|
+
* @typedef {BaseButton}
|
|
10
|
+
* @extends {Sprite}
|
|
11
|
+
*/
|
|
12
|
+
export declare class BaseButton extends Sprite {
|
|
13
|
+
static registryName: string;
|
|
14
|
+
protected textures: TextureMap;
|
|
15
|
+
private stateful;
|
|
16
|
+
private isActive;
|
|
17
|
+
private isOver;
|
|
18
|
+
private isDisabled;
|
|
19
|
+
private _onClick;
|
|
20
|
+
private _customClickHandler;
|
|
21
|
+
constructor(name: string, texture: Texture, stateful?: boolean);
|
|
22
|
+
get active(): boolean;
|
|
23
|
+
forceTextureUpdate(): void;
|
|
24
|
+
setOnClick(callback: () => void): void;
|
|
25
|
+
activate(flag: boolean): void;
|
|
26
|
+
flipDisabledFlag(makeDisabled: boolean): void;
|
|
27
|
+
protected switchTexture(state: ButtonStates): void;
|
|
28
|
+
protected setTextureForState(state: ButtonStates, texture: Texture): void;
|
|
29
|
+
get disabled(): boolean;
|
|
30
|
+
get onClick(): typeof this._onClick;
|
|
31
|
+
private _manageStateUp;
|
|
32
|
+
private _manageStateOver;
|
|
33
|
+
private _manageStateDown;
|
|
34
|
+
private _manageStateOut;
|
|
35
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Sprite } from "pixi.js";
|
|
2
|
+
import { TINT_DISABLED, TINT_ENABLED } from "../../constants";
|
|
3
|
+
import { ButtonStates } from "./ButtonState";
|
|
4
|
+
/**
|
|
5
|
+
* Class for basic button with states and textures
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @class BaseButton
|
|
9
|
+
* @typedef {BaseButton}
|
|
10
|
+
* @extends {Sprite}
|
|
11
|
+
*/
|
|
12
|
+
export class BaseButton extends Sprite {
|
|
13
|
+
static registryName;
|
|
14
|
+
textures = new Map();
|
|
15
|
+
stateful = false;
|
|
16
|
+
isActive = false;
|
|
17
|
+
isOver = false;
|
|
18
|
+
isDisabled = false;
|
|
19
|
+
_onClick = () => {
|
|
20
|
+
if (this.isDisabled) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.stateful) {
|
|
24
|
+
this.isActive = !this.isActive;
|
|
25
|
+
}
|
|
26
|
+
this._customClickHandler();
|
|
27
|
+
this._manageStateOver();
|
|
28
|
+
};
|
|
29
|
+
_customClickHandler = () => { };
|
|
30
|
+
constructor(name, texture, stateful = false) {
|
|
31
|
+
super(texture);
|
|
32
|
+
this.stateful = stateful;
|
|
33
|
+
this.x = 0;
|
|
34
|
+
this.y = 0;
|
|
35
|
+
this.name = name;
|
|
36
|
+
this.interactive = true;
|
|
37
|
+
this.isActive = false;
|
|
38
|
+
}
|
|
39
|
+
get active() {
|
|
40
|
+
return this.isActive;
|
|
41
|
+
}
|
|
42
|
+
forceTextureUpdate() {
|
|
43
|
+
this.isOver = false;
|
|
44
|
+
if (this.isActive) {
|
|
45
|
+
this.switchTexture(ButtonStates.ACTIVE);
|
|
46
|
+
}
|
|
47
|
+
if (!this.isActive) {
|
|
48
|
+
this.switchTexture(ButtonStates.NORMAL);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
setOnClick(callback) {
|
|
52
|
+
this.removeAllListeners();
|
|
53
|
+
this._customClickHandler = callback;
|
|
54
|
+
this
|
|
55
|
+
// set the mousedown and touchstart callback...
|
|
56
|
+
.on("click", this._onClick)
|
|
57
|
+
.on("mouseup", this._manageStateUp)
|
|
58
|
+
.on("mousedown", this._manageStateDown)
|
|
59
|
+
.on("mouseover", this._manageStateOver)
|
|
60
|
+
.on("mouseout", this._manageStateOut)
|
|
61
|
+
.on("tap", this._onClick)
|
|
62
|
+
.on("touchend", this._manageStateUp)
|
|
63
|
+
.on("pointercancel", this._manageStateUp)
|
|
64
|
+
.on("touchcancel", this._manageStateUp);
|
|
65
|
+
}
|
|
66
|
+
activate(flag) {
|
|
67
|
+
this.isActive = flag;
|
|
68
|
+
this.forceTextureUpdate();
|
|
69
|
+
}
|
|
70
|
+
flipDisabledFlag(makeDisabled) {
|
|
71
|
+
this.isDisabled = makeDisabled;
|
|
72
|
+
this.interactive = !makeDisabled;
|
|
73
|
+
this.tint = makeDisabled ? TINT_DISABLED : TINT_ENABLED;
|
|
74
|
+
}
|
|
75
|
+
switchTexture(state) {
|
|
76
|
+
if (this.textures.has(state)) {
|
|
77
|
+
this.texture = this.textures.get(state);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
setTextureForState(state, texture) {
|
|
81
|
+
this.textures.set(state, texture);
|
|
82
|
+
}
|
|
83
|
+
get disabled() {
|
|
84
|
+
return this.isDisabled;
|
|
85
|
+
}
|
|
86
|
+
get onClick() {
|
|
87
|
+
return this._onClick;
|
|
88
|
+
}
|
|
89
|
+
_manageStateUp() {
|
|
90
|
+
if (this.isActive) {
|
|
91
|
+
if (this.isOver) {
|
|
92
|
+
this.switchTexture(ButtonStates.ACTIVE_OVER);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.switchTexture(ButtonStates.ACTIVE);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!this.isActive) {
|
|
99
|
+
this.switchTexture(ButtonStates.NORMAL);
|
|
100
|
+
}
|
|
101
|
+
if (this.isOver) {
|
|
102
|
+
this.switchTexture(ButtonStates.OVER);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_manageStateOver() {
|
|
106
|
+
this.isOver = true;
|
|
107
|
+
if (this.isActive) {
|
|
108
|
+
this.switchTexture(ButtonStates.ACTIVE_OVER);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.switchTexture(ButtonStates.OVER);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
_manageStateDown() {
|
|
115
|
+
if (this.isActive) {
|
|
116
|
+
this.switchTexture(ButtonStates.ACTIVE_CLICKED);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.switchTexture(ButtonStates.CLICKED);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_manageStateOut() {
|
|
123
|
+
this.isOver = false;
|
|
124
|
+
if (this.isActive) {
|
|
125
|
+
this.switchTexture(ButtonStates.ACTIVE);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.switchTexture(ButtonStates.NORMAL);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var ButtonStates;
|
|
2
|
+
(function (ButtonStates) {
|
|
3
|
+
ButtonStates["NORMAL"] = "normal";
|
|
4
|
+
ButtonStates["OVER"] = "over";
|
|
5
|
+
ButtonStates["CLICKED"] = "clicked";
|
|
6
|
+
ButtonStates["ACTIVE"] = "active";
|
|
7
|
+
ButtonStates["ACTIVE_OVER"] = "activeOver";
|
|
8
|
+
ButtonStates["ACTIVE_CLICKED"] = "activeClicked";
|
|
9
|
+
})(ButtonStates || (ButtonStates = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BaseButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BaseButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BaseButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BaseButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AbstractFreeSpinContainer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AbstractFreeSpinContainer";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseButton } from "buttons";
|
|
2
|
+
import { AbstractFreeSpinContainer } from "freeSpins/AbstractFreeSpinContainer/AbstractFreeSpinContainer";
|
|
3
|
+
import { Container } from "pixi.js";
|
|
4
|
+
import { Nullable } from "utils/common";
|
|
5
|
+
import { LoadersSpineData } from "../../utils/assets";
|
|
6
|
+
import { FreeSpinPlateTexts } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Free Spin Plate class
|
|
9
|
+
*
|
|
10
|
+
* This container shows at the start of the free games
|
|
11
|
+
*
|
|
12
|
+
* @member {Sprite | Spine} freeSpinPlate texture used in free spin summary
|
|
13
|
+
* @member {Text[]} texts all of texts that shows in summary
|
|
14
|
+
* @member {BaseButton} startButton button for starting free spin game
|
|
15
|
+
* @member {number} shownAt time that free spin plate was shown
|
|
16
|
+
*/
|
|
17
|
+
export declare class FreeSpinPlate extends Container implements AbstractFreeSpinContainer {
|
|
18
|
+
private freeSpinPlate;
|
|
19
|
+
private texts;
|
|
20
|
+
private startButton;
|
|
21
|
+
shownAt: number;
|
|
22
|
+
constructor(freeSpinTexture: string, texts: FreeSpinPlateTexts, button: BaseButton, startClickResolver: () => void, spineData?: Nullable<LoadersSpineData>, isSpine?: boolean);
|
|
23
|
+
get onClick(): typeof this.startButton.onClick;
|
|
24
|
+
resize(scale: number, width: number, height: number): void;
|
|
25
|
+
reposition(width: number, height: number): void;
|
|
26
|
+
private centerComponent;
|
|
27
|
+
private initChildPositions;
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Container, Sprite, Text, Texture } from "pixi.js";
|
|
2
|
+
import { Spine } from "pixi-spine";
|
|
3
|
+
/**
|
|
4
|
+
* Free Spin Plate class
|
|
5
|
+
*
|
|
6
|
+
* This container shows at the start of the free games
|
|
7
|
+
*
|
|
8
|
+
* @member {Sprite | Spine} freeSpinPlate texture used in free spin summary
|
|
9
|
+
* @member {Text[]} texts all of texts that shows in summary
|
|
10
|
+
* @member {BaseButton} startButton button for starting free spin game
|
|
11
|
+
* @member {number} shownAt time that free spin plate was shown
|
|
12
|
+
*/
|
|
13
|
+
export class FreeSpinPlate extends Container {
|
|
14
|
+
freeSpinPlate;
|
|
15
|
+
texts;
|
|
16
|
+
startButton;
|
|
17
|
+
shownAt;
|
|
18
|
+
constructor(freeSpinTexture, texts, button, startClickResolver, spineData = null, isSpine = false) {
|
|
19
|
+
super();
|
|
20
|
+
if (isSpine && spineData) {
|
|
21
|
+
this.freeSpinPlate = new Spine(spineData);
|
|
22
|
+
}
|
|
23
|
+
this.interactive = true;
|
|
24
|
+
this.freeSpinPlate = new Sprite(Texture.from(freeSpinTexture));
|
|
25
|
+
this.texts = Object.keys(texts).map((text) => new Text(texts[text].text, texts[text].style));
|
|
26
|
+
this.startButton = button;
|
|
27
|
+
this.startButton.setOnClick(startClickResolver);
|
|
28
|
+
this.shownAt = performance.now();
|
|
29
|
+
}
|
|
30
|
+
get onClick() {
|
|
31
|
+
return this.startButton.onClick;
|
|
32
|
+
}
|
|
33
|
+
resize(scale, width, height) {
|
|
34
|
+
this.scale.set(scale);
|
|
35
|
+
this.reposition(width, height);
|
|
36
|
+
this.initChildPositions();
|
|
37
|
+
}
|
|
38
|
+
reposition(width, height) {
|
|
39
|
+
this.x = width - this.width / 2;
|
|
40
|
+
this.y = height - this.height / 2;
|
|
41
|
+
}
|
|
42
|
+
centerComponent(component) {
|
|
43
|
+
component.x = this.freeSpinPlate.width / 2 - component.width / 2;
|
|
44
|
+
}
|
|
45
|
+
initChildPositions() {
|
|
46
|
+
this.texts.forEach((text) => this.removeChild(text));
|
|
47
|
+
for (let index = 1; index <= this.texts.length; index++) {
|
|
48
|
+
this.centerComponent(this.texts[index]);
|
|
49
|
+
if (index - 1 === 0)
|
|
50
|
+
this.texts[index - 1].y = 0 + this.texts[index - 1].height;
|
|
51
|
+
this.texts[index].y += this.texts[index].height + this.texts[index - 1].y + this.texts[index - 1].height;
|
|
52
|
+
}
|
|
53
|
+
this.startButton.y = this.texts[this.texts.length - 1].y + this.texts[this.texts.length - 1].height;
|
|
54
|
+
this.texts.forEach((text) => this.addChild(text));
|
|
55
|
+
this.addChild(this.startButton);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FreeSpinPlate";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FreeSpinPlate";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ITextStyle } from "pixi.js";
|
|
2
|
+
declare const TextTypes: {
|
|
3
|
+
readonly congratulationsText: "congratulations";
|
|
4
|
+
readonly youHaveWonText: "youHaveWonText";
|
|
5
|
+
readonly numberText: "numberText";
|
|
6
|
+
readonly description: "description";
|
|
7
|
+
};
|
|
8
|
+
export type FreeSpinPlateText = keyof typeof TextTypes;
|
|
9
|
+
export type TextOptions = {
|
|
10
|
+
text: string;
|
|
11
|
+
style: Partial<ITextStyle>;
|
|
12
|
+
};
|
|
13
|
+
export type FreeSpinPlateTexts = Record<FreeSpinPlateText, TextOptions>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AbstractFreeSpinContainer } from "freeSpins/AbstractFreeSpinContainer/AbstractFreeSpinContainer";
|
|
2
|
+
import { Container } from "pixi.js";
|
|
3
|
+
import { FreeSpinSummaryTexts } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Free Spin Summary class
|
|
6
|
+
*
|
|
7
|
+
* This container shows the summary of free games
|
|
8
|
+
*
|
|
9
|
+
* @member {Sprite} freeSpinSummary texture used in free spin summary
|
|
10
|
+
* @member {Text[]} texts all of texts that shows in summary
|
|
11
|
+
* @member {VoidFunction} hideResolver resolver for hiding free spin summary container
|
|
12
|
+
* @member {number} shownAt time that free spin summary was shown
|
|
13
|
+
*/
|
|
14
|
+
export declare class FreeSpinSummary extends Container implements AbstractFreeSpinContainer {
|
|
15
|
+
private freeSpinSummary;
|
|
16
|
+
private texts;
|
|
17
|
+
shownAt: number;
|
|
18
|
+
private hideResolver;
|
|
19
|
+
constructor(textureName: string, texts: FreeSpinSummaryTexts, startClickResolver: () => void);
|
|
20
|
+
get onClick(): typeof this.hideResolver;
|
|
21
|
+
resize(scale: number, width: number, height: number): void;
|
|
22
|
+
reposition(width: number, height: number): void;
|
|
23
|
+
private centerComponent;
|
|
24
|
+
private initChildPositions;
|
|
25
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Container, Sprite, Text, Texture } from "pixi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Free Spin Summary class
|
|
4
|
+
*
|
|
5
|
+
* This container shows the summary of free games
|
|
6
|
+
*
|
|
7
|
+
* @member {Sprite} freeSpinSummary texture used in free spin summary
|
|
8
|
+
* @member {Text[]} texts all of texts that shows in summary
|
|
9
|
+
* @member {VoidFunction} hideResolver resolver for hiding free spin summary container
|
|
10
|
+
* @member {number} shownAt time that free spin summary was shown
|
|
11
|
+
*/
|
|
12
|
+
export class FreeSpinSummary extends Container {
|
|
13
|
+
freeSpinSummary;
|
|
14
|
+
texts;
|
|
15
|
+
shownAt;
|
|
16
|
+
hideResolver;
|
|
17
|
+
constructor(textureName, texts, startClickResolver) {
|
|
18
|
+
super();
|
|
19
|
+
this.freeSpinSummary = new Sprite(Texture.from(textureName));
|
|
20
|
+
this.texts = Object.keys(texts).map((keyText) => new Text(texts[keyText].text, texts[keyText].style));
|
|
21
|
+
this.shownAt = performance.now();
|
|
22
|
+
this.hideResolver = startClickResolver;
|
|
23
|
+
this.addListener("pointerdown", () => startClickResolver());
|
|
24
|
+
this.interactive = true;
|
|
25
|
+
}
|
|
26
|
+
get onClick() {
|
|
27
|
+
return this.hideResolver;
|
|
28
|
+
}
|
|
29
|
+
resize(scale, width, height) {
|
|
30
|
+
this.scale.set(scale);
|
|
31
|
+
this.reposition(width, height);
|
|
32
|
+
this.initChildPositions();
|
|
33
|
+
}
|
|
34
|
+
reposition(width, height) {
|
|
35
|
+
this.x = width - this.width / 2;
|
|
36
|
+
this.y = height - this.height / 2;
|
|
37
|
+
}
|
|
38
|
+
centerComponent(component) {
|
|
39
|
+
component.x = this.freeSpinSummary.width / 2 - component.width / 2;
|
|
40
|
+
}
|
|
41
|
+
initChildPositions() {
|
|
42
|
+
this.texts.forEach((text) => this.removeChild(text));
|
|
43
|
+
for (let index = 1; index <= this.texts.length; index++) {
|
|
44
|
+
this.centerComponent(this.texts[index]);
|
|
45
|
+
if (index - 1 === 0)
|
|
46
|
+
this.texts[index - 1].y = 0 + this.texts[index - 1].height;
|
|
47
|
+
this.texts[index].y += this.texts[index].height + this.texts[index - 1].y + this.texts[index - 1].height;
|
|
48
|
+
}
|
|
49
|
+
this.texts.forEach((text) => this.addChild(text));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ITextStyle } from "pixi.js";
|
|
2
|
+
declare const TextTypes: {
|
|
3
|
+
readonly congratulationsText: "congratulations";
|
|
4
|
+
readonly youHaveWonText: "youHaveWonText";
|
|
5
|
+
readonly numberText: "numberText";
|
|
6
|
+
readonly description: "description";
|
|
7
|
+
};
|
|
8
|
+
export type FreeSpinSummaryText = keyof typeof TextTypes;
|
|
9
|
+
export type TextOptions = {
|
|
10
|
+
text: string;
|
|
11
|
+
style: Partial<ITextStyle>;
|
|
12
|
+
};
|
|
13
|
+
export type FreeSpinSummaryTexts = Record<FreeSpinSummaryText, TextOptions>;
|
|
14
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Application, Container, ITextStyle } from "pixi.js";
|
|
2
|
+
import { ProgressiveLoader } from "./ProgressiveLoader";
|
|
3
|
+
/**
|
|
4
|
+
* This class contains the loading process to pixi application
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class SpriteLoadingContainer
|
|
8
|
+
* @typedef {SpriteLoadingContainer}
|
|
9
|
+
* @extends {Container}
|
|
10
|
+
* @implements {ProgressiveLoader}
|
|
11
|
+
*/
|
|
12
|
+
export declare class SpriteLoadingContainer extends Container implements ProgressiveLoader {
|
|
13
|
+
private sprite;
|
|
14
|
+
private text;
|
|
15
|
+
private application;
|
|
16
|
+
private rectangle;
|
|
17
|
+
private readonly loadingStatusContainerHeight;
|
|
18
|
+
private readonly loadingStatusContainerWidth;
|
|
19
|
+
private readonly loadingStatusWidth;
|
|
20
|
+
private readonly loadingStatusHeight;
|
|
21
|
+
/**
|
|
22
|
+
* Constructor for SpriteLoadingContainer
|
|
23
|
+
*
|
|
24
|
+
* @param {Application} application pixi application that have information about size of canvas
|
|
25
|
+
* @param {string} texture path to texture for logo
|
|
26
|
+
* @param {Partial<ITextStyle>} textOptions contains the options for text color blur
|
|
27
|
+
*/
|
|
28
|
+
constructor(application: Application, texture: string, textOptions: Partial<ITextStyle>);
|
|
29
|
+
updateProgress(progress: number): void;
|
|
30
|
+
resize(): void;
|
|
31
|
+
reposition(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Container, Graphics, Sprite, Text, TextStyle, Texture } from "pixi.js";
|
|
2
|
+
/**
|
|
3
|
+
* This class contains the loading process to pixi application
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class SpriteLoadingContainer
|
|
7
|
+
* @typedef {SpriteLoadingContainer}
|
|
8
|
+
* @extends {Container}
|
|
9
|
+
* @implements {ProgressiveLoader}
|
|
10
|
+
*/
|
|
11
|
+
export class SpriteLoadingContainer extends Container {
|
|
12
|
+
sprite;
|
|
13
|
+
text;
|
|
14
|
+
application;
|
|
15
|
+
rectangle;
|
|
16
|
+
loadingStatusContainerHeight = 40;
|
|
17
|
+
loadingStatusContainerWidth = 150;
|
|
18
|
+
loadingStatusWidth = this.loadingStatusContainerWidth - 20;
|
|
19
|
+
loadingStatusHeight = this.loadingStatusContainerHeight - 10;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor for SpriteLoadingContainer
|
|
22
|
+
*
|
|
23
|
+
* @param {Application} application pixi application that have information about size of canvas
|
|
24
|
+
* @param {string} texture path to texture for logo
|
|
25
|
+
* @param {Partial<ITextStyle>} textOptions contains the options for text color blur
|
|
26
|
+
*/
|
|
27
|
+
constructor(application, texture, textOptions) {
|
|
28
|
+
super();
|
|
29
|
+
this.application = application;
|
|
30
|
+
this.rectangle = new Graphics();
|
|
31
|
+
this.sprite = Sprite.from(Texture.from(texture));
|
|
32
|
+
this.rectangle.lineTextureStyle({ width: 5, texture: this.sprite.texture });
|
|
33
|
+
this.rectangle.beginFill(0x650a5a, 0.25);
|
|
34
|
+
this.rectangle.drawRoundedRect(0, 0, this.loadingStatusContainerWidth, this.loadingStatusContainerHeight, 8);
|
|
35
|
+
this.rectangle.endFill();
|
|
36
|
+
this.sprite.width = 0;
|
|
37
|
+
this.sprite.height = this.loadingStatusHeight;
|
|
38
|
+
this.sprite.tint = 0xfcd784;
|
|
39
|
+
this.addChild(this.rectangle);
|
|
40
|
+
const loaderTextStyle = new TextStyle({
|
|
41
|
+
...textOptions,
|
|
42
|
+
fontSize: 24,
|
|
43
|
+
strokeThickness: 3,
|
|
44
|
+
dropShadow: true,
|
|
45
|
+
dropShadowBlur: 4,
|
|
46
|
+
dropShadowAngle: Math.PI / 6,
|
|
47
|
+
dropShadowDistance: 6,
|
|
48
|
+
align: "center"
|
|
49
|
+
});
|
|
50
|
+
this.text = new Text(`Loaded: ${0}%`, loaderTextStyle);
|
|
51
|
+
this.text.anchor.set(0, 0.5);
|
|
52
|
+
this.reposition();
|
|
53
|
+
this.addChild(this.sprite);
|
|
54
|
+
this.addChild(this.text);
|
|
55
|
+
}
|
|
56
|
+
updateProgress(progress) {
|
|
57
|
+
this.text.text = `Loaded: ${(progress * 100).toFixed(2)}%`;
|
|
58
|
+
this.sprite.width = this.loadingStatusWidth * progress;
|
|
59
|
+
}
|
|
60
|
+
resize() {
|
|
61
|
+
this.reposition();
|
|
62
|
+
}
|
|
63
|
+
reposition() {
|
|
64
|
+
this.rectangle.y = this.application.screen.height / 2;
|
|
65
|
+
this.rectangle.x = this.application.screen.width / 2;
|
|
66
|
+
this.sprite.y = this.rectangle.y + 5;
|
|
67
|
+
this.sprite.x = this.rectangle.x + 10;
|
|
68
|
+
this.text.x = this.rectangle.x;
|
|
69
|
+
this.text.y = this.rectangle.y + 70;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LoadersSpineData, Resource } from "./types";
|
|
2
|
+
export declare const getSpineData: (resourceName: string) => LoadersSpineData;
|
|
3
|
+
export declare const loadAssets: (assets: Resource, updateProgress?: ((progress: number) => void) | undefined) => Promise<void>;
|
|
4
|
+
export declare const checkIfAssetsLoaded: (assets: Resource) => boolean;
|
|
5
|
+
export declare const waitForAssetsToLoad: (assets: Resource) => Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Assets } from "pixi.js";
|
|
2
|
+
export const getSpineData = (resourceName) => {
|
|
3
|
+
const spine = Assets.get(resourceName);
|
|
4
|
+
if (!spine)
|
|
5
|
+
throw Error(`[Assets] Could not find resource ${resourceName}!`);
|
|
6
|
+
return spine.spineData;
|
|
7
|
+
};
|
|
8
|
+
export const loadAssets = async (assets, updateProgress) => {
|
|
9
|
+
try {
|
|
10
|
+
const aliases = Object.keys(assets).map((key) => ({ alias: key, src: assets[key] }));
|
|
11
|
+
await Assets.load(aliases, (progress) => updateProgress?.(progress));
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
throw Error();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const checkIfAssetsLoaded = (assets) => {
|
|
18
|
+
for (const key of Object.keys(assets)) {
|
|
19
|
+
if (!Assets.cache.has(key))
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
export const waitForAssetsToLoad = async (assets) => {
|
|
25
|
+
return new Promise((res) => {
|
|
26
|
+
const interval = setInterval(() => {
|
|
27
|
+
if (checkIfAssetsLoaded(assets)) {
|
|
28
|
+
res();
|
|
29
|
+
clearInterval(interval);
|
|
30
|
+
}
|
|
31
|
+
}, 50);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAnimation, IBoneData, IEventData, IIkConstraintData, IPathConstraintData, ISkeletonData, ISkin, ISlotData, ITimeline, ITransformConstraintData } from "pixi-spine";
|
|
2
|
+
export type LoadersSpineData = ISkeletonData<IBoneData, ISlotData, ISkin, IAnimation<ITimeline>, IEventData, IIkConstraintData, ITransformConstraintData, IPathConstraintData>;
|
|
3
|
+
export type SpineResource = {
|
|
4
|
+
spineData: LoadersSpineData;
|
|
5
|
+
skeletonData: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type Resource = Record<string, string>;
|
|
8
|
+
export type AccessorToResource<T extends Record<string, string>> = keyof T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getScreenRatio, isMobile } from "./functions";
|
|
2
|
+
export const getDeviceOrientation = () => {
|
|
3
|
+
if (isMobile()) {
|
|
4
|
+
if (window.matchMedia("(orientation: portrait)").matches) {
|
|
5
|
+
return "mobile-portrait";
|
|
6
|
+
}
|
|
7
|
+
if (window.matchMedia("(orientation: landscape)").matches) {
|
|
8
|
+
return "mobile-landscape";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (getScreenRatio() < 1)
|
|
12
|
+
return "mobile-portrait";
|
|
13
|
+
return "pc";
|
|
14
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getDeviceOrientation } from "./deviceOrientation";
|
|
2
|
+
export const checkMobileBrowser = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent || navigator.vendor);
|
|
3
|
+
export const getScreenRatio = () => window.innerWidth / window.innerHeight;
|
|
4
|
+
export const isMobile = () => {
|
|
5
|
+
let check = false;
|
|
6
|
+
(function (a) {
|
|
7
|
+
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
|
|
8
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))
|
|
9
|
+
check = true;
|
|
10
|
+
})(navigator.userAgent || navigator.vendor);
|
|
11
|
+
return check;
|
|
12
|
+
};
|
|
13
|
+
export const setupFullscreenForIOS = () => {
|
|
14
|
+
if (!isMobile() || !checkMobileBrowser())
|
|
15
|
+
return;
|
|
16
|
+
document.body.style.overflow = "auto";
|
|
17
|
+
const scrollingElement = document.scrollingElement;
|
|
18
|
+
if (!scrollingElement)
|
|
19
|
+
return;
|
|
20
|
+
scrollingElement.scrollTo(0, 0);
|
|
21
|
+
let lastOrientation = getDeviceOrientation();
|
|
22
|
+
const scrollOverlay = document.createElement("div");
|
|
23
|
+
scrollOverlay.setAttribute("class", "ios-scroller");
|
|
24
|
+
document.body.appendChild(scrollOverlay);
|
|
25
|
+
const scrollOverlayAnimation = document.createElement("div");
|
|
26
|
+
scrollOverlayAnimation.setAttribute("class", "ios-scroller-animation");
|
|
27
|
+
document.body.appendChild(scrollOverlayAnimation);
|
|
28
|
+
let lastHeight = window.innerHeight;
|
|
29
|
+
addEventListener("resize", () => {
|
|
30
|
+
const currentOrientation = getDeviceOrientation();
|
|
31
|
+
const changedToLandScape = lastOrientation === "mobile-portrait" && currentOrientation === "mobile-landscape";
|
|
32
|
+
const changedToPortrait = lastOrientation === "mobile-landscape" && currentOrientation === "mobile-portrait";
|
|
33
|
+
if ((window.innerHeight < lastHeight && !changedToLandScape) || changedToPortrait) {
|
|
34
|
+
scrollingElement.scrollTo(0, 0);
|
|
35
|
+
document.documentElement.classList.remove("is-locked");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
document.documentElement.classList.add("is-locked");
|
|
39
|
+
}
|
|
40
|
+
lastHeight = window.innerHeight;
|
|
41
|
+
lastOrientation = currentOrientation;
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixi-rainman-game-engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "This repository contains all of the mechanics that used in rainman games.",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rm -rf dist && tsc",
|
|
9
9
|
"lint": "eslint src/** --fix",
|
|
10
|
-
"prepare": "husky"
|
|
10
|
+
"prepare": "husky && yarn build"
|
|
11
11
|
},
|
|
12
|
-
"keywords": [],
|
|
13
12
|
"type": "module",
|
|
14
13
|
"author": "@niceguys",
|
|
15
14
|
"license": "ISC",
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/niceguyspl/app-rainman-engine.git"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"README.md"
|
|
23
|
-
],
|
|
24
15
|
"dependencies": {
|
|
25
16
|
"pixi-spine": "^4.0.4",
|
|
26
17
|
"pixi.js": "^7.4.0"
|
|
@@ -44,5 +35,16 @@
|
|
|
44
35
|
"bugs": {
|
|
45
36
|
"url": "https://github.com/niceguyspl/app-rainman-engine/issues"
|
|
46
37
|
},
|
|
47
|
-
"homepage": "https://github.com/niceguyspl/app-rainman-engine#readme"
|
|
38
|
+
"homepage": "https://github.com/niceguyspl/app-rainman-engine#readme",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/niceguyspl/app-rainman-engine.git"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"keywords": [
|
|
48
|
+
"pixi"
|
|
49
|
+
]
|
|
48
50
|
}
|