Gruppe22.Backend.Actor.Actor C# (CSharp) Метод

Actor() публичный Метод

The constructor used for actors. Sets default values for the most important properties.
public Actor ( ActorType actorType, int health, int armor, int damage, int maxHealth = -1, string name = "", Random rnd = null, string animationFile = "", int level = -1 ) : System
actorType ActorType Player, NPC oder Enemy
health int Standardwert 15+random(30) or 5+random(maxhealth-5) if maxhealth is passed
armor int default random(10)
damage int default 12+random(10)
maxHealth int default = health
name string uses GenerateName() by default
rnd System.Random a random used to generate the actors starting values
animationFile string the file used to display the actor
level int the default starting level is 1
Результат System
        public Actor(ActorType actorType, int health, int armor, int damage, int maxHealth = -1, string name = "", Random rnd = null, string animationFile = "", int level = -1)
        {
            _actorType = actorType;
            _abilities = new List<Ability>();
            _quicklist = new List<int>(10);
            for (int i = 0; i < 10; ++i)
            {
                _quicklist.Add(0);
            }

            if (rnd == null) _random = new Random(); else _random = rnd;

            if (level < 0)
            {
                _level = 0;
                for (int counter = level; counter < 0; counter += 1)
                {
                    _exp = 3 * (_level) ^ 2 + 83 * (_level) + 41;

                    LevelUp();
                }
            }
            else
            {
                _level = level;
                _expNeeded = 3 * (_level + 1) ^ 2 + 83 * (_level + 1) + 41;

            }

            if (health < 0)
            {
                if (maxHealth > 0)
                {
                    health = 5 + _random.Next(maxHealth - 5);
                }
                else
                {
                    health = 15 + _random.Next(30);
                }
            }
            this._health = health;

            if (maxHealth == -1)
            {
                _maxhealth = health;
            }

            if (armor < 0)
            {
                armor = _random.Next(10);
                fireDefense = _random.Next(10);
                iceDefense = _random.Next(10);
            }
            this._armor = armor;

            if (damage < 0)
            {
                damage = 12 + _random.Next(10);
            }
            this._damage = damage;

            if (name.Trim() == "") GenerateName();
            else _name = name;

            this._inventory = new List<Item>();
            _animationFile = animationFile;
        }