예제 #1
0
 /// <summary>
 /// Belongs to InitalizeEventTrigger().
 ///
 /// Author: Steven Johnson, David Askari
 /// </summary>
 /// <param name="data">Information about the event.</param>
 public void OnPointerExitDelegate(PointerEventData data)
 {
     if (!Hover.IsActive())
     {
         TowerInformation.Reset();
     }
 }
예제 #2
0
    public void InitializeTowerInformation(GameObject _infoObject)
    {
        infoObject = _infoObject;
        info       = infoObject.GetComponent <TowerInformation>();

        gameObject.GetComponentInParent <SpriteRenderer>().sprite = info.sprite;
    }
예제 #3
0
 /// <summary>
 /// Belongs to InitalizeEventTrigger().
 ///
 /// Author: Steven Johnson, David Askari
 /// </summary>
 /// <param name="data">Information about the event.</param>
 public void OnPointerEnterDelegate(PointerEventData data)
 {
     if (!PauseGame.Status)
     {
         TowerInformation.ShowHoveringTower(TowerPrefab.GetComponent <Tower>());
     }
 }
예제 #4
0
 /// <summary>
 /// When a tower is clicked, set the currently selected tower and update the TowerInformation panel.
 ///
 /// Author: Steven Johnson, David Askari
 /// </summary>
 private void OnMouseUpAsButton()
 {
     if (!PauseGame.Status)
     {
         GameManager.SelectTower(this);
         TowerInformation.ShowPlacedTower(this);
     }
 }
예제 #5
0
        public void ShowTowerInformation(TowerInformation towerInformation)
        {
            _towerInformationPanel.SetActive(true);

            _towerName.text        = towerInformation.Name;
            _towerCost.text        = $"<b>Cost:</b> {towerInformation.Cost.ToString()}";
            _towerSpeed.text       = $"<b>Speed:</b> {towerInformation.Speed}";
            _towerDescription.text = towerInformation.Description;
        }
예제 #6
0
    public void SetTowerInformation(GameObject _infoObject)
    {
        TowerInformation _info = _infoObject.GetComponent <TowerInformation>();

        _info.currentSoldiers       = info.currentSoldiers;
        _info.currentProductionTime = info.currentProductionTime;
        _info.timeToNext            = info.timeToNext;

        info = _info;
    }
예제 #7
0
 /// <summary>
 /// Adds m amount of money to the player's available blood.
 /// </summary>
 /// <param name="m">Amount of money added.</param>
 public static void AddMoney(int m)
 {
     GameManager.money += m;
     if (TowerInformation.isActive)
     {
         TowerInformation.CheckUpgrade();
     }
     foreach (TowerBtn towerBtn in towerBtns)
     {
         towerBtn.CheckEnoughMoney();
     }
 }
예제 #8
0
 /// <summary>
 /// Check whether a tower is currently selected and the tile is empty, then either place a tower or reset TowerInformation panel based on Hover.
 /// Authors: David Askari, Steven Johnson
 /// </summary>
 private void OnMouseUpAsButton()
 {
     if (!EventSystem.current.IsPointerOverGameObject() && GameManager.SelectedTower != null && this.placedTower == null)
     {
         if (Hover.IsActive())
         {
             Tower possiblyPlacedTower = GameManager.SelectedTower.PlaceTower(this);
             this.placedTower = possiblyPlacedTower == null ? null : possiblyPlacedTower;
         }
         else
         {
             TowerInformation.Reset();
         }
     }
 }
예제 #9
0
    /// <summary>
    /// Upgrade the currently selected tower.
    ///
    /// Author: Steven Johnson, David Askari, Courtney Chu
    /// </summary>
    public void UpgradeTower()
    {
        GameManager.AddMoney(-selectedTower.UpgradeCosts);
        if (!GameManager.didUpgradeFirstTower)
        {
            GameManager.didUpgradeFirstTower = true;
            StartCoroutine(GameManager.DisplayRewardsPanel());
        }

        if (GameManager.CheckForFirstUpgrade())
        {
            StartCoroutine(GameManager.DisplayRewardsPanel());
        }

        selectedTower.Upgrade();
        TowerInformation.ShowPlacedTower(selectedTower);
        TowerInformation.CheckUpgrade();
    }
