Пример #1
0
    public void SaveCompletion(int score)
    {
        String currentLevel = SceneManager.GetActiveScene().name;
        bool   InBoss       = currentLevel.Contains("3");
        int    index;

        if (InBoss)
        {
            if (currentLevel.Contains("3-3"))
            {
                index = 3;
            }
            else
            {
                return;
            }
        }
        index = Int32.Parse(currentLevel.Substring(currentLevel.Length - 1));
        LevelProgress progress = currentSave.levels[index - 1];

        progress.completed = true;
        progress.score     = (progress.score >= score) ? progress.score : score;
        Save();
        DebugCurrentProgress(currentSave);
    }
Пример #2
0
 void StartLevel()
 {
     CurrentLevelObject = Instantiate(Levels[0]) as GameObject;
     ActiveObj          = Levels[0];
     CurrentLevel       = CurrentLevelObject.GetComponent <LevelProgress>();;
     ResetPlayer();
 }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <CharacterBehaviour>() == null)
        {
            other.gameObject.SetActive(false);
            GameEnums.LevelName levelName     = other.transform.parent.GetComponent <PatientOnHospitalBehaviour>().LevelName;
            LevelProgress       levelProgress = SaveManager.GetLevelProgress(levelName);
            if (levelProgress != null)
            {
                levelProgress.patientLeftBed = true;
                SaveManager.SaveProgressFile();
            }
            else
            {
                Debug.LogError("no save file");
            }
        }

        // finish game
        if (SaveManager.GetLevelProgress(GameEnums.LevelName.Dog) != null && SaveManager.GetLevelProgress(GameEnums.LevelName.Dog).patientLeftBed)
        {
            if (SaveManager.GetLevelProgress(GameEnums.LevelName.Robot) != null && SaveManager.GetLevelProgress(GameEnums.LevelName.Robot).patientLeftBed)
            {
                if (SaveManager.GetLevelProgress(GameEnums.LevelName.Night) != null && SaveManager.GetLevelProgress(GameEnums.LevelName.Night).patientLeftBed)
                {
                    OpenVictoryCanvas();
                }
            }
        }
    }
Пример #4
0
    public void MarkCurrentLevelComplete()
    {
        LevelProgress levelProgress = gameProgress[currentWorldIndex][currentLevelIndex];

        levelProgress.passed = true;
        WriteToSaveData(levelProgress.levelUID, (s) => s.passed = true);



        // unlock next level
        if (currentLevelIndex == levelCounts[currentWorldIndex] - 1)  // final level in world, unlock next world
        {
            if (currentWorldIndex == worldCount - 1)
            {
                gameBeaten = true;
            }
            else
            {
                worldsUnlocked[currentWorldIndex + 1] = true;
                LevelProgress firstLevelNextWorldProgress = gameProgress[currentWorldIndex + 1][1];
                firstLevelNextWorldProgress.unlocked = true;

                WriteToSaveData(firstLevelNextWorldProgress.levelUID, (s) => s.unlocked = true);
            }
        }

        LevelProgress nextLevelProgress = gameProgress[currentWorldIndex][currentLevelIndex + 1];

        nextLevelProgress.unlocked = true;
        WriteToSaveData(nextLevelProgress.levelUID, (s) => s.unlocked = true);
        SaveToFile();
    }
Пример #5
0
    public GameObject GetGridElement(Level levelMap, LevelProgress levelProgress, List <Level> levelMaps, LevelProgressListWrapper levelProgresses, Vector3 position)
    {
        if (levelMap.IsAllwaysUnlocked || MainMenu.GetIsSchoolVersion())
        {
            return(Instantiate(PrefabSelectable, position, PrefabSelectable.transform.rotation) as GameObject);
        }
        if (!MainMenu.GetIsFreeWorld() && !MainMenu.IsFullVersion())
        {
            return(Instantiate(PrefabBuy, position, PrefabSelectable.transform.rotation) as GameObject);
        }
        if (levelProgress.IsCompleted)
        {
            return(Instantiate(PrefabSelectable, position, PrefabSelectable.transform.rotation) as GameObject);
        }
        if (levelProgress.IsUnLocked)
        {
            return(Instantiate(PrefabSelectable, position, PrefabSelectable.transform.rotation) as GameObject);
        }
        var levelsThatAreCompleted = levelProgresses.LevelProgress.Where(x => x.IsCompleted);

        if (levelsThatAreCompleted != null && levelsThatAreCompleted.Any())
        {
            if (levelMaps.Any(x => x.UnlocksLevels != null && x.UnlocksLevels.Any(s => s == levelProgress.LevelName) && levelsThatAreCompleted.Any(v => v.LevelName == x.FileName)))
            {
                return(Instantiate(PrefabSelectable, position, PrefabSelectable.transform.rotation) as GameObject);
            }
        }

        return(Instantiate(PrefabLoced, position, PrefabSelectable.transform.rotation) as GameObject);
    }
