Commit 99feb492 by Alisa Jung

added fire

playerHealth now in float
parent f5910d4e
fileFormatVersion: 2
guid: 240246b882bcdcb4291fbf51a895c7cd
timeCreated: 1433456019
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class FireScript : MonoBehaviour {
PlayerHealth parentHealth;
public float constantDamagepoints = 0.1f;
public float burningTime = 10;
// Use this for initialization
void Start () {
Invoke("stopBurning", burningTime);
}
// Update is called once per frame
void Update () {
if (parentHealth != null)
{
parentHealth.changeHealthBy(-constantDamagepoints);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
parentHealth = other.GetComponent<PlayerHealth>();
transform.position = other.transform.position; //hier schon position setzen
transform.parent = other.transform;
}
}
void stopBurning()
{
Destroy(gameObject);
}
}
fileFormatVersion: 2
guid: f90cdea2ef1f0de4e9180888a148db55
timeCreated: 1433454876
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -4,9 +4,9 @@ using UnityEngine.UI; ...@@ -4,9 +4,9 @@ using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour { public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100; public float maxHealth = 100;
public int currentHealth = 100; public float currentHealth = 100;
private bool alive = true; private bool alive = true;
public Scrollbar healthbar; public Scrollbar healthbar;
...@@ -19,7 +19,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -19,7 +19,7 @@ public class PlayerHealth : MonoBehaviour {
} }
} }
public int getCurrentHealth() public float getCurrentHealth()
{ {
return currentHealth; return currentHealth;
} }
...@@ -28,7 +28,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -28,7 +28,7 @@ public class PlayerHealth : MonoBehaviour {
/// Setzt Gesundheit auf bestimmten Wert, aber nicht mehr als maxHealth von dem Player. /// Setzt Gesundheit auf bestimmten Wert, aber nicht mehr als maxHealth von dem Player.
/// </summary> /// </summary>
/// <param name="newHealth"></param> /// <param name="newHealth"></param>
public void setHealth(int newHealth) public void setHealth(float newHealth)
{ {
currentHealth = (newHealth > maxHealth) ? maxHealth : newHealth; currentHealth = (newHealth > maxHealth) ? maxHealth : newHealth;
updateHealthbar(); updateHealthbar();
...@@ -39,7 +39,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -39,7 +39,7 @@ public class PlayerHealth : MonoBehaviour {
{ {
if (healthbar) if (healthbar)
{ {
healthbar.size = (float)currentHealth / (float)maxHealth; healthbar.size = currentHealth / maxHealth;
} }
} }
...@@ -47,7 +47,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -47,7 +47,7 @@ public class PlayerHealth : MonoBehaviour {
/// Erhöht bzw. erniedrigt aktuelle Gesundheit um Wert h, Gesundheit kann nicht höher werden als maxHealth. /// Erhöht bzw. erniedrigt aktuelle Gesundheit um Wert h, Gesundheit kann nicht höher werden als maxHealth.
/// </summary> /// </summary>
/// <param name="h"></param> /// <param name="h"></param>
public void changeHealthBy(int h) public void changeHealthBy(float h)
{ {
currentHealth += h; currentHealth += h;
if (currentHealth > maxHealth) currentHealth = maxHealth; if (currentHealth > maxHealth) currentHealth = maxHealth;
......
fileFormatVersion: 2
guid: 0e484eb550cb05b409551de82ff6dc26
timeCreated: 1433454718
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment