示例#1
0
        public JobQualifications(PlayerChar owner, JobQualifications copyFrom)
            : this(owner)
        {
            MoveToPos_MaxDist.Value = copyFrom.MoveToPos_MaxDist;

            AcceptJob_Mining.Value = copyFrom.AcceptJob_Mining;
            AcceptJob_Build.Value  = copyFrom.AcceptJob_Build;

            SleepWhen_EnergyBelow.Value = copyFrom.SleepWhen_EnergyBelow;
            SleepWhen_HealthBelow.Value = copyFrom.SleepWhen_HealthBelow;

            GrowingUpIsEmergency.Value = copyFrom.GrowingUpIsEmergency;

            AvoidEnemiesWhenPathing.Value = copyFrom.AvoidEnemiesWhenPathing;
        }
示例#2
0
        public PlayerChar(Map theMap, ulong groupID, float food, float energy, float strength,
                          float adultMultiplier, string name, Player_Char.Personality.Genders gender)
            : base(theMap, groupID)
        {
            Food     = new Stat <float, PlayerChar>(this, food);
            Strength = new Stat <float, PlayerChar>(this, strength);

            Energy            = new Stat <float, PlayerChar>(this, energy);
            Energy.OnChanged += (thisChar, oldVal, newVal) =>
            {
                float max = Player_Char.Consts.MaxEnergy(Strength);
                if (newVal > max)
                {
                    Energy.Value = max;
                }
            };

            Health            = new Stat <float, PlayerChar>(this, Player_Char.Consts.Max_Health);
            Health.OnChanged += (thisChar, oldVal, newVal) =>
            {
                if (newVal > Player_Char.Consts.Max_Health)
                {
                    Health.Value = Player_Char.Consts.Max_Health;
                }
            };

            AdultMultiplier = new Stat <float, PlayerChar>(this, adultMultiplier);

            LowFoodThreshold =
                new Stat <float, PlayerChar>(this, Player_Char.Consts.InitialLowFoodThreshold);

            Career      = new Player_Char.JobQualifications(this);
            Personality = new Player_Char.Personality(this, name, gender);

            //When this Unit gets killed,
            //    make sure all callbacks for its remaining custom jobs get called.
            OnKilled += (_this, _theMap) => RemoveAllJobs();
        }