Question by
AzureBoers · Apr 11, 2018 at 02:22 AM ·
scripting beginnerrpgrpg-game
Help with Player RPG Attack!
I'm trying to get my currentattack int to work with my Strength int so when they attack they add up right but I keep getting one and when you level up it does'ent add Up right! Here are the scripts
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerStats : MonoBehaviour {
/* public int currentLevel;
public int currentEXP;
public int[] tolevelUP;
public int[] hpLevels;
public int[] attackLevels;
public int[] defenceLevels;*/
public int currentLevel;
public int baseExp = 20;
public int currentExp;
public int expForNextLevel;
public int expDiffenceToNextLevel;
public int totalExpDifference;
public float fillAmount;
public float reverseFillAmount;
public int statPoints;
public int skillPoints;
private int addDef;
public int addStr;
private int addHP;
public int currentHP;
public int currentAttack;
public int currentDefence;
public static string PlayerName { get; set; }
public static int PlayerLevel { get; set; }
public static BaseStatsClass PlayerClass { get; set; }
public static int Strength { get; set; }
public static int Wisdom { get; set; }
public static int Defence { get; set; }
public static int HitPoints { get; set; }
private PlayerHealthManager thePlayerhealth;
#region Singleton
public static PlayerStats instance;
void Awake()
{
DontDestroyOnLoad(this.gameObject);
if (instance != null)
{
Debug.LogWarning("Instacne of inventroy found bad!");
return;
}
instance = this;
}
#endregion
// Use this for initialization
void Start () {
Defence = currentDefence;
HitPoints = currentHP;
currentAttack = Strength;
/*currentHP = hpLevels[1];
currentDefence = defenceLevels[1];*/
thePlayerhealth = FindObjectOfType<PlayerHealthManager>();
}
// Update is called once per frame
void Update () {
/*if(currentEXP >= tolevelUP[currentLevel])
{
LevelUP();
}*/
Debug.Log(Strength);
Debug.Log("CA :" + currentAttack);
}
public void Heal(int healthGain) { currentHP += healthGain; }
public void CalculateLevel(int amount)
{
currentExp += amount;
int temp_cur_level = (int)Mathf.Sqrt(currentExp / baseExp) + 1;
if (currentLevel != temp_cur_level)
{
currentLevel = temp_cur_level;
}
expForNextLevel = baseExp * currentLevel * currentLevel;
expDiffenceToNextLevel = expForNextLevel - currentExp;
totalExpDifference = expForNextLevel - (baseExp * (currentLevel - 1) * (currentLevel - 1));
fillAmount = (float)expDiffenceToNextLevel / (float)totalExpDifference;
reverseFillAmount = 1 - fillAmount;
statPoints = 5 * (currentLevel - 1);
skillPoints = 15 * (currentLevel - 1);
if (currentExp >= totalExpDifference)
{
Levelup();
}
}
public void Levelup()
{
addDef = Defence + (int)Random.Range(1f, 10f);
addStr = (int)Random.Range(1f, 10f);
Debug.Log(Strength);
addHP = PlayerStats.HitPoints + (int)Random.Range(1f, 10f);
}
/*public void AddExperience(int experienceToAdd)
{
currentEXP += experienceToAdd;
}
public void LevelUP()
{
currentLevel++;
currentHP = hpLevels[currentLevel];
thePlayerhealth.playerMaxHealth = currentHP;
thePlayerhealth.playerCurrentHealth += currentHP - hpLevels[currentLevel - 1];
// currentAttack = attackLevels[currentLevel];
currentDefence = defenceLevels[currentLevel];*/
}
Comment