- Home /
Help Randomizing attributes for a novice level game
So I'm making an beginner level RPG game and i need help randomizing attributes for the start of the game. I'm fairly new so I'm sure i got this completely wrong but i did my best with the knowledge i have at hand. This is what i have so far.
using UnityEngine;
using System.Collections;
public class Randomizer : MonoBehaviour {
public float TotalAttributePoints = 20f;
private float SecondTotal;
private float ThirdTotal;
private float FourthTotal;
private float FifthTotal;
private float FirstAttributePoints;
private float SecondAttributePoints;
private float ThirdAttributePoints;
private float FourthAttributePoints;
private float FifthAttributePoints;
// Use this for initialization
void Start () {
AttributeRandomzer ();
Debug.Log ("Attributes");
Debug.Log ("Strength:" + FirstAttributePoints);
Debug.Log ("Perception:" + SecondAttributePoints);
Debug.Log ("Intelligence:" + ThirdAttributePoints);
Debug.Log ("Charisma:" + FourthAttributePoints);
Debug.Log ("Luck:" + FifthAttributePoints);
}
// Update is called once per frame
void AttributeRandomzer () {
FirstAttributePoints = Random.Range (0, TotalAttributePoints);
SecondTotal = (TotalAttributePoints - FirstAttributePoints);
SecondAttributePoints = Random.Range (0, SecondTotal);
ThirdTotal = (SecondTotal - SecondAttributePoints);
ThirdAttributePoints = Random.Range (0, ThirdTotal);
FourthTotal = (ThirdTotal - ThirdAttributePoints);
FourthAttributePoints = Random.Range (0, FourthTotal);
FifthTotal = (FourthTotal - FourthAttributePoints);
FifthAttributePoints = Random.Range (0, FifthTotal);
}
}
All help and tips are appreciated.
Comment