示例#1
0
        public TamagotchiRule(Tamagotchi tama, Rule rule)
            : this()
        {
#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            Tamagotchi = tama;
            Rule       = rule;
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor
        }
示例#2
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            var timeSpan = now - tama.LastAllRulesPassedUtc;

            if (timeSpan >= oneHour)
            {
                tama.Boredom += DeltaBoredom * (int)timeSpan.TotalHours;
                return(true);
            }

            return(false);
        }
示例#3
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Sleep == SleepThreshold && !tama.IsAthletic)
            {
                tama.HasDied = true;
            }
            else
            {
                tama.HasDied = false;
            }

            return(true);
        }
示例#4
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Health < HealthThreshold)
            {
                tama.IsAthletic = true;
            }
            else
            {
                tama.IsAthletic = false;
            }

            return(true);
        }
示例#5
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Boredom > 80)
            {
                tama.HasMunchies = true;
            }
            else
            {
                tama.HasMunchies = false;
            }

            return(true);
        }
示例#6
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            var timeSpan = now - tama.LastAllRulesPassedUtc;

            if (timeSpan >= oneHour)
            {
                int delta = DeltaHunger;

                if (tama.HasMunchies)
                {
                    delta *= 2;
                }

                tama.Hunger += delta * (int)timeSpan.TotalHours;

                return(true);
            }

            return(false);
        }
示例#7
0
文件: Rule.cs 项目: Netvon/Tamagotchi
 public virtual void Deactivate(Tamagotchi tama) /* do nothing */ }
示例#8
0
文件: Rule.cs 项目: Netvon/Tamagotchi
 /// <summary>
 /// Apply this Rule to a Tamagotchi
 /// </summary>
 public abstract bool Execute(Tamagotchi tama, DateTime now);
示例#9
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsAthletic = false;
 }
示例#10
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.HasMunchies = false;
 }
示例#11
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsCrazy = false;
 }