I'm not able to access the CharacterBase
class of my Script PlayerBehavior
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TypeCharacter{
Priest = 0,
Mage = 1,
Paladin = 2,
Warrior = 3,
Archer = 4,
Newbie = 5
}
public enum PlayerStates
{
Movement
}
public class PlayerBehavior : CharacterBase
{
private TypeCharacter type;
private AnimationController animationController;
/* State Machine*/
private PlayerStates currentState = PlayerStates.Movement;
//
//*Movimentation*//
private float speed;
public float speedRun;
public float runStaminaCost;
public float speedDodge;
public float dodgeStaminaCost;
public float timeRecoverDodge;
private float currentTimeStaminaRecoverDodge;
public float speedWalk;
public float rotateSpeed;
private float horizontal;
private float vertical;
private CharacterController controller;
private float currentStamina;
private float maxStamina;
public float staminaRecover;
//*Attack*//
private int currentAttack = 0;
public float attackRate;
private float currentAttackRate;
private float rangeAttack;
public int totalAttackAnimations;
//* *//
//UI
public UIController UI;
new protected void Start () {
base.Start ();
PlayerStatsController.SetTypeCharacter (TypeCharacter.Newbie);
currentLevel = PlayerStatsController.GetCurrentLevel();
type = PlayerStatsController.GetTypeCharacter();
basicStats = PlayerStatsController.instance.GetBasicStats(type);
animationController = GetComponent<AnimationController>();
speed = speedWalk;
controller = GetComponent<CharacterController> ();
currentAttack = basicStats.baseAttack;
base.Start();
maxStamina = basicStats.baseStamina * basicStats.agillity;
currentStamina = maxStamina;
}
new void Update()
{
base.Update();
if (Input.GetKeyDown(KeyCode.T))
{
currentLife -= Random.Range(1, 30);
}
UI.SetLife(basicStats.startLife, currentLife);
}
void Update () {
switch (currentState) {
case PlayerStates.Movement:
vertical = Input.GetAxis ("Vertical");
horizontal = Input.GetAxis ("Horizontal");
if(Input.GetKey (KeyCode.LeftShift) && vertical != 0) {speed = speedRun;
animationController.PlayAnimation (AnimationStates.RUN);}
else { speed = speedWalk;
if (vertical != 0)
animationController.PlayAnimation (AnimationStates.WALK);}
controller = GetComponent<CharacterController>();
transform.Rotate(0, horizontal * rotateSpeed, 0);
Vector3 forward = transform.TransformDirection(Vector3.forward);
float curSpeed = speed * vertical;
controller.SimpleMove(forward * curSpeed);
/*Attack */
if (Input.GetButtonDown("Fire1"))
{
Attack (); }
currentAttackRate += Time.deltaTime;
break;
}
}
private void Attack()
{
if (currentAttackRate >= attackRate) {
currentAttackRate = 0;
animationController.CallAttackAnimation (currentAttack);
currentAttack++;
if (currentAttack > totalAttackAnimations) {
currentAttack = 0;
}
}
Ray rayAttack = new Ray (transform.position, transform.forward);
RaycastHit hitinfo = new RaycastHit ();
rangeAttack = basicStats.baseRange;
if (Physics.Raycast (rayAttack, out hitinfo, rangeAttack)) {
if (hitinfo.collider.GetComponent<DestructiveBase> () != null) {
if (hitinfo.collider != GetComponent<Collider> ()) {
hitinfo.collider.GetComponent<DestructiveBase> ().ApplyDamage (currentAttack);
}
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
//Basics Atribuits//
public class BasicStats{
public BasicStats baseInfo;
public float startLife;
public float startMana;
public int strenght; /*STR*/
public int intelligence; /*INT*/
public int agillity; /*DEX*/
public int concentration; /*CON*/
public int baseDefense;
public int baseAttack;
public float baseRange;
public float baseStamina;
}
public abstract class CharacterBase : DestructiveBase
{
public int currentLevel;
public BasicStats basicStats;
// Use this for initialization
protected void Start () {
currentLife = basicStats.startLife;
}
// Update is called once per frame
protected void Update()
{
}
}