Ejemplo n.º 1
0
 override public void LevelUp(bool returnToUI)
 {
     if (!GameMaster.realMaster.weNeedNoResources)
     {
         ResourceContainer[] cost = GetUpgradeCost();
         if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
         {
             AnnouncementCanvasController.NotEnoughResourcesAnnounce();
             return;
         }
     }
     if (level > 3)
     {
         SetBlockers();
     }
     level++;
     nextStageConditionMet = CheckUpgradeCondition();
     SetModel();
     buildingObserver.CheckUpgradeAvailability();
     Quest.ResetHousingQuest();
     AnnouncementCanvasController.MakeAnnouncement(Localization.LevelReachedString(level));
     if (GameMaster.soundEnabled)
     {
         GameMaster.audiomaster.Notify(NotificationSound.HQ_Upgraded);
     }
     GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
 }
    public void CostPanel_Build()
    {
        switch (costPanelMode)
        {
        case CostPanelMode.SurfaceMaterialChanging:
            ResourceType rt = ResourceType.GetResourceTypeById(costPanel_selectedButton.y);
            if (colony.storage.CheckBuildPossibilityAndCollectIfPossible(new ResourceContainer[] { new ResourceContainer(rt, PlaneExtension.INNER_RESOLUTION * PlaneExtension.INNER_RESOLUTION) }))
            {
                observingSurface.ChangeMaterial(rt.ID, true);
                costPanel.transform.GetChild(0).GetChild(costPanel_selectedButton.x).GetComponent <Image>().overrideSprite = null;
            }
            else
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
            }
            break;

        case CostPanelMode.ColumnBuilding:
        {
            if (colony.storage.CheckBuildPossibilityAndCollectIfPossible(ResourcesCost.GetCost(Structure.COLUMN_ID)))
            {
                // float supportPoints = observingSurface.myChunk.CalculateSupportPoints(observingSurface.pos.x, observingSurface.pos.y, observingSurface.pos.z);
                // if (supportPoints <= 1)
                // {
                Structure s = Structure.GetStructureByID(Structure.COLUMN_ID);
                s.SetBasement(observingSurface, new PixelPosByte(7, 7));
                PoolMaster.current.BuildSplash(s.transform.position);
                SetCostPanelMode(CostPanelMode.Disabled);

                Plane p;
                if ((s as IPlanable).TryGetPlane(observingSurface.faceIndex, out p) && !p.isTerminal)
                {
                    mycanvas.Select(p);
                }
                else
                {
                    ReturnButton();
                }
                // }
                //   else
                //  {
                //    observingSurface.myChunk.ReplaceBlock(observingSurface.pos, BlockType.Cave, observingSurface.material_id, ResourceType.CONCRETE_ID, false);
                // }
            }
            else
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
            }
        }
        break;

        case CostPanelMode.BlockBuilding:
            BlockBuildingSite bbs = new BlockBuildingSite(observingSurface, ResourceType.GetResourceTypeById(costPanel_selectedButton.y));
            SetCostPanelMode(CostPanelMode.Disabled);
            mycanvas.ShowWorksite(bbs);
            break;
        }
    }
