Example #1
0
 public void UpgradeShields()
 {
     if (resources >= ShieldMaxUpgradeCost && currentMaxShields < 6 && uiController.UpgradeState)
     {
         resources         -= ShieldMaxUpgradeCost;
         currentMaxShields += 1;
         playerHealthControl.maxPlayerShields = currentMaxShields;
         playerHealthControl.RestoreShields();
         uiController.SetResourceCount(resources);
         uiController.SetUpgradeButtons();
         SaveResourceAndUpgradeData();
         if (mapManager.saveName == "TutorialFile")
         {
             tutorialManager.RevealMap();
         }
     }
 }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        ThreatLevel         = 0;
        player              = GameObject.Find("Player");
        abilityController   = player.GetComponent <AbilityController>();
        playerHealthControl = player.GetComponent <PlayerHealthControl>();
        movementController  = player.GetComponent <MovementController>();

        gameController  = GameObject.Find("GameController");
        uiController    = gameController.GetComponent <UIControl>();
        mapManager      = gameController.GetComponent <ManageMap>();
        tutorialManager = gameController.GetComponent <TutorialManager>();
        uiController.SetResourceCount(resources);

        gridlayout = GameObject.Find("Grid").GetComponent <GridLayout>();


        highScoreObjectList = new List <HighScoreObject>()
        {
            new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0)
        };

        if (mapManager.saveName == "TutorialFile")
        {
            resourceAndUpgradeDataSaveFileName = "tutorialResourceAndUpgradeDataSaveFile";
        }

        if (QuickSaveRoot.Exists(resourceAndUpgradeDataSaveFileName)) //use the quicksave feature to check if a save file exists
        {
            LoadResourceAndUpgradeData();                             //if a save file exists, call the load function
        }
        else
        {
            playerHealthControl.RestoreHealth();
            playerHealthControl.RestoreShields();
            abilityController.laserRange = currentMaxLaserRange;
            uiController.SetLaserCharge(abilityController.laserRange, currentMaxLaserRange);
        }
        LoadHighScores();
    }
Example #3
0
    public IEnumerator UpdateTurn()
    {
        uiController.SetPlayerTurnIndicators();
        yield return(new WaitForSeconds(0.5f));

        if (firstTurn)
        {
            firstTurn  = false;
            playerTurn = true;
            //uiController.SetEndTurnButtonState();
        }

        if (combatActive)
        {
            if (playerTurn && abilityController.AbilityUsed && movementController.HasMoved)
            {
                if (abilityController.laserRange < resourceAndUpgradeManager.CurrentMaxLaserRange)
                {
                    abilityController.laserRange += resourceAndUpgradeManager.CurrentMaxLaserRecharge;
                    if (abilityController.laserRange > resourceAndUpgradeManager.CurrentMaxLaserRange)
                    {
                        abilityController.laserRange = resourceAndUpgradeManager.CurrentMaxLaserRange;
                    }
                }
                if (abilityController.jumpRange < resourceAndUpgradeManager.CurrentMaxJumpRange)
                {
                    abilityController.jumpRange += resourceAndUpgradeManager.CurrentMaxJumpRecharge;
                    if (abilityController.jumpRange > resourceAndUpgradeManager.CurrentMaxJumpRange)
                    {
                        abilityController.jumpRange = resourceAndUpgradeManager.CurrentMaxJumpRange;
                    }
                }
                if (abilityController.currentRocketReloadAmount < abilityController.rocketReloadTime)
                {
                    abilityController.currentRocketReloadAmount++;
                }
                if (abilityController.currentShieldBoostCharge < abilityController.shieldBoostRechargeTime)
                {
                    abilityController.currentShieldBoostCharge++;
                }

                GameObject[] rockets = GameObject.FindGameObjectsWithTag("Rocket");
                foreach (GameObject rocket in rockets)
                {
                    rocket.GetComponent <RocketController>().turnsAlive++;
                }
                playerTurn = false;
                enemyTurn  = true;
                //Debug.Log("Update UI. Reset player controls");
                //Debug.Log("TM 74");
                //
                movementController.HasMoved   = false;
                abilityController.AbilityUsed = false;
                abilityController.HasFired    = false;
                StartCoroutine("OrderEnemyTurns");
            }
            else if (enemyTurn)
            {
                //Debug.Log("Order enemy turns. Update UI");
                enemyTurn  = false;
                playerTurn = true;
                //uiController.SetEndTurnButtonState();
            }
        }
        else
        {
            //Debug.Log("Reset all combat stats");
            abilityController.laserRange = abilityController.maxLaserRange;
            abilityController.jumpRange  = resourceAndUpgradeManager.CurrentMaxJumpRange;
            abilityController.currentRocketReloadAmount = abilityController.rocketReloadTime;
            abilityController.currentShieldBoostCharge  = abilityController.shieldBoostRechargeTime;
            uiController.SetLaserCharge(abilityController.laserRange, abilityController.maxLaserRange);
            uiController.SetJumpCharge(abilityController.jumpRange, resourceAndUpgradeManager.CurrentMaxJumpRange);
            uiController.SetRocketReloadState(abilityController.currentRocketReloadAmount, abilityController.rocketReloadTime);
            uiController.SetShieldBoostRechargeState(abilityController.currentShieldBoostCharge, abilityController.shieldBoostRechargeTime);
            movementController.HasMoved   = false;
            abilityController.AbilityUsed = false;
            playerHealthControl.RestoreShields();
            mapManager.ClearHighlighting();
            if (mapManager.saveName == "TutorialFile")
            {
                tutorialManager.PlayerWon();
            }
        }

        uiController.SetEndTurnButtonState();
    }