using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CW_Project2
{
abstract class Character
{
int HP;
int SP;
int EP;
int Attack;
int Defense;
int Endurance;
int Speed;
int Affinity;
public Character()
{
Attack = 5;
Defense = 5;
Endurance = 5;
Speed = 5;
Affinity = 0;
setBasePoints();
}
public Character(int initialAttack, int initialDefense, int initialEndurance, int initialSpeed, int initialAffinity)
{
Attack = initialAttack;
Defense = initialDefense;
Endurance = initialEndurance;
Speed = initialSpeed;
Affinity = initialAffinity;
setBasePoints();
}
public Character(Attributes loadAttributes, int loadHP, int loadSP, int loadEP)
{
Attack = loadAttributes.Attack;
Defense = loadAttributes.Defense;
Endurance = loadAttributes.Endurance;
Speed = loadAttributes.Speed;
Affinity = loadAttributes.Affinity;
HP = loadHP;
SP = loadSP;
EP = loadEP;
}
private void setBasePoints()
{
Random rnd = new Random();
HP = (((Defense + Endurance) * 10) / 8);
SP = (((Attack + Endurance) * 10) / 7);
EP = (((rnd.Next(10) + Endurance) * 10) / 6);
}
pu
}
}
And a Player class that inherits Character:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CW_Project2
{
class Player : Character
{
long playerID;
CharacterClass playerClass;
public Player()
{
}
public Player(int playerAttack, int playerDefense, int playerEndurance, int playerSpeed, int playerAffinity)
: base(playerAttack, playerDefense, playerEndurance, playerSpeed, playerAffinity)
{
}
public Player(CharacterClass initialClass, int bonusAttack, int bonusDefense, int bonusEndurance, int bonusSpeed, int bonusAffinity)
: this(initialClass.getClassAttributes().Attack + bonusAttack,
initialClass.getClassAttributes().Defense + bonusDefense,
initialClass.getClassAttributes().Endurance + bonusEndurance,
initialClass.getClassAttributes().Speed + bonusSpeed,
initialClass.getClassAttributes().Affinity + bonusAffinity)
{
playerClass = initialClass;
playerID = DateTime.Now.Ticks;
}
}
}
Now if I want the Player class to access the Characters class private fields, should I just make the fields Protected or create Public Properties? Basically the scenario that I am thinking of is when the Player levels up, I'll need to add points to those attributes.