コード例 #1
0
 public void TestConsume <T> (ConsumeItem <T> cons) where T : ItemGroup
 {
     cons.onComplete += (PerformerTask task) => Debug.Log("Consume Item test succeeded :)");
     PerformableTasks.Add(cons);
     cons.Start();
     if (!cons.Performing)
     {
         Debug.Log("Consume Item test failed because the task did not start");
     }
 }
コード例 #2
0
        void Awake()
        {
            Inventory = Player.Instance.Inventory;

            PerformableTasks.Add(new GenerateLaborer()).onComplete += OnGenerateLaborer;
            // PerformableTasks.Add (new GenerateUnit<Elder> ()).onComplete += OnGenerateElder;
            // PerformableTasks.Add (new GenerateUnit<Corpse> ()).onComplete += OnGenerateCorpse;
            // PerformableTasks.Add (new BorrowLoan<MilkshakeLoanGroup> ());
            // PerformableTasks.Add (new BorrowLoan<CoffeeLoanGroup> ());
        }
コード例 #3
0
 public void TestGenerate <T> (GenerateItem <T> gen) where T : ItemGroup
 {
     gen.onComplete += (PerformerTask task) => Debug.Log("Generate Item test succeeded :)");
     PerformableTasks.Add(gen);
     gen.Start();
     if (!gen.Performing)
     {
         Debug.Log("Generate Item test failed because the task did not start");
     }
 }
コード例 #4
0
 protected override void OnInitPerformableTasks(PerformableTasks p)
 {
     p.Add(new CollectItem <MilkshakeGroup> ());
     p.Add(new DeliverItem <MilkshakeGroup> ());
     p.Add(new CollectItem <CoffeeGroup> ());
     p.Add(new DeliverItem <CoffeeGroup> ());
     p.Add(new GenerateItem <YearGroup> ());
     p.Add(new CollectItem <LaborGroup> ()).onEnd += (PerformerTask t) => { Inventory["Labor"].Clear(); };
     p.Add(new CollectItem <HappinessGroup> ());
     p.Add(new ConsumeItem <HappinessGroup> ());
 }
コード例 #5
0
        protected void OnInitPerformableTasks(PerformableTasks p)
        {
            // p.Add (new ResearchUpgrade<CoffeeCapacity> ());
            // p.Add (new ResearchUpgrade<MilkshakeCapacity> ());
            p.Add(new ResearchUpgrade <LaborerSpeed> ());
            p.Add(new ResearchUnit <Apartment> ());
            p.Add(new ResearchUnit <CollectionCenter> ());
            p.Add(new UpgradeLevee());
            p.Add(new ResearchUpgrade <Eyesight> ());

            foreach (var task in PerformableTasks.ActiveTasks)
            {
                task.Value.onStart    += OnStartUpgrade;
                task.Value.onComplete += OnCompleteUpgrade;
            }
        }
コード例 #6
0
    void OnContentUpdated()
    {
        // Overview
        title.text       = content.Title;
        description.text = content.Description;

        // Tasks
        performableTasks = content.PerformableTasks;
        ClearTasks();
        InitTasks();

        // Inventory
        inventory           = content.Inventory;
        inventory.onUpdate += OnInventoryUpdated;
        OnInventoryUpdated();

        Canvas.enabled = true;
    }
コード例 #7
0
    void Set()
    {
        title       = unit.Name;
        description = unit.Description;
        inventory   = unit.Inventory;
        ITaskPerformer performer = unit as ITaskPerformer;

        if (performer != null)
        {
            PerformableTasks = performer.PerformableTasks;
        }
        else
        {
            PerformableTasks = null;
        }
        if (contentUpdated != null)
        {
            contentUpdated();
        }
    }
