Hello there,
I am fairly new to C# and after watching a ton of raw theory tutorials, I tried to make my own Player script, which includes some statistics and a bunch of other experimental stuff
I also tried to give it a Job (didn’t want to call it a class so I don’t get confused with the c# “class”), like we find in tons of games. So I created a Job script
Right now the way it’s working is i’m putting the job script as a component in an empty GameObject, fill in the stats, make it a prefab and drag/drop it into my player Script
While this is really handy for prototyping/playtesting purpose, it think (correct me if im wrong) that it would be very clumsy for an finished game.
So I tried to use Constructors, and the concept of classes and objects to create Jobs but I can’t see how to approach the problem…
How do I create Jobs from my Job script, store them and reference them, to use them in a still-to-be-built ChangeJob() function for example ?
This is a big question for me since it would also solve the inventory problem at the same time
Sorry if the post sounds messy, i’m still having trouble linking theory, proper vocabulary and practice !
Thanks in advance
Here 's the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Job : Player {
public string job_Name;
public int job_iD;
int tier;
public string job_Description;
public Skill[] job_Skills;
public int healthmodifier;
int moralemodifier;
int energymodifier;
int painmodifier;
Player player;
public Job (){
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
string name;
int iD;
public int health = 100;
public int pain;
public int moral;
public int energy;
public int Armor;
public int Resistance;
public Job job;
public Item[] Inventory;
public Item[] Stock;
public Item[] Equipment;
public Skill[] Skills;
Player.job
void Start () {
// Debug.Log ("Health is" + health);
// health = health + job.healthmodifier;
// Debug.Log ("Health is" + health);
// Debug.Log (job.name);
}
}