Exemple #1
0
    IEnumerator GameOver(GameObject player)
    {
        Destroy(player.GetComponent <PlayerShip>().shipExhaustEffectPrefab);
        Destroy(player);

        finalScoreBoard.text += score.ToString();
        finalLevelBoard.text += curLevel.ToString();

        if (getHighScore)
        {
            finalScreenTitle.text = "New Highscore";
        }
        else
        {
            finalScreenTitle.text = "Game Over";
        }

        GAME_STATE = eGameState.gameOver;

        SaveGameManager.CheckHighScore(score);
        SaveGameManager.Save();

        CustomAnalytics.SendFinalShipPartChoice();
        CustomAnalytics.SendGameOver();

        yield return(new WaitForSeconds(timeUntilRestart));

        SceneManager.LoadScene(levelToRestart);
    }
Exemple #2
0
    /// <summary>
    /// Increments one of the StepRecords that can unlock Achievements.
    /// </summary>
    /// <param name="stepType">The eStepType to increment.</param>
    /// <param name="num">The amount to increment (default = 1).</param>
    static public void AchievementStep(Achievement.eStepType stepType, int num = 1)
    {
        StepRecord sRec = STEP_REC_DICT[stepType];

        if (sRec != null)
        {
            sRec.Progress(num);

            // Iterate through all of the possible Achievements and see if the step
            //  completes the Achievement
            foreach (Achievement ach in S.achievements)
            {
                if (!ach.complete)
                {
                    // Pass the step information to the Achievement, to see if it is completed
                    if (ach.CheckCompletion(stepType, sRec.num))
                    {
                        // The result is true if the Achievement was newly completed
                        AnnounceAchievementCompletion(ach);

                        // Tell Unity Analytics that the Achievement has been completed
                        CustomAnalytics.SendAchievementUnlocked(ach);

                        // Also save the game any time we complete an Achievement
                        SaveGameManager.Save();
                    }
                }
            }
        }
        else
        {
            Debug.LogWarning("AchievementManager:AchievementStep( " + stepType + ", " + num + " )"
                             + "was passed a stepType that is not in STEP_REC_DICT.");
        }
    }
Exemple #3
0
    public void SetTurret(uint index)
    {
        if (turret != null && PlayerScriptableObject.GetTurret(index) != null)
        {
            if (turret.name != PlayerScriptableObject.GetTurret(index).name)
            {
                Destroy(turret);
            }
        }
        //log here
        if (turret == null)
        {
            turret = Instantiate(PlayerScriptableObject.GetTurret(index));

            if (turretParent.transform != null)
            {
                turret.transform.parent        = turretParent.transform;
                turret.transform.localPosition = Vector3.zero;
                turret.transform.localRotation = Quaternion.AngleAxis(90, Vector3.right);
                turret.name = PlayerScriptableObject.GetTurret(index).name;
                SaveGameManager.Save();
            }
        }
        //log here
    }
Exemple #4
0
    public void SetBody(uint index)
    {
        if (body != null && PlayerScriptableObject.GetBody(index) != null)
        {
            if (body.name != PlayerScriptableObject.GetBody(index).name)
            {
                Destroy(body);
            }
        }
        //log here
        if (body == null)
        {
            body = Instantiate(PlayerScriptableObject.GetBody(index));

            if (bodyParent.transform != null)
            {
                body.transform.parent        = bodyParent.transform;
                body.transform.localPosition = Vector3.zero;
                body.transform.localRotation = Quaternion.identity;
                body.name = PlayerScriptableObject.GetBody(index).name;
                SaveGameManager.Save();
            }
        }
        //log here
    }
 static public void GameOver()
 {
     SaveGameManager.CheckHighScore(SCORE);
     SaveGameManager.Save();
     CustomAnalytics.SendFinalShipPartChoice();
     CustomAnalytics.SendGameOver();
     _S.EndGame();
 }