コード例 #8
0
    public void TestCollect <T> (CollectItem <T> collect, AcceptCollectItem <T> acceptCollect) where T : ItemGroup
    {
        T group = Inventory.Get <T> ();

        group.Clear();
        PerformableTasks.Add(collect);

        // Make sure task doesn't start if the acceptor's inventory is empty
        taskAcceptor.ClearGroup <T> ();
        collect.Start(acceptCollect);
        if (collect.Performing)
        {
            Debug.Log("Collect Item test failed because the task started but acceptor's inventory is empty");
            return;
        }

        taskAcceptor.FillGroup <T> ();
        collect.onComplete += (PerformerTask task) => {
            taskAcceptor.FillGroup <T> ();
            collect.Start(acceptCollect);

            // Make sure the task doesn't start if the performer's inventory is full
            if (collect.Performing)
            {
                Debug.Log("Collect Item test failed because the task started but performer's inventory is full");
            }
            else
            {
                Debug.Log("Collect Item test succeeded :)");
            }
        };

        collect.Start(acceptCollect);
        if (!collect.Performing)
        {
            Debug.Log("Collect Item test failed because the task did not start");
        }
    }
コード例 #9
0
    public void TestDeliver <T> (DeliverItem <T> deliver, AcceptDeliverItem <T> acceptDeliver) where T : ItemGroup
    {
        T group = Inventory.Get <T> ();

        group.Set(5);
        PerformableTasks.Add(deliver);

        // Make sure the task doesn't start if the acceptor's inventory is full
        taskAcceptor.FillGroup <T> ();
        deliver.Start(acceptDeliver);
        if (deliver.Performing)
        {
            Debug.Log("Deliver Item test failed because the task started but acceptor's inventory is full");
            return;
        }

        taskAcceptor.ClearGroup <T> ();
        deliver.onComplete += (PerformerTask task) => {
            taskAcceptor.ClearGroup <T> ();
            deliver.Start(acceptDeliver);

            // Make sure the task doesn't start if the performer's inventory is empty
            if (deliver.Performing)
            {
                Debug.Log("Deliver Item test failed bacause the task started but performer's inventory is empty");
            }
            else
            {
                Debug.Log("Deliver Item test succeeded :)");
            }
        };

        deliver.Start(acceptDeliver);
        if (!deliver.Performing)
        {
            Debug.Log("Deliver Item test failed because the task did not start");
        }
    }
コード例 #10
0
    public void TestAutoStart(PerformerTask autoStart)
    {
        PerformableTasks.Add(autoStart);

        if (!autoStart.Settings.AutoStart)
        {
            throw new System.Exception("The task '" + autoStart.GetType() + "' will not auto start because its data model has AutoStart set to false");
        }

        if (autoStart.Settings.Duration == 0)
        {
            throw new System.Exception("The test '" + autoStart.GetType() + "' will fail because its duratio is 0. Set it to something above 0");
        }

        if (autoStart.Performing)
        {
            Debug.Log("Auto Start test succeeded :)");
        }
        else
        {
            Debug.Log("Auto Start test failed :(");
        }
    }
コード例 #11
0
    public void TestRepeat(PerformerTask repeat)
    {
        PerformableTasks.Add(repeat);
        repeat.onEnd += (PerformerTask task) => {
            Co2.WaitForFixedUpdate(() => {
                if (repeat.Performing)
                {
                    Debug.Log("Repeat test succeeded :)");
                }
                else
                {
                    Debug.Log("Repeat test failed :(");
                }
                repeat.Stop();
            });
        };

        if (!repeat.Settings.Repeat)
        {
            throw new System.Exception("The task '" + repeat.GetType() + "' will not repeat because its data model has Repeat set to false");
        }

        repeat.Start();
    }
コード例 #12
0
 protected void OnInitPerformableTasks(PerformableTasks p)
 {
     p.Add(new DemolishUnit(Container));
 }
コード例 #13
0
 public void TestGenerateUnit <T> (GenerateUnit <T> gen) where T : Unit
 {
     PerformableTasks.Add(gen);
     gen.Start();
 }
コード例 #14
0
 protected void OnInitPerformableTasks(PerformableTasks p)
 {
     p.Add(new GenerateItem <HealthGroup> ());
 }
コード例 #15
0
 protected virtual void OnInitPerformableTasks(PerformableTasks p)
 {
 }