Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class BaseHero
{
    

    public string name;  // name of Unit_Hero

    // Unit Stats

    public float MaxHP;
    public float currentHP;

    public float MaxMP;
    public float currentMP;

    public float MaxAP;
    public float currentAP;

    public int Vit;
    public int Str;
    public int Int;
    public int Dex;
    public int Mnd;

    public int Speed;
    
    public int CastingSpeed;

   
}


C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeroStateMachine : MonoBehaviour
{

    public BaseHero Hero;

    BaseHero()
    {
        this.Speed = 0;
        return this.Speed;
    }
    
    


    public enum TurnState
    {
        PROCESSING,
        ADDTOLIST,
        WAITING,
        SELECTING,
        ACTION,
        DEAD
    }

    public TurnState CurrentState;
    
    //Used for CT 
    private float current_CT = 0f;
    private float Max_CT = 100f;
    
   

    // Start is called before the first frame update
    void Start()
    {
        CurrentState = TurnState.PROCESSING;
    }

    // Update is called once per frame
    void Update()
    {
        switch(CurrentState)
        {
            case (TurnState.PROCESSING):
                CTCounter();

                break;

            case (TurnState.ADDTOLIST):

                break;

            case (TurnState.WAITING):

                break;

            case (TurnState.SELECTING):

                break;

            case (TurnState.ACTION):

                break;

            case (TurnState.DEAD):

                break;

        }
    }

    void CTCounter() //Turn count to 100 like FFT
    {
        current_CT = current_CT + Speed;

        float calc_CT = current_CT / Max_CT;

        if(current_CT >= Max_CT)
        {
            CurrentState = TurnState.ADDTOLIST;
        }
    }
}




I am trying use a public int from one class to preform a calculation on the Statemachine but I am having issues for it to see the same int of Speed.

What I have tried:

Tried to create in instances and classs to pull from .this to try to pull the what I need.
Posted
Updated 26-Apr-22 14:13pm
v2

1 solution

The problem, is that you don't seem to understand how classes and their members work.
Have a look here: Ma'am / sir how would you transfer a value from one function of a class to another function of another class ?[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900