Пример #6
0
 public void Construct(LevelProgress level, Vector3 spawnPos, PathCreator path)
 {
     speed = level.Speed;
     transform.position       = spawnPos;
     pathFollower.pathCreator = path;
     wordsAmount = (int)level.PlaneTypes;
 }
    public static LevelProgress FromString(string s)
    {
        LevelProgress lp = new LevelProgress();

        lp.SetFromString(s);
        return(lp);
    }
Пример #8
0
 public static void UpdateLevelIpisMaxCount(LevelProgress currentLevel)
 {
     if (currentLevel.FinishedCount == 0 || currentLevel.FinishedCount < finishedIpis)
     {
         currentLevel.FinishedCount = finishedIpis;
     }
 }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        if (PooProgress != null)
        {
            if (PooProgress.PooPercentageComplete() > 1f)  // 100% //1.3f)
            {
                if (player != null)
                {
                    player.ShitPants();
                }
                //LoadLosingScene();
            }
        }

        if (LevelProgress != null && gameDirection == Direction.RIGHT)
        {
            if (LevelProgress.ProgressPercentage() >= 1.0f)
            {
                LoadStoreScene();
            }
        }

        if (LevelProgress != null && gameDirection == Direction.LEFT)
        {
            if (LevelProgress.ProgressPercentage() >= 1.0f)
            {
                LoadWinScene();
            }
        }
    }
    private void Start()
    {
        LevelProgress lp = SaveManager.GetLevelProgress(levelName);

        if (lp != null)
        {
            if (lp.patientLeftBed)
            {
                SetActive(false);
                _zzz.SetActive(false);
                this.GetComponent <MeshRenderer>().enabled = false;
                this.GetComponent <BoxCollider>().enabled  = false;
                _patientModel.SetActive(false);
                return;
            }
            else if (lp.levelConcluded)
            {
                this.GetComponent <MeshRenderer>().enabled = false;
                this.GetComponent <BoxCollider>().enabled  = false;
                SetActive(false);
                _zzz.SetActive(false);
                _patientModel.SetActive(true);
                _patientModel.GetComponent <Animator>().SetBool("isScared", false);
                _patientModel.GetComponent <Animator>().SetBool("isWalking", true);
                _patientModel.GetComponent <NavMeshAgent>().updateRotation = true;
                StartCoroutine(WaitToGoAway(1.5f));
            }
        }
    }
Пример #11
0
    public void Update()
    {
        BossLevelTextMesh.text = BossLevel.ToString();
        if (CurrentProgress != LevelProgress.GatekeeperDefeated && Phase1DestroyedCount >= 2)
        {
            EventQueue.Instance.WaitABit(2f);
            EventQueue.Instance.AddAction(() => { Phase1Door.GetComponent <SmoothMoveToPosition>().enabled = true; });
            EventQueue.Instance.AddFocusEvent(Phase1Door, 3, FocusMode.Slide);
            EventQueue.Instance.AddQuickInfoPanel(LocalizationManager.Instance.GetLocalizedValue("SomethingChanged"), 2);

            Phase1DestroyedCount = 0;
            CurrentProgress      = LevelProgress.GatekeeperDefeated;

            //Play sound effect
        }

        /*
         * if(Input.GetKeyDown(KeyCode.P))
         * {
         *  GameManager.Instance.SpawnHealthPotion();
         * }
         */

        if (CurrentProgress == LevelProgress.BossDefeated)
        {
            //You won!
            GameManager.Instance.Gold += 200 * BossLevel;
        }
    }
