Beispiel #1
0
    public static void UpdateHard(int score, float time, string path)
    {
        LevelDataController i = LevelDataController.Load(path);

        foreach (Level level in i.levels)
        {
            if (level.name.Equals("hard"))
            {
                if (score < 0)
                {
                    score = 0;
                }

                level.frequency = level.frequency + 1;

                if (level.highestScore < score)
                {
                    level.highestScore = score;
                }

                if (level.shortestDuration > time)
                {
                    level.shortestDuration = time;
                }

                level.addTimeData((int)time);
                level.addScoreData(score);
                level.addDateData(DateTime.Now);
            }
        }

        i.Save(path);
    }
 private void Awake()
 {
     if (Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Beispiel #3
0
 static void LoadLevelData()
 {
     levelDataController = new LevelDataController();
     levelDataController.LoadLevelData();
 }
 private void Awake()
 {
     BluetoothManager.Instance.MountToLevel(this);
     levelData = GetComponent <LevelDataController>();
 }
Beispiel #5
0
    public void showResult()
    {
        audioCotroll.playInfoSound();

        LevelDataController i = LevelDataController.Load(path);

        int k = 0;

        foreach (Level level in i.levels)
        {
            if (level.name.Equals("easy"))
            {
                easyTime  = level.getTimeInArray();
                easyScore = level.getScoreInArray();
                easyDate  = level.getDateInArray();
            }

            if (level.name.Equals("normal"))
            {
                normalTime  = level.getTimeInArray();
                normalScore = level.getScoreInArray();
                normalDate  = level.getDateInArray();
            }

            if (level.name.Equals("hard"))
            {
                hardTime  = level.getTimeInArray();
                hardScore = level.getScoreInArray();
                hardDate  = level.getDateInArray();
            }


            Data [k].text = level.frequency.ToString();
            k++;

            float time;
            int   minutes;
            int   seconds;

            if (level.frequency == 0)
            {
                Data [k].text = " - ";
                k++;

                time          = 0f;
                Data [k].text = " - ";
            }
            else
            {
                Data [k].text = level.highestScore.ToString();
                k++;

                time    = level.shortestDuration;
                minutes = (int)time / 60;
                seconds = (int)time % 60;

                Data [k].text = string.Format("{0:00} : {1:00}", minutes, seconds);
            }
            k++;
        }

        pastResult.SetActive(true);

        if (File.Exists(path))
        {
            FileEncrypt.encrypt(path);
        }
    }
Beispiel #6
0
    private void Awake()
    {
        GameObject levelsHolder = GameObject.Find("LevelZones");
        int        currentLevel = PlayerPrefs.GetInt("GameLevel");

        LevelDataController.LevelData currentLevelData = LevelDataController.GetLevelData(currentLevel);
        for (int i = 0; i < levelsHolder.transform.childCount; i++)
        {
            levelsHolder.transform.GetChild(i).gameObject.SetActive(false);
        }
        levelsHolder.transform.GetChild(currentLevel).gameObject.SetActive(true);
        GameObject    currentLevelHolder   = levelsHolder.transform.GetChild(currentLevel).gameObject;
        PlayableLevel currentPlayableLevel = currentLevelHolder.GetComponent <PlayableLevel>();

        currentPlayableLevel.Initialize();
        LineRendererPool lineRendererPool = FindObjectOfType <LineRendererPool>();

        PlayerController playerController = FindObjectOfType <PlayerController>();

        playerController.SetPlayerPath(currentLevelHolder.transform.GetChild(1).GetComponent <BezierSpline>());
        playerController.Orient();
        Weapon currentWeapon = Instantiate(Resources.Load <GameObject>("Prefabs/Weapons/" + currentLevelData._primaryWeaponCategory.ToString()), playerController.GetWeaponPivot()).GetComponent <Weapon>();

        currentWeapon.SetLineRendererPool(lineRendererPool);
        WeaponProjectilesRetriever weaponProjectilesRetriever = FindObjectOfType <WeaponProjectilesRetriever>();

        weaponProjectilesRetriever.SetWeapon(currentWeapon);
        playerController.SetWeapon(currentWeapon);
        playerController.gameObject.SetActive(false);
        InGameController _inGameController = FindObjectOfType <InGameController>();

        FindObjectOfType <HPBarBehaviour>().SetPlayerController(playerController);
        _inGameController._player = playerController.gameObject;
        FindObjectOfType <ShootButtonBehaviour>().SetPlayer(playerController);
        currentPlayableLevel.SetPlayerController(playerController);
        //Añado la recarga al botón de recarga
        GameObject.Find("ReloadButton").GetComponent <Button>().onClick.AddListener(() => playerController.Reload());
        currentWeapon.SetVfxBloodPool(GameObject.Find("VFXBloodPool").GetComponent <VFXPool>());
        //Asigno valores a la camara
        BezierSpline cameraPath = currentLevelHolder.transform.GetChild(2).GetComponent <BezierSpline>();
        CinematicCameraController cinematicCameraController = FindObjectOfType <CinematicCameraController>();

        cinematicCameraController.SetPath(cameraPath);

        //Creo los enemigos
        EnemySpawner[] enemySpawners = currentLevelHolder.GetComponentsInChildren <EnemySpawner>();
        foreach (EnemySpawner e in enemySpawners)
        {
            EnemyController enemyController   = null;
            GameObject      instantiatedEnemy = null;
            switch (e.GetEnemyType())
            {
            case EnemyType.Zombie:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Zombie"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.WalkingNightmare:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_WalkingNightmare"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.CrawlingNightmare:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_CrawlingNightmare"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Troll:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Troll"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Explosive:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Explosive"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Spitter:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Spitter"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Bat:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Bat"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.SkeletonZombie:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_SkeletonZombie"), e.transform.position, Quaternion.identity);
                break;
            }
            enemyController = instantiatedEnemy.GetComponent <EnemyController>();
            enemyController.SetPath(e.GetComponent <BezierSpline>());
            enemyController.SetMaxHp(e._maxHP);
            enemyController.SetCurrentHP(e._maxHP);
            enemyController.SetDamage(e._damage);
            enemyController.SetChaseIndex(e._chaseIndex);
            enemyController.SetChaseSpeed(e._speed * (1 + e.animationSpeedOffset));
            enemyController.SetChaseAnimationSpeedOffset(1 + e.animationSpeedOffset);
            enemyController.SetSkin(e._skin);
            enemyController.Orient();
            enemyController.SetPlayerController(playerController);
            if (!e._preInstantiate)
            {
                instantiatedEnemy.SetActive(false);
            }
            currentPlayableLevel._enemyControllers.Add(enemyController);
        }
    }