private void Update()
 {
     if (constructible.GetIsland())
     {
         accumulated += rate * Time.deltaTime;
         AddPendingResources();
     }
 }
Exemple #2
0
    private void Update()
    {
        if (constructible.GetIsland())
        {
            var reloadDt = Time.deltaTime;

            var cannons = constructible.GetIsland().GetNumberOfCannons();
            Debug.Assert(cannons > 0);             // We are cannon at least
            var soldiers         = constructible.GetIsland().GetResourceAmount(Island.ResourceType.Soldier);
            var reloadMultiplier = (float)soldiers / cannons;
            reloadMultiplier = Mathf.Clamp(reloadMultiplier, 0.0f, 2.0f);

            delay -= reloadDt * reloadMultiplier;

            if (CanFire())
            {
                var closest = range.GetClosest();
                if (closest)
                {
                    Fire(closest);
                    delay = reloadSpeed;
                }
            }
        }
    }