Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mr BigSock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gard Aleksander Furre
Mr BigSock
Commits
23e10ab5
Commit
23e10ab5
authored
2 years ago
by
Robin Halseth Sandvik
Browse files
Options
Downloads
Patches
Plain Diff
Added skill points on level up.
- Also added debug constants to control leveling speed.
parent
a0cfb748
No related branches found
Branches containing commit
No related tags found
1 merge request
!60
Upgrades people.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MrBigsock/Assets/Code/PlayerController.cs
+21
-6
21 additions, 6 deletions
MrBigsock/Assets/Code/PlayerController.cs
with
21 additions
and
6 deletions
MrBigsock/Assets/Code/PlayerController.cs
+
21
−
6
View file @
23e10ab5
...
...
@@ -16,6 +16,11 @@ namespace BigSock {
public
partial
class
PlayerController
:
Character
{
public
const
int
SKILL_POINTS_PR_LVL
=
3
;
// Skill points to gain pr level up.
public
const
int
SKILL_POINTS_START
=
5
;
// Skill points to start with.
public
const
float
XP_SCALE_RATE
=
3.0f
;
// Multiplier for xp gain, helps test system while game is tiny.
public
UtilBar
utilBar
;
...
...
@@ -280,21 +285,31 @@ namespace BigSock {
utilBar
?.
WithHealth
(
Convert
.
ToInt32
(
HP
));
}
public
void
GainXp
(
float
xp
){
GiveXp
(
xp
);
public
void
GainXp
(
float
xp
)
{
GiveXp
(
xp
*
XP_SCALE_RATE
);
CheckXp
();
utilBar
?.
WithXP
((
int
)
this
.
xp
);
}
private
void
CheckXp
(){
if
(
xp
>
maxXp
){
/*
Checks for, and handles, level-ups.
*/
private
void
CheckXp
()
{
// If the character has leveled up.
if
(
xp
>
maxXp
)
{
level
+=
1
;
xp
-=
maxXp
;
maxXp
=
(
level
+
1
)
*
100
;
utilBar
?.
WithXP
(
maxValue
:
(
int
)
maxXp
);
SkillPoints
+=
SKILL_POINTS_PR_LVL
;
}
/*
To-do:
- Maybe not flat skill points pr level.
- Scale differently. (Separate function for getting xp requirement pr level)
*/
}
}
...
...
@@ -308,7 +323,7 @@ namespace BigSock {
/*
The number of skill points the user has at their disposal.
*/
public
int
SkillPoints
{
get
;
set
;
}
public
int
SkillPoints
{
get
;
set
;
}
=
SKILL_POINTS_START
;
/*
The amount of points the user has currently spent on each skill.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment