protected override void OnRabitHit(HeroRabit rabit) { if (level == 1 || LevelStatistic.load(level - 1).levelPassed) { SceneManager.LoadScene("Level" + level); } }
// Use this for initialization void Start() { LevelStatistic stats = LevelStatistic.load(level); if (level == 1 || LevelStatistic.load(level - 1).levelPassed) { Destroy(doorLock); } if (!stats.levelPassed) { Destroy(check); } if (stats.allFruitsCollected) { SpriteRenderer fruitRenderer = fruit.GetComponent <SpriteRenderer>(); fruitRenderer.sprite = fruitFilled; } if (stats.allCrystalsCollected) { SpriteRenderer crystalRenderer = crystal.GetComponent <SpriteRenderer>(); crystalRenderer.sprite = crystalFilled; crystalRenderer.transform.localScale -= new Vector3(1.31f, 1.32f, 0); } }
public void setStats(LevelStatistic stats) { labelFruit = fruitLabel.GetComponent <UILabel>(); labelFruit.text = stats.collectedFruits.Count + "/" + stats.totalFruits; List <Crystal.Type> crystalColors = stats.collectedCrystals; for (int i = 0; i < crystalColors.Count; i++) { switch (crystalColors[i]) { case Crystal.Type.BLUE: blueCrystal.sprite2D = CrystalController.current.blueCrystalSprite; break; case Crystal.Type.RED: redCrystal.sprite2D = CrystalController.current.redCrystalSprite; break; case Crystal.Type.GREEN: greenCrystal.sprite2D = CrystalController.current.greenCrystalSprite; break; } } }
void Start() { LevelStatistic stats = LevelStatistic.load(LevelController.current.level); collectedCrystals = new HashSet <Crystal.Type> (); foreach (Crystal.Type type in stats.collectedCrystals) { addCrystal(type); } }
// Use this for initialization void Start() { LevelStatistic stats = LevelStatistic.load(LevelController.current.level); collectedFruits = new HashSet <int>(stats.collectedFruits); Fruit[] allFruits = GameObject.FindObjectsOfType <Fruit>(); this.totalFruits = allFruits.Length; totalFruitsLabel.text = totalFruits.ToString(); }
public static LevelStatistic load(int level) { GameStatistics stats = GameStatistics.load(); int tempLevel = level; LevelStatistic found = stats.levelStats.Find(p => p.level == tempLevel); found = found != null ? found : new LevelStatistic { level = tempLevel }; found.collectedCoins = stats.collectedCoins; return(found); }
void Start() { LevelStatistic stats = LevelStatistic.load(LevelController.current.level); isCollected = stats.collectedCrystals.Contains(type); if (isCollected) { SpriteRenderer sr = this.GetComponent <SpriteRenderer>(); Color tmp = sr.color; tmp.a = 0.5f; sr.color = tmp; } }
public void save() { GameStatistics stats = GameStatistics.load(); LevelStatistic found = stats.levelStats.Find(p => p.level == level); if (found != null) { stats.levelStats.Remove(found); } stats.levelStats.Add(this); stats.collectedCoins = collectedCoins; stats.save(); }
public LevelStatistic getStats() { LevelStatistic stats = new LevelStatistic { level = level, levelPassed = true, collectedFruits = new List <int>(FruitController.current.collectedFruits), totalFruits = FruitController.current.totalFruits, allFruitsCollected = FruitController.current.collectedFruits.Count >= FruitController.current.totalFruits, collectedCrystals = new List <Crystal.Type>(CrystalController.current.collectedCrystals), allCrystalsCollected = CrystalController.current.collectedCrystals.Count >= 3, collectedCoins = coins }; return(stats); }
void Init() { // Find Player Player = GameObject.FindObjectOfType <Player>(); // Find Parallax Parallax = GameObject.FindObjectOfType <ParallaxController>(); // Find UI UI = GameObject.FindObjectOfType <UI>(); // Create Level Statistic LevelStatistic = new LevelStatistic(); // Create InputController GameObject inputControllerGo = new GameObject("__InputController__"); inputControllerGo.transform.parent = transform; InputController = inputControllerGo.AddComponent <InputController>(); }
protected override void OnRabitHit(HeroRabit rabit) { GameObject parent = UICamera.first.transform.parent.gameObject; GameObject obj = NGUITools.AddChild(parent, winPopUpPrefab); WinPopUp winPopUp = obj.GetComponent <WinPopUp>(); LevelStatistic stats = LevelController.current.getStats(); foreach (int f in stats.collectedFruits) { Debug.Log(f); } winPopUp.setStats(stats); Destroy(HeroRabit.lastRabit); stats.save(); }