private void CreateTrap() { var position = _instantiatedPreviewTrap.transform.position; var rotation = _instantiatedPreviewTrap.transform.rotation; Destroy(_instantiatedPreviewTrap.gameObject); if (_turretCanBePlaced && GameController.GetInstance().iron >= trapCost) { Entity trap = manager.Instantiate(trapECS); manager.SetComponentData(trap, new Translation { Value = position }); manager.SetComponentData(trap, new Rotation { Value = rotation }); manager.AddBuffer <EnemiesInRange>(trap); GameController.GetInstance().UpdateResources(-trapCost); } else { PopupTextObject.SetActive(true); PopupText popupText = PopupTextObject.GetComponent <PopupText>(); if (GameController.GetInstance().iron < trapCost) { popupText.Setup("Not enough iron"); } } }
private void CreateTurret() { GameController.GetInstance().Player.hud.SetBool("towers", false); CreatingSpot spot = _placeToCreate.GetComponent <CreatingSpot>(); int turretCost = turretCosts[_indexToCreate]; print(turretCost); if (GameController.GetInstance().iron >= turretCost && !spot.HasTurret) { Entity turret = _manager.Instantiate(turretsToCreate[_indexToCreate]); _manager.SetComponentData(turret, new Translation { Value = _placeToCreate.transform.position }); spot.AddTurret(turret); GameController.GetInstance().UpdateResources(-turretCost); GameController.GetInstance().TowersPlaced++; _manager.AddComponent(turret, typeof(TurretFMODPaths)); _manager.SetComponentData(turret, new TurretFMODPaths { ShotPath = turretShotSoundPath, HealPath = turretHealSoundPath, BuffPath = turretBuffSoundPath }); SoundManager.GetInstance().PlayOneShotSound(turretCollocationSoundPath, transform.position); if (_indexToCreate >= 2) { SoundManager.GetInstance().PlayOneShotSound(turretAuraSoundPath, turret); } } else { PopupTextObject.SetActive(true); PopupText popupText = PopupTextObject.GetComponent <PopupText>(); if (spot.HasTurret) { popupText.Setup("There's already a turret there"); } else if (GameController.GetInstance().iron < turretCost) { popupText.Setup("Not enough iron"); } } }
public void CreatePopupText(Vector3 position, int value) { PopupText popupText = Instantiate(popupTextPrefab, position, Quaternion.identity, transform) as PopupText; popupText.Setup(value); }