예제 #10
0
    /// <summary>
    /// Place tower on passed tile, if it is possible (enough money & don't block path).
    ///
    /// Author: Steven Johnson, David Askari
    /// </summary>
    /// <param name="parentTile">Parent tile for this tower.</param>
    /// <returns>Created tower.</returns>
    public Tower PlaceTower(Tile parentTile)
    {
        if (baseCosts > GameManager.money)
        {
            GameManager.DisplayErrorText("Can't place tower. Not enough funds.");
            return(null);
        }
        GameManager.AddMoney(-baseCosts);

        // Place tower.
        GameObject tower = Instantiate(GameManager.SelectedTower.gameObject, parentTile.transform.position, Quaternion.identity, parentTile.transform);

        if (GameManager.CheckForFirstPlacement())
        {
            StartCoroutine(GameManager.DisplayRewardsPanel());
        }

        // Check if path is blocked.
        if (!GridGraphManager.IsGraphNotBlocked(tower))
        {
            GameManager.DisplayErrorText("Can't place tower here. Path is entirely blocked.");
            GameManager.AddMoney(baseCosts);
            Destroy(tower);
            return(null);
        }

        // Set sprite sorting order.
        tower.GetComponent <SpriteRenderer>().sortingOrder = -parentTile.GridPoint.y;

        // Allow multi tower placement by pressing LeftShift.
        if (!Input.GetKey(KeyCode.LeftShift))
        {
            Hover.Deactivate();
            GameManager.SelectTower(tower.GetComponent <Tower>());
            TowerInformation.Reset();
        }

        tower.GetComponent <Tower>().tile = parentTile;
        return(tower.GetComponent <Tower>());
    }
예제 #11
0
 public void GetTheInformation(TowerInformation tower, Transform towerPlace)
 {
     this.tower      = tower;
     this.towerPlace = towerPlace;
 }
예제 #12
0
    /// <summary>
    /// Updates times and other necessary pieces of game play.
    ///
    /// Authors: Amy Lewis, Cole Twitchell, David Askari, Steven Johnson, Courtney Chu
    /// </summary>
    public void Update()
    {
        SetTimerText();
        WaveManager.Update();

        var saturation = ppProfile.colorGrading.settings;

        if (currentWave == 1)
        {
            saturation.basic.saturation = 1;
        }
        else if (currentWave == 6)
        {
            sendBossButton.SetActive(true);
            PauseGame.sendBossButton = sendBossButton.GetComponent <SendBossButton>();
        }

        if (gameOver)
        {
            waveTimer.SetPaused(true);

            if (CastleManager.CastleHealth > 0)
            {
                saturation.basic.saturation = 0;
            }

            PauseGame.Status = true;

            GameObject.Find("OptionsMenu").SetActive(false);
            GameObject.Find("OptionsButton").GetComponent <Button>().interactable = false;
            sendBossButton.GetComponent <SendBossButton>().DisableButton();

            if (CastleManager.CastleHealth > 0)
            {
                XmlImporter.Cleanup();
                PauseGame.Status = false;
                SceneManager.LoadScene("victory_cutscene");
            }
            else
            {
                gameOverObject.transform.Find("GameOverText").GetComponent <Text>().text = "GAME OVER";
                gameOverObject.SetActive(true);
                enabled = false;
            }
        }
        else
        {
            if (!waveTimer.IsPaused() && waveTimer.IsDone())
            {
                waveTimer.SetPaused(true);
                WaveManager.BeginWave();
                AudioManager.PlayBeginWaveSound();
                sendBossButton.GetComponent <SendBossButton>().DisableButton();
            }

            if (WaveManager.WaveFinished() && EnemyManager.EnemiesRemaining() <= 0)
            {
                saturation.basic.saturation = 1.0f - ((float)(currentWave - 1) / (float)totalWaves);
                currentWave++;
                waveText.text = currentWave.ToString();
                waveTimer.Reset();
                waveTimer.SetPaused(false);
                WaveManager.SetNextWave();
                skipTimeButton.interactable = true;
                sendBossButton.GetComponent <SendBossButton>().ResetButton();
            }

            if (Hover.IsActive())
            {
                GameManager.rangeIndicatorRenderer.transform.position = Hover.GetPosition();
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                GameManager.AddMoney(100);
            }

            if (Input.GetKeyDown(KeyCode.A))
            {
                SkipTimer();
            }
            else if (Input.GetMouseButtonUp(1) && Hover.IsActive())
            {
                GameManager.rangeIndicatorRenderer.enabled = false;
                Hover.Deactivate();
                GameManager.ResetTower();
                TowerInformation.Reset();
            }
        }
        ppProfile.colorGrading.settings = saturation;
        healthText.text = CastleManager.CastleHealth.ToString();
        moneyText.text  = money.ToString();

        errorTextTimer.Update();
        if (errorTextTimer.IsDone())
        {
            errorText.gameObject.SetActive(false);
            errorTextTimer.Reset();
            errorTextTimer.SetPaused(true);
        }
    }