-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExperience.cs
More file actions
44 lines (40 loc) · 975 Bytes
/
Experience.cs
File metadata and controls
44 lines (40 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using UnityEngine;
using System.Collections;
public class Experience : MonoBehaviour
{
//current level
public int vLevel = 1;
//current exp amount
public int vCurrExp = 0;
//exp amount needed for lvl 1
public int vExpBase = 10;
//exp amount left to next levelup
public int vExpLeft = 10;
//modifier that increases needed exp each level
public float vExpMod = 1.15f;
//vvvvvv USED FOR TESTING FEEL FREE TO DELETE
void Update ()
{
if (Input.GetButtonDown("Jump"))
{
GainExp(1);
}
}
//^^^^^^ USED FOR TESTING FEEL FREE TO DELETE
//leveling methods
public void GainExp(int e)
{
vCurrExp += e;
if(vCurrExp >= vExpLeft)
{
LvlUp();
}
}
void LvlUp()
{
vCurrExp -= vExpLeft;
vLevel++;
float t = Mathf.Pow(vExpMod, vLevel);
vExpLeft = (int)Mathf.Floor(vExpBase * t);
}
}