Example #1
0
    IEnumerator SummonAdds(int addCount)
    {
        phase  = BossPhases.adds;
        disVal = sprite.material.GetFloat("_Dissolve");

        sprite.material = immuneMat;
        gameObject.tag  = "Untagged";
        haveAdds        = true;

        for (int i = 0; i < addCount; i++)
        {
            Vector2    spawnPos = EnemyHandler.waypoint;
            GameObject add      = Instantiate(Add, spawnPos, Quaternion.identity);
            add.GetComponent <BossAdd>().boss = this;
            activeAdds.Add(add);
        }
        do
        {
            stats.immune = true;

            yield return(new WaitForSeconds(0.1f));
        } while (activeAdds.Count > 0);

        stats.immune = false;
        phase        = BossPhases.patrol;
        ChangeInfo(false);
        haveAdds = false;
    }
 public BossPatternTrigger(BossPhases TargetPhase, BossPhases PhaseChange, BossPhaseTriggerType Trigger, float Condition, string message = "")
 {
     this.TargetPhase = TargetPhase;
     this.PhaseChange = PhaseChange;
     this.Trigger     = Trigger;
     this.Condition   = Condition;
     this.message     = message;
 }
Example #3
0
    private void Update()
    {
        if (phase == BossPhases.patrol)
        {
            if (CDtimer > 0)
            {
                CDtimer -= Time.deltaTime;
            }
            else
            {
                int dice = Random.Range(0, 10);
                if (dice < 5)
                {
                    StartCoroutine(SummonAdds(3));
                    phase = BossPhases.adds;
                }
                else
                {
                    phase = BossPhases.special;
                }
                CDtimer = specialCD;
            }
            if (Vector2.Distance(transform.position, player.position) > 0.85f)
            {
                transform.Translate((player.position - transform.position).normalized * Time.deltaTime * speed);
            }
        }
        else if (phase == BossPhases.special)
        {
            if (Vector2.Distance(transform.position, center) > 1.5f)
            {
                transform.Translate((center - (Vector2)transform.position).normalized * Time.deltaTime * speed);
            }
            else
            {
                StartCoroutine("centerAbility");
            }
        }
        else if (phase == BossPhases.adds)
        {
            if (Vector2.Distance(transform.position, player.position) > 0.85f)
            {
                transform.Translate((player.position - transform.position).normalized * Time.deltaTime * speed);
            }
        }

        if (!haveAdds)
        {
            if (changeTimer > 0)
            {
                changeTimer -= Time.deltaTime;
            }
            else
            {
                ChangeInfo(true);
            }
        }
    }
Example #4
0
    private IEnumerator SetInterphase1()
    {
        currentPhase = BossPhases.Interphase1;
        yield return(new WaitForSeconds(3.8f));

        // Spawn small viruses
        virusesGroup.SetActive(true);
        virusCounter = FindObjectsOfType <Monster>().Length + 1;
        foreach (Monster virus in FindObjectsOfType <Monster>())
        {
            virus.MonsterDestroyedDelegate += MonsterDestroyed;
        }
    }
Example #5
0
    IEnumerator centerAbility()
    {
        if (castingSpecial)
        {
            yield break;
        }

        castingSpecial = true;
        specialAbility.Play();
        yield return(new WaitForSeconds(specialAbility.duration));

        phase          = BossPhases.patrol;
        castingSpecial = false;
    }
Example #6
0
 private void Update()
 {
     if (CurrentPhase == BossPhases.idle)
     {
         if (idleTimer < idleDuration)
         {
             idleTimer += Time.deltaTime;
         }
         else
         {
             CurrentPhase = BossPhases.phase1;
             leftHand.GetComponent <Boss_LeftHand>().BeginEncounter();
             rightHand.GetComponent <Boss_RightHand>().BeginEncounter();
         }
     }
 }
Example #7
0
    private void Start()
    {
        gameDone  = GameObject.Find("Gamedone").GetComponent <Canvas>();
        HealthBar = UIManager.instance.bossHealth;
        HealthBar.GetComponentInParent <Canvas>().enabled = true;
        phase  = BossPhases.patrol;
        center = GameObject.Find("StageCenter").transform.position;
        player = FindObjectOfType <PlayerMovement>().transform;
        stats  = GetComponent <EnemyStats>();
        sprite = GetComponent <SpriteRenderer>();

        canMove        = true;
        castingSpecial = false;
        haveAdds       = false;
        CDtimer        = specialCD;
        changeTimer    = changeCD;


        //ChangeInfo();
    }
