Exemplo n.º 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() + ")";
        }
    }
Exemplo n.º 2
0
        public IActionResult GetDig(int digid)
        {
            DigSite displayDig = dbContext.DigSites
                                 .Include(dig => dig.AddedBy)
                                 .Include(dig => dig.FossilsUncovered)
                                 .FirstOrDefault(dig => dig.DigSiteID == digid);

            return(View("DigSiteDisplay", displayDig));
        }
Exemplo n.º 3
0
    public void Load(ColonyControllerSerializer ccs)
    {
        if (storage == null)
        {
            storage = gameObject.AddComponent <Storage>();
        }
        storage.Load(ccs.storageSerializer);
        gears_coefficient             = ccs.gears_coefficient;
        labourEfficientcy_coefficient = ccs.labourEfficientcy_coefficient;
        happiness_coefficient         = ccs.happiness_coefficient;
        health_coefficient            = ccs.health_coefficient;
        birthrateCoefficient          = ccs.birthrateCoefficient;

        energyStored        = ccs.energyStored;
        energyCrystalsCount = ccs.energyCrystalsCount;
        if (ccs.worksites.Count > 0)
        {
            foreach (WorksiteSerializer ws in ccs.worksites)
            {
                Worksite w = null;
                switch (ws.type)
                {
                case WorksiteType.BlockBuildingSite:
                    w = new BlockBuildingSite();
                    break;

                case WorksiteType.CleanSite:
                    w = new CleanSite();
                    break;

                case WorksiteType.DigSite:
                    w = new DigSite();
                    break;

                case WorksiteType.GatherSite:
                    w = new GatherSite();
                    break;

                case WorksiteType.TunnelBuildingSite:
                    w = new TunnelBuildingSite();
                    break;
                }
                w.Load(ws);
            }
        }
        freeWorkers          = ccs.freeWorkers;
        citizenCount         = ccs.citizenCount;
        deathCredit          = ccs.deathCredit;
        peopleSurplus        = ccs.peopleSurplus;
        housingTimer         = ccs.housingTimer;
        starvationTimer      = ccs.starvationTimer;
        starvationTime       = ccs.starvationTime;
        realBirthrate        = ccs.realBirthrate;
        birthrateCoefficient = ccs.birthrateCoefficient;
    }
Exemplo n.º 4
0
        protected static void ExcavateSomething(DigSite ths, InteractionInstance inst)
        {
            Sim instanceActor = inst.InstanceActor;
            List <IGameObject> standardTreasure = ths.TreasureComponent.GetStandardTreasure(instanceActor);

            if (standardTreasure.Count > 0x0)
            {
                ths.mNumTreasuresRemaining--;
                GiveTreasuresToSim(standardTreasure, instanceActor, true);
            }
        }
Exemplo n.º 5
0
 public void PourInCube()
 {
     if (chosenCube == null || chosenCube.excavatingStatus == 0)
     {
         return;
     }
     else
     {
         DigSite ds = chosenCube.gameObject.AddComponent <DigSite>();
         ds.Set(chosenCube, false);
         ds.ShowOnGUI();
     }
 }
Exemplo n.º 6
0
 public IActionResult CreateDig(DigSite newDig)
 {
     if (ModelState.IsValid)
     {
         newDig.UserID = HttpContext.Session.GetInt32("LoggedUser").Value;
         dbContext.Add(newDig);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("DigSiteForm"));
     }
 }
Exemplo n.º 7
0
 public void DigButton()
 {
     if (observingSurface == null || observingSurface.destroyed)
     {
         SelfShutOff();
         return;
     }
     else
     {
         if (observingSurface.host.IsStructure())
         {
             //IPlanable
             ((observingSurface.host) as Structure).Annihilate(true, true, false);
             SelfShutOff();
             return;
         }
         else
         {
             bool newCleanSite = false;
             if (observingSurface.isSurface)
             {
                 newCleanSite = observingSurface.fulfillStatus != FullfillStatus.Empty;
                 if (observingSurface.haveWorksite)
                 {
                     var w = colony.GetWorksite(observingSurface);
                     if (w != null && w is CleanSite)
                     {
                         if ((w as CleanSite).diggingMission)
                         {
                             w.StopWork(true);
                             newCleanSite = false;
                         }
                     }
                 }
             }
             if (newCleanSite)
             {
                 var cs = new CleanSite(observingSurface, true);
                 UIController.current.ShowWorksite(cs);
             }
             else
             {
                 var ds = new DigSite(observingSurface, true);
                 UIController.current.ShowWorksite(ds);
             }
             StatusUpdate();
         }
     }
 }