Ejemplo n.º 3
0
    override public void LevelUp(bool returnToUI)
    {
        if (upgradedIndex == -1)
        {
            return;
        }
        if (!GameMaster.realMaster.weNeedNoResources)
        {
            ResourceContainer[] cost = GetUpgradeCost();
            if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
                return;
            }
        }
        Factory upgraded = GetStructureByID(upgradedIndex) as Factory;

        upgraded.Prepare();
        PixelPosByte setPos = new PixelPosByte(surfaceRect.x, surfaceRect.z);

        if (upgraded.surfaceRect.size == 16)
        {
            setPos = new PixelPosByte(0, 0);
        }
        int workers = workersCount;

        workersCount = 0;
        if (upgraded.rotate90only & (modelRotation % 2 != 0))
        {
            upgraded.modelRotation = (byte)(modelRotation - 1);
        }
        else
        {
            upgraded.modelRotation = modelRotation;
        }
        //
        upgraded.SetRecipe(recipe);
        upgraded.productionMode        = productionMode;
        upgraded.productionModeValue   = productionModeValue;
        upgraded.workPaused            = workPaused;
        upgraded.workflow              = workflow;
        upgraded.inputResourcesBuffer  = inputResourcesBuffer; inputResourcesBuffer = 0;
        upgraded.outputResourcesBuffer = outputResourcesBuffer; outputResourcesBuffer = 0;
        //
        upgraded.SetBasement(basement, setPos);
        upgraded.AddWorkers(workers);
        if (isActive)
        {
            upgraded.SetActivationStatus(true, true);
        }
        if (returnToUI)
        {
            upgraded.ShowOnGUI();
        }
        GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
    }
Ejemplo n.º 4
0
    override public void LevelUp(bool returnToUI)
    {
        if (upgradedIndex == -1)
        {
            return;
        }
        if (!GameMaster.realMaster.weNeedNoResources)
        {
            ResourceContainer[] cost = GetUpgradeCost();
            if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
                return;
            }
        }
        WorkBuilding upgraded = GetStructureByID(upgradedIndex) as WorkBuilding;

        upgraded.Prepare();
        PixelPosByte setPos = new PixelPosByte(surfaceRect.x, surfaceRect.z);

        if (upgraded.surfaceRect.size == 16)
        {
            setPos = new PixelPosByte(0, 0);
        }
        int workers = workersCount;

        workersCount = 0;
        if (upgraded.rotate90only & (modelRotation % 2 != 0))
        {
            upgraded.modelRotation = (byte)(modelRotation - 1);
        }
        else
        {
            upgraded.modelRotation = modelRotation;
        }
        upgraded.AddWorkers(workers);
        upgraded.SetBasement(basement, setPos);
        GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
        if (returnToUI)
        {
            upgraded.ShowOnGUI();
        }
        //copied to factory.levelup
    }
 public void StartConstructing()
 {
     if (observingHangar.status == Hangar.HangarStatus.ConstructingShuttle)
     {
         observingHangar.StopConstruction();
         PrepareHangarWindow();
     }
     else
     {
         ColonyController colony = GameMaster.realMaster.colonyController;
         if (colony.storage.CheckBuildPossibilityAndCollectIfPossible(ResourcesCost.GetCost(ResourcesCost.SHUTTLE_BUILD_COST_ID)))
         {
             observingHangar.StartConstruction();
             PrepareHangarWindow();
         }
         else
         {
             AnnouncementCanvasController.NotEnoughResourcesAnnounce();
         }
     }
 }
Ejemplo n.º 6
0
    /*
     * override public bool IsLevelUpPossible(ref string refusalReason)
     * {
     *  if (workFinished && !awaitingElevatorBuilding)
     *  {
     *      //Block b = basement.myChunk.GetBlock(lastWorkObjectPos.x, lastWorkObjectPos.y - 1, lastWorkObjectPos.z);
     *      //if (b != null && b.type == BlockType.Cube) return true;
     *      else
     *      {
     *          refusalReason = Localization.GetRefusalReason(RefusalReason.NoBlockBelow);
     *          return false;
     *      }
     *  }
     *  else
     *  {
     *      refusalReason = Localization.GetRefusalReason(RefusalReason.WorkNotFinished);
     *      return false;
     *  }
     * }
     */

    override public void LevelUp(bool returnToUI)
    {
        //if (b != null && b.type == BlockType.Cube)
        {
            if (!GameMaster.realMaster.weNeedNoResources)
            {
                ResourceContainer[] cost = GetUpgradeCost();
                if (cost != null && cost.Length != 0)
                {
                    if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
                    {
                        AnnouncementCanvasController.NotEnoughResourcesAnnounce();
                        return;
                    }
                }
            }
            //   workObject = b as CubeBlock;

            UpgradeMine((byte)(level + 1));
            GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
        }
    }