Пример #12
0
    public OverallProgress CreateRandomSave()
    {
        string saveName = "Atticus";

        string[] files = GetFilePaths();
        while (StringInFileList(saveName, files))
        {
            saveName = RandomString(8);
        }
        OverallProgress p = new OverallProgress();

        p.saveName = saveName;
        LevelProgress level1 = new LevelProgress();
        LevelProgress level2 = new LevelProgress();
        LevelProgress level3 = new LevelProgress();

        level1.level = 1;
        level2.level = 2;
        level3.level = 3;
        p.levels     = new LevelProgress[3];
        p.levels[0]  = level1;
        p.levels[1]  = level2;
        p.levels[2]  = level3;

        return(p);
    }
Пример #13
0
 public static int GetLevelStarCount(LevelProgress levelProgress, Level levelMap)
 {
     if (levelProgress.IsCompleted)
     {
         return(GetLevelStarCount(levelMap, levelProgress.FinishedCount));
     }
     return(0);
 }
Пример #14
0
    public UserData()
    {
        _data          = new GameData();
        _levelProgress = new LevelProgress();

        LoadData();
        LoadLevelProgress();
    }
Пример #15
0
 //The beginning of the game
 void OnEnterIdle()
 {
     if (!isStartFocusAnimationPlayed)
     {
         EventQueue.Instance.AddFocusEvent(Phase1Door, 3, FocusMode.Static);
         CurrentProgress             = LevelProgress.Started;
         isStartFocusAnimationPlayed = true;
     }
 }
Пример #16
0
 public LevelData(LevelProgress levelProgress)
 {
     id = levelProgress.levelId;
     hasShownDescription = true;
     isStarted           = true;
     isCompleted         = levelProgress.isCompleted;
     mainCode            = levelProgress.mainCode;
     codeLineCount       = levelProgress.codeLineCount;
 }
Пример #17
0
 public LevelData(LevelProgress levelProgress)
 {
     Id = levelProgress.levelId;
     HasShownDescription = true;
     IsStarted           = true;
     IsCompleted         = levelProgress.isCompleted;
     MainCode            = levelProgress.mainCode;
     CodeLineCount       = levelProgress.codeLineCount;
 }
Пример #18
0
 // Start is called before the first frame update
 void Start()
 {
     __sr    = GetComponent <SpriteRenderer>();
     __stage = GetComponent <Stage>();
     if (!!__sr && __stage)
     {
         __sr.sprite = LevelProgress.getCompletion(__stage.level_to_load, __stage.stage_to_load) ? stage_done : stage_undone;
     }
 }
Пример #19
0
 void Start()
 {
     FindTexts();
     levels         = Stats.sharedInstance.input.levels;
     sharedInstance = this;
     //Store health of last level ahead of time
     //to use it for random level generation.
     lastTotalHealth = TotalHealth(4);
 }
 public GameProgress () {
     mProgress = new LevelProgress[LevelCount];
     int i;
     for (i = 0; i < LevelCount; i++) {
         mProgress[i] = new LevelProgress();
     }
     for (i = 0; i < LevelCount; i++) {
         mPilotStats[i] = new PilotStats(i);
     }
 }
Пример #21
0
 void Awake()
 {
     if (progress == null) {
         DontDestroyOnLoad(gameObject);
         progress = this;
         load();
     } else if (progress != this) {
         Destroy(gameObject);
     }
 }
Пример #22
0
    public void Start()
    {
        CurrentProgress = LevelProgress.Started;
        GameManager.Instance.OnEnterIdleState += OnEnterIdle;

        if (IsStartAtSpawnPoint2)
        {
            GameManager.Instance.GetPartyLeader().GetComponent <Respawn>().RespawnAllAtSpawnPoint(PhaseTwoSpawnPoint);
        }
    }
Пример #23
0
 void Start()
 {
     if (GrayIfBeaten && LevelProgress.GetInstance().IsLevelBeaten(LevelName))
     {
         GameObject checkmark = Instantiate(checkMarkPrefab, transform);
         checkmark.transform.parent     = transform;
         checkmark.transform.position   = checkmark.transform.position - new Vector3(0, 5f, 0);
         checkmark.transform.localScale = new Vector3(.25f, .25f, .25f);
     }
 }
Пример #24
0
    // Loads level progresses from disk


    // Adds the level progress given to the list of level progress. Replaces old progress if appliicable.
    public void SaveLevelProgress(LevelProgress newLevelProgress)
    {
        var matchingLevelSave = levelProgresses.Find(x => x.levelID == newLevelProgress.levelID);

        if (matchingLevelSave != null)
        {
            levelProgresses.Remove(matchingLevelSave);
        }

        levelProgresses.Add(newLevelProgress);
    }