Example #8
0
    private void ChangePhase(BossPhases newPhase)
    {
        // Optionnal parameter to load a specific phase
        if (newPhase != 0)
        {
            currentPhase = newPhase;
        }

        // Changes from P1 to Interphase1
        if (currentPhase == BossPhases.Interphase1)
        {
            StopAllCoroutines();
            StartCoroutine(SetInterphase1());
        }

        // Load P2
        if (currentPhase == BossPhases.Phase2)
        {
            // Show boss P2
            bossAnimator.SetTrigger("Phase2Appearing");
            // Spawn tentacles
            StartCoroutine(SetIdleTentacles());
            // Reset boss hp
            healthPoint = 10;
        }

        if (currentPhase == BossPhases.Interphase2)
        {
            // Show boss P2
            bossAnimator.SetTrigger("Phase2Appearing");
            // Spawn tentacles
            StartCoroutine(SetIdleTentacles());
            // Reset boss hp
            healthPoint = 10;
        }
    }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        if (FindObjectOfType <Player>() != null)
        {
            target = FindObjectOfType <Player>();
        }


        if (boss_state == BossState.APPEARING)
        {
            MoveToInitPos();
        }
        if (boss_phase == BossPhases.PHASE1)
        {
            rb.constraints = RigidbodyConstraints.FreezePosition;

            if (this.current_HP <= this.GetMaxHP() / 2)
            {
                State_two_Sound.Play();
                boss_phase = BossPhases.PHASE2;
            }

            if (timeBetweenStateCountdown <= 0)
            {
                if (boss_state == BossState.WAITING)
                {
                    MoveToInitPos();
                    // Start spawning wave
                    StartCoroutine(WaitingState());
                }
                if (boss_state == BossState.ATTACKING)
                {
                    if (timeBetweenShotCountdown <= 0)
                    {
                        Bang.Play();
                        Corner_Shoot();
                        timeBetweenShotCountdown = timeBetweenEachShot;
                    }
                    else
                    {
                        timeBetweenShotCountdown -= Time.deltaTime;
                    }
                }
            }
            else
            {
                timeBetweenStateCountdown -= Time.deltaTime;
            }
        }

        if (boss_phase == BossPhases.PHASE2)
        {
            rb.constraints = RigidbodyConstraints.FreezePosition;
            transform.Rotate(Vector3.up * 50 * Time.deltaTime, Space.Self);
            if (boss_state == BossState.WAITING)
            {
                //this.transform.position = new Vector3(transform.position.x + UnityEngine.Random.Range(speed * Time.deltaTime, -speed * Time.deltaTime), transform.position.y, transform.position.z);
                MoveToInitPos();
                // Start spawning wave
                StartCoroutine(WaitingState());
            }
            if (boss_state == BossState.ATTACKING)
            {
                if (timeBetweenShotCountdown <= 0)
                {
                    Bang.Play();
                    Corner_Shoot();
                    Corner_Spawn();
                    timeBetweenShotCountdown = timeBetweenEachShot;
                }
                else
                {
                    timeBetweenShotCountdown -= Time.deltaTime;
                }
            }
            if (current_HP <= 0)  // If the player has nno HP , he dies
            {
                FinalState.Play();
                this.setHP(GetMaxHP());
                boss_state = BossState.APPEARING;
                boss_phase = BossPhases.PHASE3;
            }
        }
        if (boss_phase == BossPhases.PHASE3)
        {
            mesh_renderer.material = mat_boss;
            rb.constraints         = RigidbodyConstraints.None;
            rb.constraints         = RigidbodyConstraints.FreezeRotation;
            rb.constraints         = RigidbodyConstraints.FreezePositionZ;
            transform.Rotate(Vector3.forward * rotateSpeed * Time.deltaTime, Space.Self);
            if (!onetime)
            {
                transform.localScale += new Vector3(7, 7, 7);
                onetime    = true;
                boss_state = BossState.WAITING;
            }
            if (boss_state == BossState.WAITING)
            {
                MoveToInitPosBis();
                ChargeAttack();
                Vector3 screenPos = m_MainCamera.WorldToScreenPoint(transform.position);
                // Start spawning wave
                if (screenPos.x > (m_width / 2) - 1 && screenPos.x <= (m_width / 2) + 1 && screenPos.y > m_height - 0.25 * m_height - 1 && screenPos.y <= m_height - 0.25 * m_height + 1)
                {
                    boss_state = BossState.ATTACKING;
                }
            }
            if (boss_state == BossState.ATTACKING)
            {
                if (timeBetweenChargeCountdown <= 0)
                {
                    ChargeAttack();
                    Corner_Shoot();
                    timeBetweenChargeCountdown = timeBetweenEachCharge;
                }
                else
                {
                    timeBetweenChargeCountdown -= Time.deltaTime;
                }
            }
            if (current_HP <= 0)   // If the player has nno HP , he dies
            {
                boss_status = false;
                Destroy(this.gameObject);
            }
        }
    }
Example #10
0
 // Use this for initialization
 void Start()
 {
     bossPhases = FindObjectOfType <BossPhases>();
 }
Example #11
0
 void Start()
 {
     bossAnimator = this.GetComponent <Animator>();
     currentPhase = BossPhases.Phase1;
 }