Ejemplo n.º 7
0
    public virtual void LevelUp(bool returnToUI)
    {
        if (upgradedIndex == -1)
        {
            return;
        }
        if (!GameMaster.realMaster.weNeedNoResources)
        {
            ResourceContainer[] cost = GetUpgradeCost();
            if (!GameMaster.realMaster.colonyController.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
                return;
            }
        }
        Building     upgraded = GetStructureByID(upgradedIndex) as Building;
        PixelPosByte setPos   = new PixelPosByte(surfaceRect.x, surfaceRect.z);

        if (upgraded.surfaceRect.size == PlaneExtension.INNER_RESOLUTION)
        {
            setPos = new PixelPosByte(0, 0);
        }
        if (upgraded.rotate90only & (modelRotation % 2 != 0))
        {
            upgraded.modelRotation = (byte)(modelRotation - 1);
        }
        else
        {
            upgraded.modelRotation = modelRotation;
        }
        upgraded.SetBasement(basement, setPos);
        GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
        if (returnToUI)
        {
            upgraded.ShowOnGUI();
        }
    }
 // end build request
 public void CreateSelectedBuilding(byte x, byte z, bool checkForIntersections)
 {
     if (observingSurface == null || observingSurface.destroyed)
     {
         SelfShutOff();
         return;
     }
     ResourceContainer[] cost;
     if (selectedStructureID != Structure.SETTLEMENT_CENTER_ID)
     {
         cost = ResourcesCost.GetCost(selectedStructureID);
     }
     else
     {
         cost = ResourcesCost.GetSettlementUpgradeCost(constructingLevel);
     }
     if (colony.storage.CheckSpendPossibility(cost))
     {
         byte strSize = Structure.GetStructureSize(selectedStructureID), res = PlaneExtension.INNER_RESOLUTION;
         if (x + strSize > res)
         {
             x = (byte)(res - strSize);
         }
         if (z + strSize > res)
         {
             z = (byte)(res - strSize);
         }
         if (checkForIntersections && observingSurface.IsAnyBuildingInArea(new SurfaceRect(x, z, strSize)))
         {
             constructingPlaneTouchPos = new Vector2Int(x, z);
             buildIntersectionSubmit.SetActive(true);
             return;
         }
         else
         {
             colony.storage.GetResources(cost);
             Structure s  = Structure.GetStructureByID(selectedStructureID);
             byte      rt = 0;
             if (s.rotate90only)
             {
                 rt  = (byte)(Random.value * 3);
                 rt *= 2;
             }
             else
             {
                 rt = (byte)(Random.value * 7);
             }
             if (s.ID == Structure.SETTLEMENT_CENTER_ID)
             {
                 (s as Settlement).SetLevel(constructingLevel);
             }
             s.SetBasement(observingSurface, new PixelPosByte(x, z));
             //if (!(s is Dock) & !(s is Hangar)) s.SetModelRotation(rt);
             PoolMaster.current.BuildSplash(s.transform.position);
             GameMaster.realMaster.eventTracker?.BuildingConstructed(s);
             if (observingSurface != null && observingSurface.fulfillStatus != FullfillStatus.Empty)
             {
                 if (constructionPlane.activeSelf)
                 {
                     PrepareConstructionPlane();
                 }
                 if (strSize == res | Structure.PlaceInCenter(selectedStructureID))
                 {
                     if (s is IPlanable)
                     {
                         var   ip = s as IPlanable;
                         Plane p;
                         if (ip.TryGetPlane(observingSurface.faceIndex, out p) && !p.isTerminal)
                         {
                             var sbb = selectedBuildingButton;
                             mycanvas.Select(p);
                         }
                     }
                 }
                 ReturnButton();
             }
             else
             {
                 ReturnButton();
             }
         }
     }
     else
     {
         AnnouncementCanvasController.NotEnoughResourcesAnnounce();
     }
 }