Esempio n. 1
0
    void StartLevel()
    {
        int l;

        l = GameManager.player.level;
        LevelManager.Stage stage;
        if (l < LevelManager.stages.stages.Count)
        {
            stage = LevelManager.stages.stages[l];
        }
        else
        {
            if (l < LevelManager.stages.stages.Count * 2)
            {
                l     = l - LevelManager.stages.stages.Count;
                stage = new LevelManager.Stage()
                {
                    id         = l + LevelManager.stages.stages.Count,
                    sheeps     = LevelManager.stages.stages[l].sheeps,
                    size       = LevelManager.stages.stages[l].size,
                    precents   = LevelManager.stages.stages[l].precents,
                    lifes      = LevelManager.stages.stages[l].lifes,
                    startTime  = LevelManager.stages.stages[l].startTime - (LevelManager.stages.stages[l].startTime / 3),
                    speedShips = LevelManager.stages.stages[l].speedShips,
                    kBonus     = LevelManager.stages.stages[l].kBonus,
                    kTime      = LevelManager.stages.stages[l].kTime - (LevelManager.stages.stages[l].kTime / 3),
                    kSpeed     = LevelManager.stages.stages[l].kSpeed - (LevelManager.stages.stages[l].kSpeed / 3)
                };
            }
            else
            {
                stage = LevelManager.lastLevel.stage;
            }
        }
        for (int i = 0; i < stage.sheeps.Count; i++)
        {
            MainGeneration.Ship ship = new MainGeneration.Ship(
                stage.sheeps[i],
                stage.precents[i],
                stage.speedShips[i],
                stage.lifes[i]);
            generate.enemies.Add(ship);
        }
        Dictionary <Bonus, int> d = new Dictionary <Bonus, int>();

        foreach (var i in bonuses.Keys)
        {
            d.Add(i, bonuses[i]);
        }
        foreach (var i in d)
        {
            if (i.Key.GetType() != typeof(BonusWeapon))
            {
                Debug.Log(i.Key.name);
                bonuses[i.Key] = (int)Mathf.Round(i.Value * stage.kBonus);
            }
        }
        sizeLevel            = stage.size;
        generate.k           = stage.kTime;
        generate.kSpeed      = stage.kSpeed;
        generate.avengerTime = stage.startTime;
        if (entityPlayer)
        {
            Destroy(entityPlayer.gameObject);
        }
        entityPlayer          = Instantiate(GameManager.skins[GameManager.player.pack][GameManager.player.skins].prefab, Camera.main.transform).GetComponent <Entity>();
        entityPlayer.position = Vector2.zero;
        hud.StartLevel(stage.id);
    }