//If it comes here, its because its a shop item for sure!!! public void ListenForItemPickedUp(GameObject obj, TowerPiece towerPiece) { //Make sure hand is empty if (this.objInMyHand == null) { //-----------------------------TODO remove------------------------- obj.transform.position = new Vector3(0, 10, 0); this.objInMyHand = obj; this.towerPiece = towerPiece; //Spawn ghost obj SpawnObjGrabbed(towerPiece.currentType); if (!towerPiece.itemWasPlacedOnMap) { //Check if item was pickup from shop or map if (!towerPiece.itemWasPlacedOnMap) { //Respawn the right obj SpawnTheRightObj(towerPiece); } } } }
private void PlaceObjBackWhereItWas(GameObject obj, TowerPiece towerPiece) { //Get old position Vector3 position = this.gridManager.GetGrid("MapRoom").GetCenterTileFromCoords(towerPiece.positionOnMap); //Set position to item in my hand this.objInMyHand.transform.position = position; //Remove ghost item RemoveObjWithAnimation(obj); }
public void AddTowerPiece() { GameObject towerPieceGO = Instantiate(GetTowerPiecePrefab(), new Vector3(transform.position.x, GetTowerPieceY(), transform.position.z), Quaternion.identity); TowerPiece towerPiece = towerPieceGO.AddComponent <TowerPiece>(); _towerPiecesOnTile.Add(towerPiece); if (_towerPiecesOnTile.Count == 4) { _domed = true; } }
public void ListenForItemDropped(GameObject obj, TowerPiece towerPiece) { if (towerPiece.itemWasPlacedOnMap) { //Place back to where it was PlaceObjBackWhereItWas(this.objInMyHand, towerPiece); } else { //Remove from map RemoveObjWithAnimation(this.objSelected); this.objInMyHand = null; this.objSelected = null; this.towerPiece = null; } }
private void SpawnTheRightObj(TowerPiece towerPiece) { this.timeManager.AddTimedAction(new TimedAction(() => { SpawnTurretInShop(towerPiece.currentType); }, 3f)); }