Example #1
0
 private void HandleLandChunkSelected(Land_Chunk landChunk)
 {
     if (landChunk == selectedLand) return;
     if (selectedLand) selectedLand.SetSelectedState(false);
     selectedLand = landChunk;
     if (selectedLand) selectedLand.SetSelectedState(true);
 }
Example #2
0
    private void HandleLandChunkDeselected()
    {
        transform.position = selector.GetAveragePositionOfSelected();

        Land_Chunk chunk = selector.GetLastSelectedLandChunk();
        if (!chunk) return;
        UpdatePurchaseButton(chunk);
        UpdatePlowLandButton(chunk);
        selectedLandChunk = chunk;
    }
Example #3
0
 public bool AddChunkChecked(Land_Chunk chunk)
 {
     if (!chunk) return false;
     if (!selectedChunks.Contains(chunk))
     {
         AddChunk(chunk);
         return true;
     }
     return false;
 }
Example #4
0
 private void HandleLandChunkSelected(Land_Chunk landChunk)
 {
     if (landChunk)
     {
         gameObject.SetActive(true);
         transform.position = selector.GetAveragePositionOfSelected();
         UpdatePurchaseButton(landChunk);
         UpdatePlowLandButton(landChunk);
         selectedLandChunk = landChunk;
     }
     else
     {
         gameObject.SetActive(false);
         selectedLandChunk = null;
     }
 }
Example #5
0
    private GameObject FindIntersectingFencePiece(Land_Chunk a, Land_Chunk b)
    {
        GameObject result = null;
        Collider col = intersectionCheckVolume;

        //NOTE: returns after first intersection is found
        for (int i = 0; i < fenceCheckOffsets.Length; ++i)
        {
            col.transform.position = a.transform.position + fenceCheckOffsets[i];
            result = CheckForFenceIntersection(col.bounds, b);
            if (result) break;
        }

        return result;
    }
Example #6
0
 private GameObject CheckForFenceIntersection(Bounds bounds, Land_Chunk b)
 {
     GameObject[] pieces = b.fenceMidSections;
     for (int i = 0; i < pieces.Length; ++i)
     {
         if (!pieces[i] || !pieces[i].activeSelf) continue;
         Collider pieceCol = pieces[i].GetComponentInChildren<Collider>();
         if (pieceCol && pieceCol.bounds.Intersects(bounds)) return pieces[i];
     }
     return null;
 }
Example #7
0
    //NOTE: Checks for sections of fence that should be unhidden due to tiles being sold by the player.
    private void FixGapsInFence(Land_Chunk chunk)
    {
        Collider intersectionCollider = intersectionCheckVolume;
        GameObject[] fencePieces = chunk.fenceMidSections;

        for (int i = 0; i < fencePieces.Length; ++i)
        {
            bool activated = false;
            if (!fencePieces[i] || fencePieces[i].activeSelf) continue;
            fencePieces[i].SetActive(true);

            //The post model and collider are children of the fence object.
            Collider postCollider = fencePieces[i].GetComponentInChildren<Collider>();
            if (!postCollider) continue;

            //Check for adjacent tile using bounds intersection checks.
            for (int k = 0; k < landChunks.Length; ++k)
            {
                if (!landChunks[k] || landChunks[k].owned || landChunks[k].transform == postCollider.transform) continue;
                intersectionCollider.transform.position = postCollider.transform.position;
                Collider landCol = landChunks[k].GetComponent<Collider>();
                if (landCol)
                {
                    if (intersectionCollider.bounds.Intersects(landCol.bounds))
                    {
                        fencePieces[i].SetActive(true);
                        activated = true;
                        break;
                    }
                }
                else Print.NotFound<Collider>(this, "failed to find land collider");
            }
            if (!activated) fencePieces[i].SetActive(false);
        }
    }
Example #8
0
 private void HandleNonImportantSelection()
 {
     if (selectedLand) selectedLand.SetSelectedState(false);
     selectedLand = null;
 }
Example #9
0
 private void UpdatePlowLandButton(Land_Chunk chunk)
 {
     if (!chunk) return;
     plowLandButton.gameObject.SetActive(showSellScreen && !chunk.plowed);
     if (plowLandButtonText) plowLandButtonText.text = "Plow: -$" + selector.GetTotalSelectedLandPlowCost().ToString();
 }
Example #10
0
 private void SingleSelection(Land_Chunk chunk)
 {
     if (!chunk) return;
     ClearSelection();
     AddChunk(chunk);
 }
Example #11
0
 private void HandleChunkSelectedCtrlMod(Land_Chunk chunk)
 {
     if (!chunk) return;
     if (!selectedChunks.Contains(chunk)) AddChunk(chunk);
     else RemoveChunk(chunk);
 }
Example #12
0
 public void RemoveChunk(Land_Chunk chunk)
 {
     chunk.SetSelectedState(false);
     selectedChunks.Remove(chunk);
     TriggerOnLandChunkDeselected();
 }
Example #13
0
 private void HandleOnLandPlowed(Land_Chunk chunk)
 {
     if (selectedLandChunk && chunk == selectedLandChunk) UpdatePlowLandButton(chunk);
 }
Example #14
0
 private void UpdatePurchaseButton(Land_Chunk chunk)
 {
     if (!chunk) return;
     if (chunk.owned)
     {
         string priceText = selector.GetTotalSelectedLandSellValue().ToString();
         purchaseButtonText.text = "Sell +$" + priceText;
         showSellScreen = true;
     }
     else
     {
         string priceText = selector.GetTotalSelectedLandCost().ToString();
         purchaseButtonText.text = "Purchase -$" + priceText;
         showSellScreen = false;
     }
 }
Example #15
0
 private void AddNeighborChunk(Land_Chunk chunk)
 {
     for (int k = 0; k < neighborChunks.Length; ++k)
     {
         if (neighborChunks[k] != null) continue;
         neighborChunks[k] = chunk;
         if (k >= neighborChunks.Length) return;
         break;
     }
 }
Example #16
0
 public void AddChunk(Land_Chunk chunk)
 {
     chunk.SetSelectedState(true);
     selectedChunks.Add(chunk);
 }
Example #17
0
 private void TriggerOnLandChunkSelectedCtrlMod(Land_Chunk landChunk)
 {
     if (onLandChunkSelectedCtrlMod != null) onLandChunkSelectedCtrlMod(landChunk);
 }
 private void TriggerOnLandChunkSelected(Land_Chunk chunk)
 {
     if (onLandChunkSelected != null) onLandChunkSelected(chunk);
 }