Exemple #1
0
    private void UpdatePhase2()
    {
        switch (Phase2CurrentAttack)
        {
        case Phase2Attack.GlassStart:
            GlassStartTimePassed += Time.deltaTime;
            GlassSprite.color     = new Color(
                GlassSprite.color.r, GlassSprite.color.g, GlassSprite.color.b,
                Mathf.Lerp(0, 0.5f, GlassStartTimePassed / GlassStartDuration));
            if (GlassStartTimePassed >= GlassStartDuration)
            {
                Phase2CurrentAttack = Phase2Attack.MonsterAttack;
            }
            break;

        case Phase2Attack.MonsterAttack:
            Phase2TimeToMonsterSpawn -= Time.deltaTime;
            if (Phase2TimeToMonsterSpawn <= 0)
            {
                // Choosing spawn zone
                SpawnZoneScript spawnZone = null;
                var             dice      = Random.Range(-1.0f, 1.0f); // -1 or 0
                spawnZone = dice < 0 ? leftSpawnZone : rightSpawnZone;
                monsterSpawner.SpawnZone = spawnZone;

                Phase2TimeToMonsterSpawn = Phase2TimeToEachMonsterSpawn;
                if (Phase2SpawnIndex < Phase2Monsters.Length)
                {
                    var monsterToSpawn = Phase2Monsters[Phase2SpawnIndex];
                    var enemy          = monsterSpawner.SpawnCertainMonsterWithoutName(monsterToSpawn);
                    enemy.GetComponent <MonsterLife>().FadeIn(0.3f);
                }
                else
                {
                    Phase2CurrentAttack = Phase2Attack.GlassFade;
                    GlassFadeOutPassed  = 0;
                }
                Phase2SpawnIndex++;
            }
            break;

        case Phase2Attack.GlassFade:
            GlassFadeOutPassed += Time.deltaTime;
            if (GlassFadeOutPassed < GlassFadeOutDuration)
            {
                GlassSprite.color = new Color(
                    GlassSprite.color.r, GlassSprite.color.g, GlassSprite.color.b,
                    Mathf.Lerp(0.5f, 1, GlassFadeOutPassed / GlassFadeOutDuration));
            }

            if (GlassFadeOutPassed / GlassFadeOutDuration > 1)
            {
                StartPhase4();
            }
            break;

        default:
            break;
        }
    }
Exemple #2
0
    void Awake()
    {
        InitializeFields();

        roomLighting     = GetComponent <RoomLighting>();
        scenesController = GetComponent <RelodScene>();
        isPointVictory   = scenesController.isPointVictory;

        // Get reference for UI current enemy name
        currentEnemy = GetComponent <CurrentEnemy>();
        GameObject SpawnSquare = GameObject.FindGameObjectWithTag("SpawnZone");

        if (SpawnSquare)
        {
            SpawnZone = SpawnSquare.GetComponent <SpawnZoneScript>();
        }

        currentEvilDictionary = evilDictionary.EvilNames.OrderBy(a => Random.Range(0, 10000)).ToList();
        randomSequence        = GenerateRandom(currentEvilDictionary.Count / 2, currentEvilDictionary.Count - 1);
    }