Exemple #1
0
    override public void WorkUpdate()
    {
        if (workplace == null)
        {
            StopWork(true);
            return;
        }
        var strlist = workplace.GetStructuresList();

        if (strlist == null)
        {
            if (diggingMission)
            {
                colony.RemoveWorksite(this);
                DigSite ds = new DigSite(workplace, true, 0);
                TransferWorkers(this, ds);
                if (showOnGUI)
                {
                    ds.ShowOnGUI(); showOnGUI = false;
                }
                StopWork(true);
            }
            else
            {
                StopWork(true);
            }
            return;
        }
        else
        {
            workSpeed = colony.workspeed * workersCount * GameConstants.CLEARING_SPEED;
            workflow += workSpeed;
            colony.gears_coefficient -= gearsDamage * workSpeed;
            Structure s          = strlist[0];
            float     workGained = 0;
            if (s.ID == Structure.PLANT_ID)
            {
                workGained = s.hp;
                (s as Plant).Harvest(false);
            }
            else
            {
                HarvestableResource hr = s as HarvestableResource;
                if (hr != null)
                {
                    workGained = hr.resourceCount;
                    hr.Harvest();
                }
                else
                {
                    s.ApplyDamage(workflow);
                    workGained = workflow;
                }
            }
            workflow   -= workGained;
            actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + " :" + strlist.Count.ToString() + ")";
        }
    }
Exemple #2
0
    void LabourResult()
    {
        int              i = 0;
        bool             resourcesFound = false;
        List <Structure> strs           = workObject.surfaceObjects;

        while (i < strs.Count & workflow > 0)
        {
            switch (strs[i].id)
            {
            case Structure.PLANT_ID:
                Plant p = strs[i] as Plant;
                if (p != null)
                {
                    byte hstage = p.GetHarvestableStage();
                    if (hstage != 255 & p.stage >= hstage)
                    {
                        p.Harvest();
                        resourcesFound = true;
                        workflow--;
                    }
                }
                break;

            case Structure.CONTAINER_ID:
                HarvestableResource hr = strs[i] as HarvestableResource;
                if (hr != null)
                {
                    hr.Harvest();
                    resourcesFound = true;
                    workflow--;
                }
                break;

            case Structure.RESOURCE_STICK_ID:
                ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource;
                if (shr != null)
                {
                    shr.Harvest();
                    resourcesFound = true;
                    workflow--;
                }
                break;
            }
            i++;
        }
        if (resourcesFound)
        {
            destructionTimer = GameMaster.LABOUR_TICK * 10;
        }
    }
 protected override void LabourResult(int iterations)
 {
     if (iterations < 1)
     {
         return;
     }
     workflow -= iterations;
     while (iterations > 0)
     {
         iterations--;
         Structure s = workplace.GetRandomStructure();
         if (s == null)
         {
             INLINE_FinishWorkSequence();
             return;
         }
         else
         {
             if (s.ID == Structure.PLANT_ID)
             {
                 (s as Plant).Harvest(false);
             }
             else
             {
                 HarvestableResource hr = s as HarvestableResource;
                 if (hr != null)
                 {
                     hr.Harvest();
                 }
                 else
                 {
                     s.ApplyDamage(DAMAGE_PER_TICK);
                 }
             }
         }
     }
     actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + " :" + workplace.structuresCount.ToString() + ")";
 }
    protected override void LabourResult(int iterations)
    {
        if (iterations < 1)
        {
            return;
        }
        workflow -= iterations;
        int              i = 0;
        bool             resourcesFound = false;
        List <Structure> strs           = workplace.GetStructuresList();

        if (strs != null)
        {
            while (i < strs.Count & iterations > 0)
            {
                if (strs[i] == null)
                {
                    i++;
                    continue;
                }
                else
                {
                    iterations--;
                    switch (strs[i].ID)
                    {
                    case Structure.PLANT_ID:
                        Plant p = strs[i] as Plant;
                        if (p != null)
                        {
                            p.Harvest(false);
                            resourcesFound = true;
                        }
                        break;

                    case Structure.CONTAINER_ID:
                        HarvestableResource hr = strs[i] as HarvestableResource;
                        if (hr != null)
                        {
                            hr.Harvest();
                            resourcesFound = true;
                        }
                        break;

                    case Structure.RESOURCE_STICK_ID:
                        ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource;
                        if (shr != null)
                        {
                            shr.Harvest();
                            resourcesFound = true;
                        }
                        break;
                    }
                    i++;
                }
            }
            if (resourcesFound)
            {
                destructionTimer = GameMaster.LABOUR_TICK * 10;
            }
        }
    }
