I am working on a small card game style project. I have a custom class for the cards. The code is:
using UnityEngine;
using System.Collections;
public enum SpeciesType{
Human,
Orc,
Elf,
Alien,
Monster,
Loner
};
[System.Serializable]
public class Card{
public SpeciesType species;
public string cardName;
public int health;
public int armour;
public int attack;
public int intelligence;
public int stamina;
public Card(SpeciesType spec, string name, int hp, int arm, int at, int intel, int stam){
species = spec;
cardName = name;
health = hp;
armour = arm;
attack = at;
intelligence = intel;
stamina = stam;
}
}
My question is can I assign a specific card element into a general variable I can access via scripts?
Can i do something like this:
general variable = cards health;
if(player card general variable > AI card general variable){
the player wins
}
My game works so whoever has the higher number in the specific variable, in this example health, then they win and the defeated card goes to the dead pile.
The idea being that, if i choose attack, then I can assign the general variable to attack, without having to do multiple If statements for each class int. This is my first time using a custom class. Sorry if itâs hard to understand, itâs weird to explain. I dont know if this even a thing