Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dyingIsMainstream
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gamejam-gpn15
dyingIsMainstream
Commits
72cfff97
Commit
72cfff97
authored
Jun 04, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added playerHealth
parent
4739840b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
PlayerHealth.cs
Assets/Scripts/PlayerHealth.cs
+44
-0
PlayerHealth.cs.meta
Assets/Scripts/PlayerHealth.cs.meta
+12
-0
No files found.
Assets/Scripts/PlayerHealth.cs
0 → 100644
View file @
72cfff97
using
UnityEngine
;
using
System.Collections
;
public
class
PlayerHealth
:
MonoBehaviour
{
public
int
maxHealth
=
100
;
public
int
currentHealth
=
100
;
private
bool
alive
=
true
;
// Update is called once per frame
void
Update
()
{
if
(
alive
&&
currentHealth
<=
0
)
{
Debug
.
Log
(
"Player "
+
name
+
" dead."
);
}
}
public
int
getCurrentHealth
()
{
return
currentHealth
;
}
/// <summary>
/// Setzt Gesundheit auf bestimmten Wert, aber nicht mehr als maxHealth von dem Player.
/// </summary>
/// <param name="newHealth"></param>
public
void
setHealth
(
int
newHealth
)
{
currentHealth
=
(
newHealth
>
maxHealth
)
?
maxHealth
:
newHealth
;
}
/// <summary>
/// Erhöht bzw. erniedrigt aktuelle Gesundheit um Wert h, Gesundheit kann nicht höher werden als maxHealth.
/// </summary>
/// <param name="h"></param>
public
void
changeHealthBy
(
int
h
)
{
currentHealth
+=
h
;
if
(
currentHealth
>
maxHealth
)
currentHealth
=
maxHealth
;
}
}
Assets/Scripts/PlayerHealth.cs.meta
0 → 100644
View file @
72cfff97
fileFormatVersion: 2
guid: 64eedc6579a413545b11c63c47c39d53
timeCreated: 1433439187
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment