예제 #1
0
    // Convert structure based on context option chosen
    void ContextOptionChoice(tile _tile, string choice)
    {
        if (choice == decisionTextCancel) { return; }				// If you chose cancel, then don't do anything
        else
        {

            // check if action is possible (unless you're just re-enforcing or un-re-enforcing)
            if (choice == decisionTextReenforce || choice == decisionTextReenforce2 || choice == decisionTextUnReenforce) { }
            else if (tileToConvert.thisTileType == tile.tileType.structure_residence)
            {
                if (!VerifyMeetPrereqs(0,0,0,-1,0) && choice != decisionTextCommunity) { CannotPerformAction("Cannot remove residence - there won't be enough for the workplaces\n(remove mines, or build another residence somewhere else)"); return; }
            }
            else if (tileToConvert.thisTileType == tile.tileType.structure_community)
            {
                if (!VerifyMeetPrereqs(0,0,0,0,-1)) { CannotPerformAction("Cannot remove community - there won't be enough for the residences\n(you need a community to sustain every " + ResidencesPerCommunity + " residences)"); return; }
            }
            else if (choice == decisionTextMining)
            {
                if (!VerifyMeetPrereqs(1,0,0,0,0)) { CannotPerformAction("Cannot build mine - not enough residences\n(1 residence sustains " + MinesPerResidence + " mine(s).)"); return; }
            }
            else if (choice == decisionTextResidence)
            {
                if (!VerifyMeetPrereqs(0,0,0,1,0)) { CannotPerformAction("Cannot build residence - not enough communities\n(you need a community to sustain every " + ResidencesPerCommunity + " residences)"); return; }
            }

            // Check costs and other requirements and perform type change
            if (choice == decisionTextDestroy)
            {
                if (!_tile.structureTypes.Contains(_tile.myNeighborUp.thisTileType))		// if the block above me is not a structure
                {
                    if (FindBaseStrength(FindTileAtTop(_tile), _tile) >= 0)					// make sure it's not structurally necessary before destroying it
                    {
                        RemoveBenefitsOfOldType(_tile);
                        _tile.ChangeTileType(tile.tileType.empty);			// set to empty
                        inventoryDirt -= costToDestroyStructure;							// pay resources
                    }
                    else { CannotPerformAction("Cannot destroy structure - structures rely on this block"); }
                }
                else { CannotPerformAction("Cannot destroy structure - structures rely on this block"); }
            }
            else if (choice == decisionTextRevert)											// revert to empty
            {
                RemoveBenefitsOfOldType(_tile);
                _tile.ChangeTileType (tile.tileType.structure);			// set to empty
                inventoryDirt -= costToRemodel;											// pay resources
            }
            else if (choice == decisionTextReenforce && inventoryDirt - costOfStructure_reenforced >= 0)					// re-enforce structure 1
            {
                _tile.prop_levelOfReenforcement++;
                inventoryDirt -= costOfStructure_reenforced;
            }
            else if (choice == decisionTextReenforce2 && inventoryDirt - costOfStructure_reenforced_2 >= 0)					// re-enforce structure 2
            {
                _tile.prop_levelOfReenforcement++;
                inventoryDirt -= costOfStructure_reenforced_2;
            }
            else if (choice == decisionTextUnReenforce)					// un-re-enforce structure
            {
                // find the strength it will be set back to
                int _tempStrength = 0;
                if (tileToConvert.structureTypes.Contains(tileToConvert.thisTileType)) { _tempStrength = strengthOfStructures; }
                else if (tileToConvert.thisTileType == tile.tileType.dirt) { _tempStrength = strengthOfDirt; }
                else if (tileToConvert.thisTileType == tile.tileType.rock || tileToConvert.thisTileType == tile.tileType.rockWithGem) { _tempStrength = strengthOfRock; }

                if (FindBaseStrength(FindTileAtTop(_tile), _tile, _tempStrength) >= 0			// make sure the structure doesn't rely on it
                         || tileToConvert.myNeighborUp.thisTileType == tile.tileType.empty)		// or if it's the top structure
                {
                    _tile.prop_levelOfReenforcement = 0;
                    inventoryDirt += costOfStructure_unReenforce;
                }
                else { CannotPerformAction("Cannot un-reenforce structure - structures rely on this block's re-enforcement"); }
            }
            else if (choice == decisionTextResidence && inventoryDirt - costOfStructure_residence >= 0)						// change to residence
            { RemoveBenefitsOfOldType(_tile); _tile.ChangeTileType (tile.tileType.structure_residence); inventoryDirt -= costOfStructure_residence; countResidence++; }
            else if (choice == decisionTextMining && inventoryDirt - costOfStructure_mining >= 0)							// change to mining
            {
                RemoveBenefitsOfOldType(_tile);
                _tile.ChangeTileType (tile.tileType.structure_mining);
                inventoryDirt -= costOfStructure_mining;
                countMining++;
                mineTiles.Add(_tile);
                UpdateMinableTilesList();
            }
            else if (choice == decisionTextFactory && inventoryDirt - costOfStructure_factory >= 0)							// change to factory
            { RemoveBenefitsOfOldType(_tile); _tile.ChangeTileType (tile.tileType.structure_factory); inventoryDirt -= costOfStructure_factory; countFactory++; RecalculateCosts(); }
            else if (choice == decisionTextMill && inventoryDirt - costOfStructure_mill >= 0)								// change to mill
            { RemoveBenefitsOfOldType(_tile); _tile.ChangeTileType (tile.tileType.structure_mill); inventoryDirt -= costOfStructure_mill; countMill++; RecalculateCosts(); }
            else if (choice == decisionTextCommunity && inventoryDirt - costOfStructure_community >= 0)						// change to community center
            { RemoveBenefitsOfOldType(_tile); _tile.ChangeTileType (tile.tileType.structure_community); inventoryDirt -= costOfStructure_community; countCommunity++; }
            else if (choice == decisionTextSonar && inventoryDirt - costOfStructure_sonar >= 0)								// change to sonar
            {
                RemoveBenefitsOfOldType(_tile);
                inventoryDirt -= costOfStructure_sonar;
                sonarList.Add(_tile);														// Add to sonar list
                UpdateAllSonar();
                RecalculateCosts();
            }
            else if (choice == decisionTextMountGem)																		// change to gem mount
            {
                if (inventoryGems > 0)												// make sure you have a gem
                {
                    if (_tile.myNeighborUp.thisTileType == tile.tileType.empty)		// make sure there's no structure above
                    {
                        if (_tile.thisTileY >= gemHeightRequirement)				// make sure the gem is being mounted high enough
                        {
                            RemoveBenefitsOfOldType(_tile);
                            _tile.ChangeTileType (tile.tileType.structure_gemMount);
                            inventoryGems--;
                            countGemMount++;
                            inventoryDirt += prizeDirtForMountingGem;
                        }
                        else { CannotPerformAction("Cannot mount Gem here - Gem must be mounted at least " + gemHeightRequirement + " above ground level"); }
                    }
                    else { CannotPerformAction("Cannot mount Gem here - Gem must be mounted on the top of a structure"); }
                }
                else { CannotPerformAction("Cannot mount Gem - You don't have any Gems"); }
            }
            else { CannotPerformAction("Not enough resources\n(Resources can be gained by mining or destroying other structures)"); }
        }
    }