Am Trying to Learn C# do to it’s more used with other gaming engines. So am trying to Convert my Java to C# if anyone could help me with this would be grateful. trying to get this three scripts to talk to each other.
using UnityEngine;
using System.Collections;
public class EnemyDamage : MonoBehaviour
{
void OnCollisionStay ( Collision hit )
{
if(hit.gameObject.tag == "EnemyDamage")
{
GUIHealth.HITS -= 1;
}
}
}
using UnityEngine;
using System.Collections;
public class PlayerFallout : MonoBehaviour {
static int dead= false;
void OnTriggerEnter ( Collider hit ){
if(hit.gameObject.tag == "Fallout")
{
dead = true;
}
}
void LateUpdate (){
if(dead)
{
GUIHealth.HITS = 500;
Application.LoadLevel (Application.loadedLevelName);
dead = false;
}
}
}
using UnityEngine;
using System.Collections;
public class GUIHealth : MonoBehaviour {
Texture2D Health00;
Texture2D Health10;
Texture2D Health20;
Texture2D Health30;
Texture2D Health40;
Texture2D Health50;
Texture2D Health60;
Texture2D Health70;
Texture2D Health80;
Texture2D Health90;
Texture2D Health100;
static FIXME_VAR_TYPE HITS= 500;
void Update ()
{
print("Hits: "+HITS);
FIXME_VAR_TYPE heathtexture= gameObject.Find("Health100");
if (HITS < 500)
{
guiTexture.texture = Health90;
}
if (HITS < 450)
{
guiTexture.texture = Health80;
}
if (HITS < 400)
{
guiTexture.texture = Health70;
}
if (HITS < 350)
{
guiTexture.texture = Health60;
}
if (HITS < 300)
{
guiTexture.texture = Health50;
}
if (HITS < 250)
{
guiTexture.texture = Health40;
}
if (HITS < 200)
{
guiTexture.texture = Health30;
}
if (HITS < 150)
{
guiTexture.texture = Health20;
}
if (HITS < 100)
{
guiTexture.texture = Health10;
}
if (HITS < 50)
{
PlayerFallout.dead = true;
GUIHealth.HITS = 500;
}
}
void gotHit (){
HITS -=1;
}
}
Thank you for your time.