Here are my scripts, I’m trying to write a skillpoint selection for me and my friends game, he doesn’t understand scripting at all that’s why it’s retardedly commented. Anyway, I’m trying to get it to set the health to the players Stamina times 10, but it returns 0.
Here are my two scripts
Health.cs (Simple AI downloaded, edited the code)
using UnityEngine;
using System.Collections;
public class Health : MonoBehaviour {
public float MaxHealth;
public float CurrentHealth;
public bool Invincible;
public bool Dead;
LevelUp levels = new LevelUp();
// Use this for initialization
void Start () {
//MAKE THE CURRENT HEALTH THE MAX HEALTH AT START
MaxHealth = levels.stamina * 10;
CurrentHealth=MaxHealth;
}
void LevelUp() {
MaxHealth = levels.stamina * 10;
CurrentHealth = MaxHealth;
}
// Update is called once per frame
void Update () {
//IF INVINCIBLE, HE CANNOT DIE..
if(Invincible){
CurrentHealth=MaxHealth;
}
else{
if(CurrentHealth<=0){
CurrentHealth=0;
Dead=true;
}
//MAX HEALTH
if(CurrentHealth>=MaxHealth)CurrentHealth=MaxHealth;
//WHEN DEATH IS UPON HIM
if(Dead){
//TELL THE AI SCRIPT HE IS DEAD
FreeAI AI=(FreeAI)GetComponent("FreeAI");
if(AI){
if(AI.IsDead){}
else AI.IsDead=true;
}
}
}
}
}
and here is the LevelUp.cs for stat handling and experience.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class LevelUp : MonoBehaviour {
/**
*
* int = Integer, A variable for a number without a decimal point.
* bool = Boolean, A variable that returns true or false.
* float = Integer, A variable for a number WITH Decimal Points.
* char = Character, A variable for a single character, I.E 'A' 'B' 'C'
* string = Group of characters, for sentences such at "Hello, JewFace"
*
**/
//I don't understand this either;'
public static LevelUp instance;
//Current Experience.
public int currExperience,
expToLevel, //Experience needed to level.
playerLevel; // Players Level
// Stat Points
public int strength, //Melee Damage
stamina, // Health Stat
agility, // Movement Agility, Archer Damage
dexterity, // CritRating - Acurracy.
intelligence; // Mana Scaling.
//This is called before script initialization.
void Awake() {
}
// Use this for initialization
void Start () {
instance = this;
strength = 10;
stamina = 10;
agility = 10;
dexterity = 10;
intelligence = 10;
currExperience = 0;
expToLevel = 100;
playerLevel = 1;
}
// Update is called once per frame
void Update () {
// Leveling up, if current experience is greater or equal to the required value, add experience to required level up value.
if(currExperience >= expToLevel) {
playerLevel += 1;
expToLevel = expToLevel + (int)(expToLevel * 1.1);
}
}
// Handles all GUI based functions, what's beign displayed.
void OnGUI() {
GUI.Box (new Rect(Screen.width / 2, Screen.height - 120, 260, 260), "");
}
}