Ejemplo n.º 1
0
        static public IEnumerator UnitTest(Utility.Scheduler scheduler)
        {
            List <Base> stackers = new List <Base>();

            stackers.Add(new NoRefresh(() => 3, () => 0.5, scheduler));
            stackers.Add(new Refresh(() => 3, () => 0.5, scheduler));
            stackers.Add(new Independent(() => 3, () => 0.5, scheduler));
            stackers.Add(new Cumulative(() => 3, () => 0.5, scheduler));
            stackers.Add(new Permanent(() => 3));

            foreach (var stacker in stackers)
            {
                stacker.Changed += (Evolution evolution) => { Debug.Log($"{stacker.GetType().Name} Evolution {evolution.ToString()} with {stacker.Duration(scheduler).ToString("F1")}s left at {scheduler.Now.ToString("F1")}s"); };
                for (int i = 0; i < 100; ++i)
                {
                    if (UnityEngine.Random.value < 0.35)
                    {
                        uint amount = 1 + Convert.ToUInt32(UnityEngine.Random.value * 2);
                        Debug.Log($"{stacker.GetType().Name} Add {amount} to {stacker.ToString()}");
                        stacker.Add(amount);
                    }
                    else if (UnityEngine.Random.value < 0.50)
                    {
                        uint amount = 1 + Convert.ToUInt32(UnityEngine.Random.value * 2);
                        Debug.Log($"{stacker.GetType().Name} Remove {amount} to {stacker.ToString()}");
                        stacker.Remove(amount);
                    }
                    yield return(scheduler.Wait(0.1));
                }
            }
        }
Ejemplo n.º 2
0
        // Use this for initialization
        IEnumerator Start()
        {
            Debug.Assert(debugButtonPrefab != null);
            Debug.Assert(horizontalLayout != null);
            scheduler = new Utility.Scheduler(this);

            yield return(StartCoroutine(App.Content.Session.Load()));

            AddButton("Update skills", SkillUpdate);
            AddButton("Test stackers", StackerUnitTest);
        }
Ejemplo n.º 3
0
 public Refresh(MaxAmountDelegate maxStack_, DurationDelegate duration_, Utility.Scheduler scheduler_)
 {
     maxAmount = maxStack_;
     duration  = duration_;
     scheduler = scheduler_;
 }
Ejemplo n.º 4
0
 public Cumulative(MaxAmountDelegate maxAmount_, DurationDelegate duration_, Utility.Scheduler scheduler_)
 {
     maxAmount = maxAmount_;
     duration  = duration_;
     scheduler = scheduler_;
 }
Ejemplo n.º 5
0
 public Independent(MaxAmountDelegate maxAmount_, DurationDelegate duration_, Utility.Scheduler scheduler_)
 {
     maxAmount = maxAmount_;
     duration  = duration_;
     scheduler = scheduler_;
 }
Ejemplo n.º 6
0
 public double Duration(Utility.Scheduler scheduler)
 {
     return(Amount() > 0 ? Expiration() - scheduler.Now : 0);
 }