Esempio n. 1
0
 protected override void OnRabitHit(HeroRabit rabit)
 {
     if (level == 1 || LevelStatistic.load(level - 1).levelPassed)
     {
         SceneManager.LoadScene("Level" + level);
     }
 }
Esempio n. 2
0
    // 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);
        }
    }
Esempio n. 3
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;
            }
        }
    }
Esempio n. 4
0
    void Start()
    {
        LevelStatistic stats = LevelStatistic.load(LevelController.current.level);

        collectedCrystals = new HashSet <Crystal.Type> ();
        foreach (Crystal.Type type in stats.collectedCrystals)
        {
            addCrystal(type);
        }
    }
Esempio n. 5
0
    // 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();
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    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;
        }
    }
Esempio n. 8
0
    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();
    }
Esempio n. 9
0
    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);
    }
Esempio n. 10
0
    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>();
    }
Esempio n. 11
0
    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();
    }