Esempio n. 1
0
    public void Tick()
    {
        var constructorObjects = GameObject.FindGameObjectsWithTag("Constructor");

        foreach (var constructorObject in constructorObjects)
        {
            if (ResourceConsumer.isFunctioning(constructorObject))
            {
                var constructorStorage = constructorObject.GetComponent <ResourceStorage>();
                resources[ResourceType.Materials] += constructorStorage.resources[ResourceType.Materials];
            }
        }

        resources[ResourceType.People] = 0;
        foreach (var houseObject in GameObject.FindGameObjectsWithTag("House"))
        {
            if (ResourceConsumer.isFunctioning(houseObject))
            {
                var houseStorage = houseObject.GetComponent <ResourceStorage>();
                resources[ResourceType.People] += houseStorage.resources[ResourceType.People];
            }
        }

        if (resources[ResourceType.People] > goalQuantity)
        {
            win();
        }
    }
Esempio n. 2
0
    public override void flowFrom(ResourceType resourceType, float quantity, int sourceFlowIteration)
    {
        if (filterList.Contains(resourceType))
        {
            return;
        }
        storage.resources[resourceType] += quantity;

        if (!ResourceConsumer.isFunctioning(gameObject))
        {
            return;
        }
    }
Esempio n. 3
0
    public override void flowFrom(ResourceType resourceType, float quantity, int sourceFlowIteration)
    {
        if (sourceFlowIteration <= flowIteration)
        {
            return;
        }
        flowIteration = sourceFlowIteration;

        storage.resources[resourceType] += quantity;
        var falloff      = resourceFalloff[resourceType];
        var nextQuantity = quantity * falloff;

        if (!ResourceConsumer.isFunctioning(gameObject))
        {
            return;
        }

        foreach (var conduit in Placeable.FindConnectedTo <ResourceReceiver>(GetComponent <Placeable>()))
        {
            conduit.flowFrom(resourceType, nextQuantity, flowIteration);
        }
    }
    public void Tick()
    {
        if (!ResourceConsumer.isFunctioning(gameObject))
        {
            return;
        }

        var storage   = GetComponent <ResourceStorage>();
        var placeable = GetComponent <Placeable>();

        foreach (var pair in resourceGeneration)
        {
            if (pair.Value <= 0)
            {
                continue;
            }
            storage.resources[pair.Key] = pair.Value;
            foreach (var conduit in Placeable.FindConnectedTo <ResourceReceiver>(placeable))
            {
                Debug.Log("Flowing " + pair.Key + " to " + conduit.gameObject.name);
                conduit.flowFrom(pair.Key, pair.Value, Ticker.FindTicker().NextFlow());
            }
        }
    }