Ejemplo n.º 1
0
    public bool RemoveBuilding()
    {
        if (_myBuildingUnit == null)
        {
            //There is no building on this tile
            return(false);
        }
        else
        {
            //Have the building destroy itself and clear local ref
            _myBuildingUnit.DestroyBuilding();

            _myBuildingUnit = null;

            return(true);
        }
    }
Ejemplo n.º 2
0
 public void ClearReceivedBuilding()
 {
     _myBuildingUnit = null;
 }
Ejemplo n.º 3
0
    public bool RemoveBuilding()
    {
        if(_myBuildingUnit == null)
        {
            //There is no building on this tile
            return false;
        }
        else
        {
            //Have the building destroy itself and clear local ref
            _myBuildingUnit.DestroyBuilding();

            _myBuildingUnit = null;

            return true;
        }
    }
Ejemplo n.º 4
0
 public void ReceiveBuilding(iBuildingPlacer building)
 {
     _myBuildingUnit = building;
 }
Ejemplo n.º 5
0
 public void ClearReceivedBuilding()
 {
     _myBuildingUnit = null;
 }
Ejemplo n.º 6
0
 public void ReceiveBuilding(iBuildingPlacer building)
 {
     _myBuildingUnit = building;
 }
Ejemplo n.º 7
0
    public void PlaceBuildingOnCurrent()
    {
        if (buildingPlacement.currentBuilding != BuildingType.off)
        {
            if (_currentTile != null)
            {
                //Handle building removal mode
                if (buildingPlacement.currentBuilding == BuildingType.remove)
                {
                    //Store the building and it's removal sound from this tile in temp
                    iBuildingPlacer _tempBuilding = _currentTile.getPlacedBuilding();
                    SoundType       _tempSound    = SoundType.None;
                    if (_tempBuilding != null)
                    {
                        _tempSound = _tempBuilding.getRemovalSound();
                    }

                    //Try to remove building from the current tile building receiver
                    if (_currentTile.RemoveBuilding())
                    {
                        //Building was cleared from receiver

                        //Play building remove sound, if we have one
                        if (SoundType.None != _tempSound)
                        {
                            Sounds.instance.Play(_tempSound);
                        }
                    }
                    else
                    {
                        //no building to clear
                    }
                }
                else
                {
                    //Handle placement of all other buildings
                    GameObject tempBuilding = GameObject.Instantiate(GetBuildingPrefab_forType(buildingPlacement.currentBuilding));

                    //Try to place building on the current tile
                    if (tempBuilding.gameObject.GetComponent <iBuildingPlacer>().PlaceBuilding(_currentTile))
                    {
                        //building was successfully placed onto the receiver

                        //Parent new building to root
                        tempBuilding.transform.parent = GO_Root.transform;

                        //add to internal list
                        allBuildings.Add(tempBuilding);

                        //Initiate the new building (with it's index, etc)
                        tempBuilding.gameObject.GetComponent <iBuildingPlacer>().Init(allBuildings.Count - 1);

                        //Play building place sound
                        Sounds.instance.Play(
                            tempBuilding.gameObject.GetComponent <iBuildingPlacer>().getPlacementSound());
                    }
                    else
                    {
                        //fail to build, destroy temp
                        Destroy(tempBuilding);
                    }
                }
            }
        }
    }