Пример #25
0
    public void updateCompletionFromLevelProgress()
    {
        bool stage_done = LevelProgress.getCompletion(level_to_load, stage_to_load);

        if (stage_done)
        {
            // unlock neighbors
            __completion_status = COMPLETION.DONE;
            unlock_neighbors();
        }
    }
Пример #26
0
    // Returns if the given moon has been collected on the given level
    public bool HasMoonBeenCollected(int levelID, int moonID)
    {
        LevelProgress levelProgress = levelProgresses.Find(x => x.levelID == levelID);

        if (levelProgress != null)
        {
            CollectableMoonData moon = levelProgress.collectableMoonData.Find(x => x.moonID == moonID);
            return(moon.isCollected);
        }
        return(false);
    }
Пример #27
0
        private IEnumerator LoadLevelSequence(LevelInfo levelInfo)
        {
            SoundManager.PlaySound(_sfxStartLevel);
            LevelProgress.CreateNewProgressData(levelInfo.DisplayName, levelInfo.SceneName, levelInfo.LevelRewards, levelInfo.HighestWaveDefeated);
            Save();
            Debug.Log("--- Overworld: Exit ---");

            yield return(new WaitForSeconds(_screenFader.FadeOut()));

            SceneManager.LoadScene(levelInfo.SceneName);
        }
Пример #28
0
    public void Complete()
    {
        if (LevelProgress == null)
        {
            return;
        }

        LevelProgress.Complete(Time);
        LevelProgress.Save();

        Pix.Game.GetInstance().ReportScores();
    }
 void Awake()
 {
     if (lP == null)
     {
         lP = this;
         DontDestroyOnLoad(this);
     }
     else if (this != lP)
     {
         Destroy(gameObject);
     }
 }
Пример #30
0
        // Update the player's progress based on the level they just played
        private void UpdateGameProgress()
        {
            Debug.Log("--- Overworld : Update Game Progress ---");

            // Fade in the camera
            _screenFader.FadeIn();

            // Center the camera on the player's base (is overriden later if levelInfo is loaded)
            _cameraController.SetCameraPosition(_playerBase.position);

            // No level progress data was found
            var levelProgressData = LevelProgress.Data;

            if (levelProgressData == null)
            {
                return;
            }

            // No level info data was found
            var levelInfo = GetLevelInfoBySceneName(levelProgressData.SceneName);

            if (levelInfo == null)
            {
                return;
            }

            // Set the level as 'Complete' if it was passed and was not previously finished
            if (levelProgressData.LevelPassed && levelInfo.LevelState == LevelState.Unlocked)
            {
                levelInfo.CompleteLevel();
            }

            // Add any item rewards
            RewardItems(levelProgressData, levelInfo);

            // Add resource rewards
            ItemProgress.AddResources(levelProgressData.Resources);

            // Update tower lifetime stats
            TowerProgress.UpdateTowerLifetimeStats(levelProgressData.TowerStats);

            // Update highest level defeated
            levelInfo.UpdateHighestWaveDefeated(levelProgressData.WavesDefeated);

            // Open the level finished window
            _windowLevelFinished.WindowOpen(levelProgressData);

            // Set the camera to the location of the level on the map
            _cameraController.SetCameraPosition(levelInfo.transform.position);

            // Reset the progress data after it has been used
            LevelProgress.ResetLevelProgress();
        }
 public bool MergeWith(LevelProgress other) {
     bool modified = false;
     if (other.mScore > mScore) {
         mScore = other.mScore;
         modified = true;
     }
     if (other.mStars > mStars) {
         mStars = other.mStars;
         modified = true;
     }
     return modified;
 }
Пример #32
0
 void Awake()
 {
     if (progress == null)
     {
         DontDestroyOnLoad(gameObject);
         progress = this;
         load();
     }
     else if (progress != this)
     {
         Destroy(gameObject);
     }
 }
Пример #33
0
    // Use this for initialization
    void Awake()
    {
        if (LP)
        {
            DestroyImmediate(gameObject);
        }

        else
        {
            DontDestroyOnLoad(gameObject);
            LP = this;
        }
    }
 public static LevelProgress FromString(string s) {
     LevelProgress lp = new LevelProgress();
     lp.SetFromString(s);
     return lp;
 }