/// <summary>
        /// We select a specific BuildingPlatform as the target
        /// </summary>
        /// <param name="target">The buildingPlatform we are going to select</param>
        public void SetTarget(BuildingPlatform target)
        {
            m_Target = target;

            //We use the building position as the position for the UI
            transform.position = target.GetBuildPosition();

            towerName.text = target.GetTower().name;
            sellPrice.text = target.GetTower().SellPrice + "U";
            UI.SetActive(true);
        }
Пример #2
0
        /// <summary>
        /// Called for selecting a specific building platform and showing the UI
        /// </summary>
        /// <param name="buildingPlatform">The building platform we are trying to select</param>
        public void SelectPlatform(BuildingPlatform buildingPlatform)
        {
            //if we click on the same platform that was already selected we deselect it
            if (buildingPlatform == m_SelectedPlatform)
            {
                DeselectBuildingPlatform();
                return;
            }

            m_SelectedPlatform = buildingPlatform;
            buildingPlatformUI.SetTarget(m_SelectedPlatform);
        }
Пример #3
0
        /// <summary>
        /// Sells the tower on this platform.
        /// </summary>
        public void SellTower(BuildingPlatform platform)
        {
            //we add the credits that we get from the sale and we destroy the tower
            MinigameManager.Instance.AddCurrency(platform.GetTower().SellPrice);
            ParticleSystem particles = Instantiate <ParticleSystem>(SellEffect, platform.GetBuildPosition(), SellEffect.transform.rotation);

            Destroy(particles, 1.5f);

            //Play the audio sound
            audioSource.clip = sellSound;
            audioSource.Play();

            platform.SellTower();
        }
Пример #4
0
        /// <summary>
        /// Build a tower on the selected platform
        /// </summary>
        /// <param name="platform">Bulding platform where we want to build the tower</param>
        /// <returns></returns>
        public Tower BuildTowerOn(BuildingPlatform platform)
        {
            // If we can affor to build it we do so othwerwise we do nothing
            if (CanAfford())
            {
                MinigameManager.Instance.currency.UpdateCredits(-m_TowerToBuild.Cost);
                Tower          towerToBuild = Instantiate <Tower>(m_TowerToBuild, platform.GetBuildPosition(), platform.transform.rotation);
                ParticleSystem particles    = Instantiate <ParticleSystem>(BuildEffect, platform.GetBuildPosition(), BuildEffect.transform.rotation);
                Destroy(particles.gameObject, 5f);

                //Play the audio sound
                audioSource.clip = buildSound;
                audioSource.Play();

                StopBuilding();
                return(towerToBuild);
            }

            return(null);
        }
Пример #5
0
 /// <summary>
 /// We deselect the building platform selected so we hide the UI
 /// </summary>
 public void DeselectBuildingPlatform()
 {
     m_SelectedPlatform = null;
     buildingPlatformUI.Hide();
 }