Exemplo n.º 8
0
    public static void StaticLoad(System.IO.Stream fs, int count)
    {
        if (count < 0 | count > 1000)
        {
            Debug.Log("worksites loading error - incorrect count");
            GameMaster.LoadingFail();
            return;
        }
        if (count > 0)
        {
            Worksite w     = null;
            Chunk    chunk = GameMaster.realMaster.mainChunk;
            for (int i = 0; i < count; i++)
            {
                switch ((WorksiteType)fs.ReadByte())
                {
                case WorksiteType.CleanSite:
                {
                    w = CleanSite.Load(fs, chunk);
                    break;
                }

                case WorksiteType.DigSite:
                {
                    w = DigSite.Load(fs, chunk);
                    break;
                }

                case WorksiteType.BlockBuildingSite:
                {
                    w = BlockBuildingSite.Load(fs, chunk);
                    break;
                }

                case WorksiteType.GatherSite:
                {
                    w = GatherSite.Load(fs, chunk);
                    break;
                }

                default: w = null; break;
                }
            }
        }
    }
Exemplo n.º 9
0
 private void INLINE_FinishWorkSequence()
 {
     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);
     }
 }
Exemplo n.º 10
0
    public static DigSite Load(System.IO.Stream fs, Chunk chunk)
    {
        var data = new byte[5];

        fs.Read(data, 0, data.Length);
        Plane plane = null;

        if (chunk.GetBlock(data[0], data[1], data[2])?.TryGetPlane(data[3], out plane) == true)
        {
            var cs = new DigSite(plane, data[4] == 1);
            cs.LoadWorksiteData(fs);
            return(cs);
        }
        else
        {
            Debug.Log("digsite load error");
            return(null);
        }
    }
Exemplo n.º 11
0
    public static void StaticLoad(WorksiteSerializer[] wdata)
    {
        worksitesList = new List <Worksite>(wdata.Length);
        Worksite w = null;

        for (int i = 0; i < worksitesList.Count; i++)
        {
            switch (wdata[i].type)
            {
            default: w = null;; break;

            case WorksiteType.BlockBuildingSite:
                w = new BlockBuildingSite();
                break;

            case WorksiteType.CleanSite:
                w = new CleanSite();
                break;

            case WorksiteType.DigSite:
                w = new DigSite();
                break;

            case WorksiteType.GatherSite:
                w = new GatherSite();
                break;

            case WorksiteType.TunnelBuildingSite:
                w = new TunnelBuildingSite();
                break;
            }
            if (w != null)
            {
                w.Load(wdata[i]);
                worksitesList[i] = w;
            }
        }
    }
Exemplo n.º 12
0
 public void DigCube()
 {
     if (chosenCube == null)
     {
         return;
     }
     else
     {
         if (faceIndex == 4)
         {
             SurfaceBlock sb = chosenCube.myChunk.GetBlock(chosenCube.pos.x, chosenCube.pos.y + 1, chosenCube.pos.z) as SurfaceBlock;
             if (sb == null)
             {
                 DigSite ds = chosenCube.gameObject.AddComponent <DigSite>();
                 ds.Set(chosenCube, true);
                 workingObserver = ds.ShowOnGUI(); // вообще они должны сами в конце цепочки устанавливать здесь workingObserver, не?
             }
             else
             {
                 CleanSite cs = chosenCube.gameObject.AddComponent <CleanSite>();
                 cs.Set(sb, true);
                 workingObserver = cs.ShowOnGUI();
             }
         }
         else
         {
             if (faceIndex < 4)
             {
                 TunnelBuildingSite tbs = chosenCube.gameObject.AddComponent <TunnelBuildingSite>();
                 tbs.Set(chosenCube);
                 tbs.CreateSign(faceIndex);
                 workingObserver = tbs.ShowOnGUI();
             }
         }
     }
 }
Exemplo n.º 13
0
        protected override Scenario.GatherResult Gather(List <Scenario> list, ref int continueChance, ref int maximum, ref bool random)
        {
            if (mCollectables == null)
            {
                mCollectables = new List <GameObject>();
                foreach (GameObject obj in Sims3.Gameplay.Queries.GetObjects <GameObject>())
                {
                    if (obj.InInventory)
                    {
                        continue;
                    }

                    if (!obj.InWorld)
                    {
                        continue;
                    }

                    if (obj.LotCurrent == null)
                    {
                        continue;
                    }

                    RockGemMetalBase rock = obj as RockGemMetalBase;
                    if (rock != null)
                    {
                        if (rock.mCollected)
                        {
                            continue;
                        }

                        if (rock.IsOnSpawner)
                        {
                            continue;
                        }

                        mCollectables.Add(obj);
                    }
                    else if (obj is InsectJig)
                    {
                        mCollectables.Add(obj);
                    }
                    else if (obj is MinorPet)
                    {
                        MinorPet pet = obj as MinorPet;

                        if (pet.IsUnconscious)
                        {
                            continue;
                        }

                        if (pet.Captured)
                        {
                            if (!pet.Escaped)
                            {
                                continue;
                            }
                        }

                        mCollectables.Add(obj);
                    }
                    else
                    {
                        DigSite site = obj as DigSite;
                        if ((site != null) && (site.NumTreasuresRemaining > 0))
                        {
                            mCollectables.Add(obj);
                        }
                    }
                }

                if (mCollectables.Count == 0)
                {
                    return(GatherResult.Failure);
                }
            }

            return(base.Gather(list, ref continueChance, ref maximum, ref random));
        }
Exemplo n.º 14
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) + ")";
        }
    }