Exemple #5
0
    // public const int MAX_WORKERS = 32

    override public void WorkUpdate()
    {
        if (workObject == null)
        {
            StopWork();
            return;
        }
        if (workObject.surfaceObjects.Count == 0)
        {
            Chunk ch = workObject.myChunk;
            destroyed = true; // чтобы скрипт игнорировал StopWork при удалении блока
            if (workObject.type != BlockType.Cave)
            {
                ch.DeleteBlock(workObject.pos);
            }
            else
            {
                (workObject as CaveBlock).DestroySurface();
            }
            destroyed = false; // включаем обратно, чтобы удаление прошло нормально

            int x = workObject.pos.x, y = workObject.pos.y, z = workObject.pos.z;
            workObject = null;

            if (diggingMission)
            {
                Block basement = ch.GetBlock(x, y - 1, z);
                if (basement == null || basement.type != BlockType.Cube)
                {
                    StopWork();
                }
                else
                {
                    DigSite ds = basement.gameObject.AddComponent <DigSite>();
                    TransferWorkers(this, ds);
                    ds.Set(basement as CubeBlock, true);
                    if (showOnGUI)
                    {
                        ds.ShowOnGUI(); showOnGUI = false;
                    }
                    StopWork();
                }
            }
            return;
        }
        else
        {
            workflow += workSpeed;
            Structure s          = workObject.surfaceObjects[0];
            float     workGained = 0;
            if (s.id == Structure.PLANT_ID)
            {
                workGained = s.hp;
                (s as Plant).Harvest();
            }
            else
            {
                HarvestableResource hr = s as HarvestableResource;
                if (hr != null)
                {
                    workGained = hr.resourceCount;
                    hr.Harvest();
                }
                else
                {
                    s.ApplyDamage(workflow);
                    workGained = workflow;
                }
            }
            workflow   -= workGained;
            actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + workObject.surfaceObjects.Count.ToString() + ' ' + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + ")";
        }
    }
Exemple #6
0
    override public void WorkUpdate()
    {
        if (workplace == null)
        {
            StopWork(true);
        }
        if (workersCount > 0)
        {
            workSpeed = colony.workspeed * workersCount * GameConstants.GATHERING_SPEED;
            workflow += workSpeed;
            colony.gears_coefficient -= gearsDamage * workSpeed;
            if (workflow >= 1f)
            {
                int              i = 0;
                bool             resourcesFound = false;
                List <Structure> strs           = workplace.GetStructuresList();
                if (strs != null)
                {
                    while (i < strs.Count & workflow > 0)
                    {
                        switch (strs[i].ID)
                        {
                        case Structure.PLANT_ID:
                            Plant p = strs[i] as Plant;
                            if (p != null)
                            {
                                p.Harvest(false);
                                resourcesFound = true;
                                workflow--;
                            }
                            break;

                        case Structure.CONTAINER_ID:
                            HarvestableResource hr = strs[i] as HarvestableResource;
                            if (hr != null)
                            {
                                hr.Harvest();
                                resourcesFound = true;
                                workflow--;
                            }
                            break;

                        case Structure.RESOURCE_STICK_ID:
                            ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource;
                            if (shr != null)
                            {
                                shr.Harvest();
                                resourcesFound = true;
                                workflow--;
                            }
                            break;
                        }
                        i++;
                    }
                    if (resourcesFound)
                    {
                        destructionTimer = GameMaster.LABOUR_TICK * 10;
                    }
                }
            }
        }
        else
        {
            workSpeed = 0f;
        }
        destructionTimer -= GameMaster.LABOUR_TICK;
        if (destructionTimer <= 0)
        {
            StopWork(true);
        }
    }