Пример #1
0
    public override void FixedUpdate()
    {
        base.FixedUpdate();

        if (this.isBusy())
        {
            if (counter % 180 == 0 && !this.GetComponent <inventory>().isFull())
            {
                RessourceHelper.deliverTo(this.gameObject, false, ressources.Trees);
            }
            //check if it has scrap, if true then recycle INFO: 1 Scrap = 3 Energy
            if (this.GetComponent <inventory>().getAmount(ressources.Trees) >= 1 && this.getCurEnergy() > 3)
            {
                this.addEnergy(-energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().add(new ressourceStack(WoodPerSecond * Time.deltaTime, ressources.Wood));
                this.GetComponent <inventory>().remove(new ressourceStack(treesPerSecond * Time.deltaTime, ressources.Trees));
            }

            if (this.GetComponent <inventory>().getAmount(ressources.Trees) >= 1 && this.getCurEnergy() > 3)
            {
                this.GetComponent <Animator>().SetBool("working", true);
                if (!this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().isPlaying)
                {
                    this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().Play();
                }
            }
            else
            {
                this.GetComponent <Animator>().SetBool("working", false);
                this.transform.Find("CFX3_Fire_Shield").GetComponent <ParticleSystem>().Stop();
            }
        }
    }
Пример #2
0
    public override void FixedUpdate()
    {
        base.FixedUpdate();

        if (this.isBusy())
        {
            //ProcessingPlant_Anim
            if (this.getCurEnergy() > 3)
            {
                //request both ores
                if (counter % 180 == 0 && !this.GetComponent <inventory>().isFull())
                {
                    RessourceHelper.deliverTo(this.gameObject, false, ressources.OreIron);
                    RessourceHelper.deliverTo(this.gameObject, false, ressources.OreGold);
                }

                //select right ore
                var ore = ressources.OreIron;
                if (this.GetComponent <inventory>().getAmount(ressources.OreIron) < 0.2f)
                {
                    ore = ressources.OreGold;
                    if (this.GetComponent <inventory>().getAmount(ressources.OreGold) < 0.2f)
                    {
                        this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Stop();
                        return;
                    }
                }


                if (!this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().isPlaying)
                {
                    this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Play();
                }

                this.addEnergy(-energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().remove(new ressourceStack(OrePerSecond * Time.deltaTime, ore));

                var ingot = ore.Equals(ressources.OreIron) ? ressources.Iron : ressources.Gold;
                this.GetComponent <inventory>().add(new ressourceStack(IngotsPerSecond * Time.deltaTime, ingot));
            }
            else
            {
                this.transform.Find("ProcessingPlant_Anim").GetComponent <ParticleSystem>().Stop();
            }
        }
    }
Пример #3
0
    new void FixedUpdate()
    {
        base.FixedUpdate();

        if (workLight == null)
        {
            workLight = this.transform.Find("DrillSparks").transform.Find("Point Light").gameObject;
        }

        if (counter % 5 == 0)
        {
            handleConnections();
        }

        if (this.isBusy())
        {
            //check if it has scrap, if true then recycle INFO: 1 Scrap = 3 Energy
            if (this.GetComponent <inventory>().getAmount(ressources.Scrap) >= 1)
            {
                this.addEnergy(energyPerSecond * Time.deltaTime, this);
                this.GetComponent <inventory>().remove(new ressourceStack(scrapPerSecond * Time.deltaTime, ressources.Scrap));
            }

            if (this.GetComponent <inventory>().getAmount(ressources.Scrap) >= 1)
            {
                this.GetComponent <Animator>().SetBool("working", true);
                workLight.GetComponent <Light>().enabled = true;
                this.transform.Find("DrillSparks").GetComponent <ParticleSystem>().Play();
            }
            else
            {
                this.GetComponent <Animator>().SetBool("working", false);
                workLight.GetComponent <Light>().enabled = false;
                this.transform.Find("DrillSparks").GetComponent <ParticleSystem>().Stop();
            }
            //send for moar scrap!!
            if (counter % 60 == 0 && !this.GetComponent <inventory>().isFull())
            {
                RessourceHelper.deliverTo(this.gameObject, false, ressources.Scrap);
            }
        }
    }
Пример #4
0
    private new void FixedUpdate()
    {
        base.FixedUpdate();

        if (!busy)
        {
            return;
        }

        //request resources
        if (useMovers)
        {
            foreach (var data in getProduceData())
            {
                foreach (var kind in data.consume)
                {
                    if (counter % 180 == 0 && this.inventory.getFillPercent() < 0.9f)
                    {
                        RessourceHelper.deliverTo(this.gameObject, false, kind.getRessource());
                    }
                }
            }
        }

        //consume goods
        var dataList = this.getProduceData();
        var workDone = false;

        foreach (var data in dataList)
        {
            if (handleProduceData(data))
            {
                workDone = true;
            }
        }

        if (hasAnimation)
        {
            animator.SetBool(Work, workDone);
        }
    }
Пример #5
0
    void FixedUpdate()
    {
        counter++;
        if (!active)
        {
            return;
        }

        var   inv       = this.gameObject.GetComponent <inventory>();
        float availUran = inv.getAmount(ressources.Uranium);

        if (!inv.isFull() && counter % 60 == 0)
        {
            RessourceHelper.deliverTo(this.gameObject, false, ressources.Uranium);
        }

        //update heat items
        foreach (var item in allStructures)
        {
            item.update(availUran);
        }
    }
Пример #6
0
    /// <summary>
    /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
    /// </summary>
    new void FixedUpdate()
    {
        base.FixedUpdate();
        if (this.salvaging && this.getHP().HP < 3)
        {
            print("structure salvaged!");
            var pickup = Instantiate(GameObject.Find("Terrain").GetComponent <Scene_Controller>().pickupBox,
                                     this.transform.position, Quaternion.identity);
            pickup.GetComponent <inventory>().add(new ressourceStack(this.getHP().getInitialHP(), ressources.Scrap));
            GameObject.Destroy(this.gameObject);
        }

        if (salvaging)
        {
            this.getHP().HP -= 2.5f;
            return;
        }

        if (steamAmount > 10)
        {
            this.addEnergy(10 * Time.deltaTime, this);
            steamAmount -= 10 * Time.deltaTime;
            this.getInv().add(ressources.Water, -10f * Time.deltaTime);
        }

        if ((this.getInv().getAmount(ressources.Water) < 50 || this.steamAmount > 10) && counter % 60 == 0 &&
            !this.GetComponent <inventory>().isFull())
        {
            RessourceHelper.deliverTo(this.gameObject, false, ressources.Water);
        }

        if (counter % 5 == 0)
        {
            handleConnections();
        }
    }