Exemplo n.º 1
0
 // Kvieciamas tik tada kai paspaudziama ant movables layer neturincio pastato
 public void DeselectBuildings()
 {
     if (selectedBuildingIndex != -1)
     {
         if (EmptySpot(selectedBuildingIndex))
         {
             ClearSquares(selectedBuildingIndex, buildingsLocations[selectedBuildingIndex]);
             buildingsLocations[selectedBuildingIndex] = new BuildingLocation(buildings[selectedBuildingIndex].transform.position.x, buildings[selectedBuildingIndex].transform.position.y, buildings[selectedBuildingIndex].transform.position.z);
             FillSquares(selectedBuildingIndex, buildingsLocations[selectedBuildingIndex]);
         }
         else
         {
             buildings[selectedBuildingIndex].transform.position        = new Vector3(buildingsLocations[selectedBuildingIndex].x, buildingsLocations[selectedBuildingIndex].y, buildingsLocations[selectedBuildingIndex].z);
             buildingBasisMeshRenderers[selectedBuildingIndex].material = green;
         }
         if (buildings[selectedBuildingIndex].transform.position == new Vector3(0, -100, 0))
         {
             CanonManager    canonManager    = buildings[selectedBuildingIndex].GetComponent(typeof(CanonManager)) as CanonManager;
             CrossbowManager crossbowManager = buildings[selectedBuildingIndex].GetComponent(typeof(CrossbowManager)) as CrossbowManager;
             if (canonManager != null)
             {
                 AddAndRemove.instance.SellCanon();
             }
             else if (crossbowManager != null)
             {
                 AddAndRemove.instance.SellCrossbowTower();
             }
         }
         PutBuildingBack(selectedBuildingIndex);
         selectedBuildingIndex = -1;
         selectedBuildingArrows.transform.position = new Vector3(0, -100, 0);
     }
     removeBuildingButton.gameObject.SetActive(false);
 }
Exemplo n.º 2
0
    //-----------------------------------------------------------------------------------------------------
    //Kvieciamas kai paspaudziama ant movables layer turincio pastato
    public void SelectBuilding(int index)
    {
        if (index != selectedBuildingIndex)
        {
            if (selectedBuildingIndex != -1)
            {
                if (EmptySpot(selectedBuildingIndex))
                {
                    ClearSquares(selectedBuildingIndex, buildingsLocations[selectedBuildingIndex]);
                    buildingsLocations[selectedBuildingIndex] = new BuildingLocation(buildings[selectedBuildingIndex].transform.position.x, buildings[selectedBuildingIndex].transform.position.y, buildings[selectedBuildingIndex].transform.position.z);
                    FillSquares(selectedBuildingIndex, buildingsLocations[selectedBuildingIndex]);
                }
                else
                {
                    buildings[selectedBuildingIndex].transform.position        = new Vector3(buildingsLocations[selectedBuildingIndex].x, buildingsLocations[selectedBuildingIndex].y, buildingsLocations[selectedBuildingIndex].z);
                    buildingBasisMeshRenderers[selectedBuildingIndex].material = green;
                }

                if (selectedBuildingIndex != index)
                {
                    PutBuildingBack(selectedBuildingIndex);
                    BringBuildingNearer(index);
                }
            }
            else
            {
                BringBuildingNearer(index);
            }

            if (selectedBuildingIndex != -1 && buildings[selectedBuildingIndex].transform.position == new Vector3(0, -100, 0))
            {
                CanonManager    canonManager    = buildings[selectedBuildingIndex].GetComponent(typeof(CanonManager)) as CanonManager;
                CrossbowManager crossbowManager = buildings[selectedBuildingIndex].GetComponent(typeof(CrossbowManager)) as CrossbowManager;
                if (canonManager != null)
                {
                    AddAndRemove.instance.SellCanon();
                }
                else if (crossbowManager != null)
                {
                    AddAndRemove.instance.SellCrossbowTower();
                }
            }

            BuildingPlacement.instance.SetItem(buildings[index], buildingsDimensions[index]);

            SetArrowsLocalPosition(index);
            selectedBuildingArrows.transform.position = new Vector3(buildings[index].transform.position.x, 0, buildings[index].transform.position.z);
            BringArrowsNearer();

            selectedBuildingIndex = index;
        }
        removeBuildingButton.gameObject.SetActive(true);
    }
Exemplo n.º 3
0
    private void PutBuildingBack(int buildingIndex)
    {
        CanonManager    canonManager    = buildings[buildingIndex].GetComponent(typeof(CanonManager)) as CanonManager;
        CrossbowManager crossbowManager = buildings[buildingIndex].GetComponent(typeof(CrossbowManager)) as CrossbowManager;

        if (canonManager != null)
        {
            canonManager.PutBack();
        }
        else if (crossbowManager != null)
        {
            crossbowManager.PutBack();
        }
    }
Exemplo n.º 4
0
 void Start()
 {
     PossibleCardBases.Add(new CardBase(true, true, true));
     PossibleCardBases.Add(new CardBase(true, true, false));
     PossibleCardBases.Add(new CardBase(true, false, true));
     PossibleCardBases.Add(new CardBase(true, false, false));
     PossibleCardBases.Add(new CardBase(false, true, true));
     PossibleCardBases.Add(new CardBase(false, true, false));
     PossibleCardBases.Add(new CardBase(false, false, true));
     Cards = GetComponentsInChildren <Card>();
     CardSetup();
     GetCard(SelectorPos.x, SelectorPos.y).ToggleSelection(true);
     CanonManager   = FindObjectOfType <CanonManager>();
     CardsRemaining = Cards.Length;
 }