Exemple #6
0
    void checkAchivement(WeaponType type)
    {
        ACH_DICT[type].achieved = true;

        GameObject chMark = achievementBoxes[ACH_DICT[type].serialNumber].transform.Find("checkedMark").gameObject;

        chMark.SetActive(true);
        SaveGameManager.Save();
    }
    bool SetPartNS(ShipPart.eShipPartType type, int num)
    {
        // Ensure that this is asking for an extant ship part
        if (!ShipPartsDictionary.DICT.ContainsKey(type))
        {
            Debug.LogError("ShipCustomization:SetPartNS - ShipPartsDictionary.DICT does not contain type: " + type);
            return(false);
        }
        if (!currPartsDict.ContainsKey(type))
        {
            Debug.LogError("ShipCustomization:SetPartNS - currPartsDict does not contain type: " + type);
            return(false);
        }

        if (num < 0 || ShipPartsDictionary.DICT[type].partInfos.Length <= num)
        {
            Debug.LogError("ShipCustomization:SetPartNS - Attempt to choose nonextant " + type + ": " + num);
            return(false);
        }

        // Now we know that this is a valid type and part num...
        // Pull the information from the current part in that place
        Transform  currTrans    = currPartsDict[type];
        Vector3    lPos         = currTrans.localPosition;
        Quaternion lRot         = currTrans.localRotation;
        Transform  parentTransf = currTrans.parent;

        // Generate a new part and position it correctly
        Transform newTransf = Instantiate <GameObject>(ShipPartsDictionary.DICT[type].partInfos[num].prefab).transform;

        newTransf.SetParent(parentTransf);
        newTransf.localPosition = lPos;
        newTransf.localRotation = lRot;

        // Replace the currTrans with the newTrans in the currPartsDict
        currPartsDict[type] = newTransf;

        // Destroy the old one
        Destroy(currTrans.gameObject);

        // Save the game
        SaveGameManager.Save();

        return(true);
    }
 void UnlockAchievement(int achievementNumberInList)
 {
     if (achievementNumberInList == -1)
     {
         achievementNameDisplay.text        = "HIGH SCORE";
         achievementDescriptionDisplay.text = "You've achieved a new high score.";
     }
     else
     {
         achievementNameDisplay.text        = Achievements[achievementNumberInList].name;
         achievementDescriptionDisplay.text = Achievements[achievementNumberInList].description;
         ShipCustomizationPanel.UnlockPart(Achievements[achievementNumberInList].partType, Achievements[achievementNumberInList].partNum);
         CustomAnalytics.SendAchievementUnlocked(Achievements[achievementNumberInList]);
     }
     anim.SetBool("Achievement appear", true);
     Invoke("AchievementDisappear", durationOfShowingAchievement);
     SaveGameManager.Save();
 }
    // -------------------------------------------------------------------------------

    public override void OnInspectorGUI()
    {
        SaveGameManager saveGameManager = (SaveGameManager)target;

        DrawDefaultInspector();

        if (Application.isPlaying)
        {
            if (GUILayout.Button("Save Game"))
            {
                saveGameManager.Save();
            }

            if (GUILayout.Button("Reset Save Game"))
            {
                saveGameManager.ResetSaveGame();
            }
        }
    }
    static public void AddScore(int num)
    {
        // Find the ScoreGT Text field only once.
        if (SCORE_GT == null)
        {
            GameObject go = GameObject.Find("ScoreGT");
            if (go != null)
            {
                SCORE_GT = go.GetComponent <Text>();
            }
            else
            {
                Debug.LogError("Warpaid:AddScore() - Could not find a GameObject named ScoreGT.");
                return;
            }
            SCORE = 0;
        }
        // SCORE holds the definitive score for the game.
        SCORE += num;

        if (!GOT_HIGH_SCORE)
        {
            // We just got the high score
            GOT_HIGH_SCORE = true;

            // Announce it using the AchievementPopUp
            AchievementPopUp.ShowPopUp("High Score!", "You've achieved a new high score.");

            // save this fact
            SaveGameManager.Save();
        }

        SCORE_GT.text = SCORE.ToString("N0");


        // Notify the AchievementManager that this has happened
        AchievementManager.AchievementStep(Achievement.eStepType.scoreAttained, SCORE);
    }
 void OnApplicationQuit()
 {
     //Debug.Log("Application ending after " + Time.time + " seconds");
     scanforPoop();
     SaveGameManager.Save(save);
 }
 public void SaveGame()
 {
     // need to create reminder button here save/cancel ("hey, this is early-access now, so it has only one available slot for saving and loading")
     SaveGameManager.Save();
 }
Exemple #13
0
 static public void GameOver()
 {
     SaveGameManager.CheckHighScore(SCORE);
     SaveGameManager.Save();
     _S.EndGame();
 }
Exemple #14
0
    //decided I'd try to only run this on an event(aka when the value changed) so after I add the value
    //I just call it on the script I added it from. plan on making methods later to make it simpler.
    /// <summary>
    /// make sure to call this after changing variables
    /// </summary>
    public static void AchievementCheck()
    {
        if (SaveGameManager.CheckHighScore(SCORE) && !_S._newHighScore)
        {
            _S._newHighScore = true;
            AchievementSettings highScoreSettings = new AchievementSettings();
            highScoreSettings.title       = _S.highScoreTitle;
            highScoreSettings.description = _S.highScoreDescription;
            highScoreSettings.count       = SCORE;
            _S._settingsQueue.Enqueue(highScoreSettings);
            UIScript.SetGameOverText("HIGH SCORE!");
        }
        foreach (AchievementSettings setting in _S.settings)
        {
            switch ((int)setting.achievementType)
            {
            case 0:                    //LuckyShot
                if (BULLET_WRAP_COUNT >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 1:                    //AsteroidHitCount
                if (ASTEROIDS_HIT >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 2:                    //BulletsFired
                if (BULLETS_FIRED >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 3:                    //Points
                if (SCORE >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 4:                    //LevelsComplete
                if (AsteraX.GetLevel() >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            default:
                break;
            }

            UIScript.UnlockToggleFromAchievement(setting);
        }
        SaveGameManager.Save();
    }
Exemple #15
0
 public void Save()
 {
     audioSource.Play();
     SaveGameManager.Save(GameManager._instance.CurrentLevel);
 }