-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathSymbol.svelte
More file actions
55 lines (51 loc) · 1.36 KB
/
Symbol.svelte
File metadata and controls
55 lines (51 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script lang="ts">
import SymbolSpine from './SymbolSpine.svelte';
import SymbolSprite from './SymbolSprite.svelte';
import { getSymbolInfo } from '../game/utils';
import type { SymbolState, RawSymbol } from '../game/types';
import { getContext } from '../game/context';
import { BitmapText } from 'pixi-svelte';
type Props = {
x?: number;
y?: number;
state: SymbolState;
rawSymbol: RawSymbol;
oncomplete?: () => void;
loop?: boolean;
};
const props: Props = $props();
const context = getContext();
const symbolInfo = $derived(getSymbolInfo({ rawSymbol: props.rawSymbol, state: props.state }));
const isSprite = $derived(symbolInfo.type === 'sprite');
</script>
{#if isSprite}
<SymbolSprite {symbolInfo} x={props.x} y={props.y} oncomplete={props.oncomplete} />
{:else}
<SymbolSpine
loop={props.loop}
{symbolInfo}
x={props.x}
y={props.y}
showWinFrame={props.state === 'win' && !['S', 'M'].includes(props.rawSymbol.name)}
listener={{
complete: props.oncomplete,
event: (_, event) => {
if (event.data?.name === 'wildExplode') {
context.eventEmitter?.broadcast({ type: 'soundOnce', name: 'sfx_wild_explode' });
}
},
}}
/>
{/if}
{#if props.rawSymbol.multiplier}
<BitmapText
anchor={0.5}
x={props.x}
y={props.y}
text={`${props.rawSymbol.multiplier}X`}
style={{
fontFamily: 'gold',
fontSize: 50,
}}
/>
{/if}