예제 #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;
        }
    }
예제 #2
0
 private void StartPhase2()
 {
     CurrentPhase = Phase.PHASE2;
     BossInstance.SetActive(false);
     print(BossInstance.name);
     Phase2CurrentAttack  = Phase2Attack.GlassStart;
     GlassStartTimePassed = 0;
     monsterSpawner       = GetComponent <ArenaEnemySpawner>();
 }