@rpg-engine/long-bow 0.1.68 → 0.1.69

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.
@@ -9,6 +9,8 @@ interface IProps {
9
9
  width?: number;
10
10
  height?: number;
11
11
  scale?: number;
12
+ grayScale?: boolean;
13
+ opacity?: number;
12
14
  }
13
15
 
14
16
  export const SpriteFromAtlas: React.FC<IProps> = ({
@@ -18,6 +20,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
18
20
  width = GRID_WIDTH,
19
21
  height = GRID_HEIGHT,
20
22
  scale = 2,
23
+ grayScale = false,
24
+ opacity = 1,
21
25
  }) => {
22
26
  //! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
23
27
  //!Due to React's limitations, we cannot import it from the public folder directly!
@@ -31,6 +35,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
31
35
  atlasIMG={atlasIMG}
32
36
  frame={spriteData.frame}
33
37
  scale={scale}
38
+ grayScale={grayScale}
39
+ opacity={opacity}
34
40
  />
35
41
  </Container>
36
42
  );
@@ -45,6 +51,8 @@ interface IImgSpriteProps {
45
51
  h: number;
46
52
  };
47
53
  scale: number;
54
+ grayScale: boolean;
55
+ opacity: number;
48
56
  }
49
57
 
50
58
  interface IContainerProps {
@@ -66,4 +74,6 @@ const ImgSprite = styled.div<IImgSpriteProps>`
66
74
  position: relative;
67
75
  top: 8px;
68
76
  left: 8px;
77
+ filter: ${props => (props.grayScale ? 'grayscale(100%)' : 'none')};
78
+ opacity: ${props => props.opacity};
69
79
  `;
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- interface IProps {
4
+ export interface ISimpleProgressBarProps {
5
5
  value: number;
6
- height?: string;
7
6
  bgColor?: string;
7
+ margin?: number;
8
8
  }
9
9
 
10
- export const SimpleProgressBar: React.FC<IProps> = ({
10
+ export const SimpleProgressBar: React.FC<ISimpleProgressBarProps> = ({
11
11
  value,
12
-
13
12
  bgColor = 'red',
13
+ margin = 20,
14
14
  }) => {
15
15
  return (
16
- <Container>
17
- <ProgressBarContainer>
16
+ <Container className="simple-progress-bar">
17
+ <ProgressBarContainer margin={margin}>
18
18
  <BackgroundBar>
19
19
  <Progress value={value} bgColor={bgColor} />
20
20
  </BackgroundBar>
@@ -34,16 +34,20 @@ const BackgroundBar = styled.span`
34
34
  background-color: rgba(0, 0, 0, 0.075);
35
35
  `;
36
36
 
37
- interface IProgressProps {
37
+ interface ISimpleProgressBarThemeProps {
38
38
  value: number;
39
39
  bgColor: string;
40
40
  }
41
41
 
42
42
  const Progress = styled.span`
43
- background-color: ${(props: IProgressProps) => props.bgColor};
44
- width: ${(props: IProgressProps) => props.value}%;
43
+ background-color: ${(props: ISimpleProgressBarThemeProps) => props.bgColor};
44
+ width: ${(props: ISimpleProgressBarThemeProps) => props.value}%;
45
45
  `;
46
46
 
47
+ interface ISimpleProgressBarTheme2Props {
48
+ margin: number;
49
+ }
50
+
47
51
  const ProgressBarContainer = styled.div`
48
52
  border-radius: 60px;
49
53
  border: 1px solid #282424;
@@ -53,6 +57,6 @@ const ProgressBarContainer = styled.div`
53
57
  display: block;
54
58
  height: 100%;
55
59
  }
56
-
57
60
  height: 8px;
61
+ margin-left: ${(props: ISimpleProgressBarTheme2Props) => props.margin}px;
58
62
  `;
@@ -1,42 +1,99 @@
1
+ import { getSPForLevel } from '@rpg-engine/shared';
1
2
  import React from 'react';
2
3
  import styled from 'styled-components';
3
- import imgSrcTemplate from './imgExp.png';
4
+ import atlasJSON from '../mocks/atlas/items/items.json';
5
+ import atlasIMG from '../mocks/atlas/items/items.png';
6
+ import { SpriteFromAtlas } from './Item/SpriteFromAtlas';
4
7
  import { SimpleProgressBar } from './SimpleProgressBar';
5
8
 
6
9
  export interface ISkillProgressBarProps {
7
- value: number;
8
-
9
- height: string;
10
+ skillName: string;
10
11
  bgColor: string;
11
- titleName: string;
12
-
13
- logoSrc?: string;
12
+ level: number;
13
+ skillPoints: number;
14
+ skillPointsToNextLevel?: number;
15
+ texturePath: string;
16
+ showSkillPoints?: boolean;
14
17
  }
15
18
 
16
19
  export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
17
- value,
18
20
  bgColor,
19
- titleName,
20
-
21
- logoSrc = imgSrcTemplate,
21
+ skillName,
22
+ level,
23
+ skillPoints,
24
+ texturePath,
25
+ showSkillPoints = true,
22
26
  }) => {
27
+ const spForNextLevel = getSPForLevel(level + 1);
28
+
29
+ const ratio = (skillPoints / spForNextLevel) * 100;
30
+
23
31
  return (
24
32
  <>
25
33
  <ProgressTitle>
26
- <TitleName>{titleName}</TitleName>
27
- <ValueDisplay>{value}</ValueDisplay>
34
+ <TitleName>{skillName}</TitleName>
35
+ <ValueDisplay>lv {level}</ValueDisplay>
28
36
  </ProgressTitle>
29
37
  <ProgressBody>
30
38
  <ProgressIconContainer>
31
- <Icon src={logoSrc} />
39
+ {atlasIMG && atlasJSON ? (
40
+ <SpriteContainer>
41
+ <SpriteFromAtlas
42
+ atlasIMG={atlasIMG}
43
+ atlasJSON={atlasJSON}
44
+ spriteKey={texturePath}
45
+ scale={1}
46
+ grayScale
47
+ opacity={0.5}
48
+ />
49
+ </SpriteContainer>
50
+ ) : (
51
+ <></>
52
+ )}
32
53
  </ProgressIconContainer>
33
54
 
34
- <SimpleProgressBar value={value} bgColor={bgColor} />
55
+ <ProgressBarContainer>
56
+ <SimpleProgressBar value={ratio} bgColor={bgColor} />
57
+ </ProgressBarContainer>
35
58
  </ProgressBody>
59
+ {showSkillPoints && (
60
+ <SkillDisplayContainer>
61
+ <SkillPointsDisplay>
62
+ {skillPoints}/{spForNextLevel}
63
+ </SkillPointsDisplay>
64
+ </SkillDisplayContainer>
65
+ )}
36
66
  </>
37
67
  );
38
68
  };
39
69
 
70
+ const ProgressBarContainer = styled.div`
71
+ position: relative;
72
+ top: 8px;
73
+ width: 100%;
74
+ height: auto;
75
+ `;
76
+
77
+ const SpriteContainer = styled.div`
78
+ position: relative;
79
+ top: -3px;
80
+ left: 0;
81
+ `;
82
+
83
+ const SkillDisplayContainer = styled.div`
84
+ margin: 5px auto;
85
+
86
+ p {
87
+ margin: 0;
88
+ }
89
+ `;
90
+
91
+ const SkillPointsDisplay = styled.p`
92
+ font-size: 0.6rem !important;
93
+ font-weight: bold;
94
+ text-align: center;
95
+ `;
96
+
40
97
  const TitleName = styled.span`
41
98
  margin-left: 5px;
42
99
  `;
@@ -52,6 +109,7 @@ const ProgressIconContainer = styled.div`
52
109
  const ProgressBody = styled.div`
53
110
  display: flex;
54
111
  flex-direction: row;
112
+ width: 100%;
55
113
  `;
56
114
 
57
115
  const ProgressTitle = styled.div`
@@ -62,9 +120,5 @@ const ProgressTitle = styled.div`
62
120
  span {
63
121
  font-size: 0.6rem;
64
122
  }
65
- `;
66
-
67
- const Icon = styled.img`
68
- margin-right: 10px;
69
- height: 30px;
123
+ margin-top: 10px;
70
124
  `;
@@ -0,0 +1,235 @@
1
+ import { ISkill } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { colors } from '../constants/uiColors';
5
+ import { DraggableContainer } from './DraggableContainer';
6
+ import { SkillProgressBar } from './SkillProgressBar';
7
+
8
+ export interface ISkillContainerProps {
9
+ skill: ISkill;
10
+ onCloseButton: () => void;
11
+ }
12
+
13
+ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
14
+ onCloseButton,
15
+ skill,
16
+ }) => {
17
+ return (
18
+ <SkillsDraggableContainer title="Skills" onCloseButton={onCloseButton}>
19
+ <SkillSplitDiv>
20
+ <p>Combat Skills</p>
21
+ <hr className="golden" />
22
+ </SkillSplitDiv>
23
+ <SkillProgressBar
24
+ skillName={'First'}
25
+ bgColor={colors.cardinal}
26
+ level={skill?.first?.level || 0}
27
+ skillPoints={skill?.first?.skillPoints || 0}
28
+ skillPointsToNextLevel={skill?.first?.skillPointsToNextLevel || 0}
29
+ texturePath={'gloves/leather-gloves.png'}
30
+ />
31
+ <SkillProgressBar
32
+ skillName={'Club'}
33
+ bgColor={colors.cardinal}
34
+ level={skill?.club?.level || 0}
35
+ skillPoints={skill?.club?.skillPoints || 0}
36
+ skillPointsToNextLevel={skill?.club?.skillPointsToNextLevel || 0}
37
+ texturePath={'maces/club.png'}
38
+ />
39
+ <SkillProgressBar
40
+ skillName={'Sword'}
41
+ bgColor={colors.cardinal}
42
+ level={skill?.sword?.level || 0}
43
+ skillPoints={skill?.sword?.skillPoints || 0}
44
+ skillPointsToNextLevel={skill?.sword?.skillPointsToNextLevel || 0}
45
+ texturePath={'swords/double-edged-sword.png'}
46
+ />
47
+ <SkillProgressBar
48
+ skillName={'Axe'}
49
+ bgColor={colors.cardinal}
50
+ level={skill?.axe?.level || 0}
51
+ skillPoints={skill?.axe?.skillPoints || 0}
52
+ skillPointsToNextLevel={skill?.axe?.skillPointsToNextLevel || 0}
53
+ texturePath={'axes/double-axe.png'}
54
+ />
55
+ <SkillProgressBar
56
+ skillName={'Distance'}
57
+ bgColor={colors.cardinal}
58
+ level={skill?.distance?.level || 0}
59
+ skillPoints={skill?.distance?.skillPoints || 0}
60
+ skillPointsToNextLevel={skill?.distance?.skillPointsToNextLevel || 0}
61
+ texturePath={'bows/horse-bow.png'}
62
+ />
63
+ <SkillProgressBar
64
+ skillName={'Shielding'}
65
+ bgColor={colors.cardinal}
66
+ level={skill?.shielding?.level || 0}
67
+ skillPoints={skill?.shielding?.skillPoints || 0}
68
+ skillPointsToNextLevel={skill?.shielding?.skillPointsToNextLevel || 0}
69
+ texturePath={'shields/studded-shield.png'}
70
+ />
71
+ <SkillSplitDiv>
72
+ <p>Crafting Skills</p>
73
+ <hr className="golden" />
74
+ </SkillSplitDiv>
75
+ <SkillProgressBar
76
+ skillName={'Fishing'}
77
+ bgColor={colors.blue}
78
+ level={skill?.fishing?.level || 0}
79
+ skillPoints={skill?.fishing?.skillPoints || 0}
80
+ skillPointsToNextLevel={skill?.fishing?.skillPointsToNextLevel || 0}
81
+ texturePath={'foods/fish.png'}
82
+ />
83
+ <SkillProgressBar
84
+ skillName={'Mining'}
85
+ bgColor={colors.blue}
86
+ level={skill?.mining?.level || 0}
87
+ skillPoints={skill?.mining?.skillPoints || 0}
88
+ skillPointsToNextLevel={skill?.mining?.skillPointsToNextLevel || 0}
89
+ texturePath={'crafting-resources/iron-ingot.png'}
90
+ />
91
+ <SkillProgressBar
92
+ skillName={'Lumberjacking'}
93
+ bgColor={colors.blue}
94
+ level={skill?.lumberjacking?.level || 0}
95
+ skillPoints={skill?.lumberjacking?.skillPoints || 0}
96
+ skillPointsToNextLevel={
97
+ skill?.lumberjacking?.skillPointsToNextLevel || 0
98
+ }
99
+ texturePath={'crafting-resources/greater-wood-log.png'}
100
+ />
101
+ <SkillProgressBar
102
+ skillName={'Cooking'}
103
+ bgColor={colors.blue}
104
+ level={skill?.cooking?.level || 0}
105
+ skillPoints={skill?.cooking?.skillPoints || 0}
106
+ skillPointsToNextLevel={skill?.cooking?.skillPointsToNextLevel || 0}
107
+ texturePath={'foods/chickens-meat.png'}
108
+ />
109
+ <SkillProgressBar
110
+ skillName={'Alchemy'}
111
+ bgColor={colors.blue}
112
+ level={skill?.alchemy?.level || 0}
113
+ skillPoints={skill?.alchemy?.skillPoints || 0}
114
+ skillPointsToNextLevel={skill?.alchemy?.skillPointsToNextLevel || 0}
115
+ texturePath={'potions/greater-mana-potion.png'}
116
+ />
117
+
118
+ <SkillSplitDiv>
119
+ <p>Basic Attributes</p>
120
+ <hr className="golden" />
121
+ </SkillSplitDiv>
122
+ <SkillProgressBar
123
+ skillName={'Stamina'}
124
+ bgColor={colors.darkYellow}
125
+ level={skill?.stamina?.level || 0}
126
+ skillPoints={skill?.stamina?.skillPoints || 0}
127
+ skillPointsToNextLevel={skill?.stamina?.skillPointsToNextLevel || 0}
128
+ texturePath={'spell-icons/regenerate.png'}
129
+ />
130
+ <SkillProgressBar
131
+ skillName={'Magic'}
132
+ bgColor={colors.purple}
133
+ level={skill?.magic?.level || 0}
134
+ skillPoints={skill?.magic?.skillPoints || 0}
135
+ skillPointsToNextLevel={skill?.magic?.skillPointsToNextLevel || 0}
136
+ texturePath={'spell-icons/fireball.png'}
137
+ />
138
+ <SkillProgressBar
139
+ skillName={'Magic Resistance'}
140
+ bgColor={colors.navyBlue}
141
+ level={skill?.magicResistance?.level || 0}
142
+ skillPoints={skill?.magicResistance?.skillPoints || 0}
143
+ skillPointsToNextLevel={
144
+ skill?.magicResistance?.skillPointsToNextLevel || 0
145
+ }
146
+ texturePath={'spell-icons/freeze.png'}
147
+ />
148
+ <SkillProgressBar
149
+ skillName={'Strength'}
150
+ bgColor={colors.cardinal}
151
+ level={skill?.strength?.level || 0}
152
+ skillPoints={skill?.strength?.skillPoints || 0}
153
+ skillPointsToNextLevel={skill?.strength?.skillPointsToNextLevel || 0}
154
+ texturePath={'spell-icons/enchanted-blow.png'}
155
+ />
156
+ <SkillProgressBar
157
+ skillName={'Resistance'}
158
+ bgColor={colors.raisinBlack}
159
+ level={skill?.resistance?.level || 0}
160
+ skillPoints={skill?.resistance?.skillPoints || 0}
161
+ skillPointsToNextLevel={skill?.resistance?.skillPointsToNextLevel || 0}
162
+ texturePath={'spell-icons/magic-shield.png'}
163
+ />
164
+ <SkillProgressBar
165
+ skillName={'Dexterity'}
166
+ bgColor={colors.blue}
167
+ level={skill?.dexterity?.level || 0}
168
+ skillPoints={skill?.dexterity?.skillPoints || 0}
169
+ skillPointsToNextLevel={skill?.dexterity?.skillPointsToNextLevel || 0}
170
+ texturePath={'spell-icons/haste.png'}
171
+ />
172
+
173
+ {/* <SkillSplitDiv>
174
+ <p>Magic Skills</p>
175
+ <hr className="golden" />
176
+ </SkillSplitDiv>
177
+ <SkillProgressBar
178
+ skillName={'Ice'}
179
+ bgColor={'red'}
180
+ level={skill?.ice?.level || 0}
181
+ skillPoints={skill?.ice?.skillPoints || 0}
182
+ skillPointsToNextLevel={skill?.ice?.skillPointsToNextLevel || 0}
183
+ texturePath={'spell-icons/freeze.png'}
184
+ />
185
+ <SkillProgressBar
186
+ skillName={'Earth'}
187
+ bgColor={'red'}
188
+ level={skill?.earth?.level || 0}
189
+ skillPoints={skill?.earth?.skillPoints || 0}
190
+ skillPointsToNextLevel={skill?.earth?.skillPointsToNextLevel || 0}
191
+ texturePath={'spell-icons/earth-barrier.png'}
192
+ />
193
+ <SkillProgressBar
194
+ skillName={'Air'}
195
+ bgColor={'red'}
196
+ level={skill?.air?.level || 0}
197
+ skillPoints={skill?.air?.skillPoints || 0}
198
+ skillPointsToNextLevel={skill?.air?.skillPointsToNextLevel || 0}
199
+ texturePath={'spell-icons/poison-tornado.png'}
200
+ />
201
+ <SkillProgressBar
202
+ skillName={'Water'}
203
+ bgColor={'red'}
204
+ level={skill?.water?.level || 0}
205
+ skillPoints={skill?.water?.skillPoints || 0}
206
+ skillPointsToNextLevel={skill?.water?.skillPointsToNextLevel || 0}
207
+ texturePath={'spell-icons/tsunami.png'}
208
+ /> */}
209
+ </SkillsDraggableContainer>
210
+ );
211
+ };
212
+
213
+ const SkillsDraggableContainer = styled(DraggableContainer)`
214
+ border: 1px solid black;
215
+ width: 400px;
216
+ height: 800px;
217
+ overflow-y: scroll;
218
+ .DraggableContainer__TitleContainer-sc-184mpyl-2 {
219
+ width: auto;
220
+ height: auto;
221
+ }
222
+ `;
223
+
224
+ const SkillSplitDiv = styled.div`
225
+ width: 100%;
226
+ font-size: 11px;
227
+ margin-top: 10px;
228
+ hr {
229
+ margin: 0px;
230
+ padding: 0px;
231
+ }
232
+ p {
233
+ margin-bottom: 0px;
234
+ }
235
+ `;
@@ -1,3 +1,10 @@
1
1
  export const colors = {
2
2
  darkGrey: '#3e3e3e',
3
+ darkYellow: '#FFC857',
4
+ orange: '#E9724C',
5
+ cardinal: '#C5283D',
6
+ raisinBlack: '#191923',
7
+ navyBlue: '#0E79B2',
8
+ purple: '#8C3D8C',
9
+ blue: '#3772FF',
3
10
  };