Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Spieleentwicklung
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Adrian Paschkowski
Spieleentwicklung
Commits
1aca14bc
Verified
Commit
1aca14bc
authored
3 years ago
by
Adrian Paschkowski
Browse files
Options
Downloads
Patches
Plain Diff
Reset Mana on round loss
parent
594d4e3f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Assets/Scripts/StatsManager.cs
+22
-1
22 additions, 1 deletion
Assets/Scripts/StatsManager.cs
Assets/Scripts/Store/EnemySpawnController.cs
+1
-1
1 addition, 1 deletion
Assets/Scripts/Store/EnemySpawnController.cs
with
23 additions
and
2 deletions
Assets/Scripts/StatsManager.cs
+
22
−
1
View file @
1aca14bc
...
...
@@ -50,12 +50,13 @@ public interface IManaChangeCallback
void
OnManaChanged
(
int
oldValue
,
int
newValue
);
}
public
class
StatsManager
:
MonoBehaviour
public
class
StatsManager
:
MonoBehaviour
,
IRoundCallback
{
public
static
StatsManager
instance
{
get
;
private
set
;
}
[
SerializeField
]
int
currentMana
;
int
manaAtRoundStart
;
[
SerializeField
,
Tooltip
(
"When the AntiPlayer receives damage, how much of that damage is converted to Mana"
)]
float
antiPlayerDamageManaMultiplier
=
100f
;
[
SerializeField
,
Tooltip
(
"When the AntiPlayer dies, how much mana to give"
)]
...
...
@@ -186,4 +187,24 @@ public class StatsManager : MonoBehaviour
armorMultiplier
=
1f
,
});
}
void
Start
()
{
RoundController
.
instance
.
roundCallbacks
.
Add
(
this
);
}
public
void
OnRoundStart
()
{
manaAtRoundStart
=
currentMana
;
}
public
void
OnRoundEnd
(
bool
won
)
{
if
(!
won
)
{
// Reset current Mana back to start value if round was lost
var
gainedMana
=
currentMana
-
manaAtRoundStart
;
ModifyMana
(-
gainedMana
);
}
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/Store/EnemySpawnController.cs
+
1
−
1
View file @
1aca14bc
...
...
@@ -69,9 +69,9 @@ public class EnemySpawnController : MonoBehaviour
public
void
OnEnemyMouseDown
(
string
enemyName
)
{
SetEnemyToSpawnObject
(
enemyName
);
if
(!
RoundController
.
instance
.
roundRunning
&&
StatsManager
.
instance
.
ModifyMana
(-
1
*
(
int
)
activeSpawn
.
enemyCost
))
{
SetEnemyToSpawnObject
(
enemyName
);
dragObject
.
GetComponent
<
Image
>().
sprite
=
activeSpawn
.
EnemySprite
;
enemyImage
=
Instantiate
(
dragObject
,
GetPreviewWorldPosition
(),
Quaternion
.
identity
,
transform
);
}
...
...
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