private IEnumerator Start_Series_Of_Explosions()
    {
        Instantiate_Explotion_thenDestroy();
        yield return(new WaitForSeconds(Random.Range(.5f, 1)));

        Instantiate_Explotion_thenDestroy();
        yield return(new WaitForSeconds(Random.Range(.5f, 1)));

        Instantiate_Explotion_thenDestroy();
        yield return(new WaitForSeconds(Random.Range(.5f, 1)));

        Instantiate_Explotion_thenDestroy();
        yield return(new WaitForSeconds(Random.Range(.5f, 1)));

        Instantiate_Explotion_thenDestroy();
        yield return(new WaitForSeconds(Random.Range(.5f, 1)));

        yield return(new WaitForSeconds(1));

        mySpriteRenderer.enabled = false;
        transform.GetChild(0).gameObject.SetActive(false);
        transform.GetChild(1).gameObject.SetActive(false);
        transform.GetChild(10).gameObject.SetActive(false);
        GameObject explosion2 = Instantiate(finalDeathBoom, transform.position, transform.rotation) as GameObject;

        Destroy(explosion2, 5);
        yield return(new WaitForSeconds(5));

        GameObject  gameSession       = FindObjectOfType <GameSession>().gameObject;
        GameSession gameSessionScript = gameSession.GetComponent <GameSession>();

        gameSessionScript.AddDestroyEnemies();
        gameObject.SetActive(false);
    }
Example #2
0
    private void Die()
    {
        ///Has its own activation bool because if bool is activated then
        ///the minions it spawned will also die when it dies
        if (bossBrainy)
        {
            if (FindObjectsOfType <BrainSheildDome>().Length >= 1)
            {
                FindObjectOfType <BrainSheildDome>().StopCoRoutineDead();
                bossBrainy = false;
            }

            if (FindObjectsOfType <HandMinion>().Length >= 1)
            {
                gameSession.Turn_OFF_GamesessionBool_is_LeftHandMinion_in_Scene();
                var hand = GameObject.Find("Left handminion(Clone)");
                hand.GetComponent <HandMinion>().Instantiate_Explosion_On_Death_HandMinion_Left();
                Destroy(hand);
            }

            if (FindObjectsOfType <RightHandMinion>().Length >= 1)
            {
                gameSession.Turn_OFF_GamesessionBool_is_RightHandMinion_in_Scene();
                var hand = GameObject.Find("Right handminion(Clone)");
                hand.GetComponent <RightHandMinion>().Instantiate_Explosion_On_Death_HandMinionRight();
                Destroy(hand);
            }
        }

        //To call a method from anther script use FindObjectOfType
        //We are looking for the GameSession script
        //Calling the AddToScore method from that script
        //we are putting in the score value Delclared in the parameters above via "scoreValue"
        if (addOnce)
        {
            gameSession.AddToScore(scoreValue);
            gameSession.AddDestroyEnemies();
            addOnce = false;
        }

        //enemyValue
        Destroy(gameObject);
        GameObject explosion = Instantiate(
            deathVFX,
            transform.position,
            transform.rotation);

        Destroy(explosion, durationOFExplosion);
        AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathSoundVolume);
    }
Example #3
0
    private void Move()
    {
        if (PathLoopPlayingAfterWaveLoop)
        {
            if (pathLoopIndex <= (movementLoop.Count - 1))
            {
                pathPoints = movementLoop[pathLoopIndex].GetPathPoints();

                if (pathPointIndex <= (pathPoints.Count - 1))
                {
                    var targetPosition    = pathPoints[pathPointIndex].transform.position;
                    var movementThisFrame = movementLoop[pathLoopIndex].GetPathMoveSpeed() * Time.deltaTime;
                    transform.position = Vector2.MoveTowards(transform.position, targetPosition, movementThisFrame);

                    if (transform.position == targetPosition)
                    {
                        Special_Movement_for_Boss_peanut();
                        pathPointIndex++;
                    }
                }
                else
                {
                    //SettingPathPointIndex to 0 loops the animation
                    if (IncreaseIndexByOne)
                    {
                        if (pathPointIndex > pathPoints.Count - 1)
                        {
                            pathPointIndex = 0;
                            pathLoopIndex++;
                        }
                    }
                    else if (playSecondPathLoop)
                    {
                        pathLoopIndex      = 0;
                        pathPointIndex     = 0;
                        playSecondPathLoop = false;
                    }
                    else
                    {
                        pathPointIndex = 0;
                    }
                }
            }
            else
            {
                pathLoopIndex  = 0;
                pathPointIndex = 0;
            }
        }
        else if (!PathLoopPlayingAfterWaveLoop)
        {
            if (waypointIndex <= waypoints.Count - 1)
            {
                var targetPosition    = waypoints[waypointIndex].transform.position;
                var movementThisFrame = waveConfig.GetMoveSpeed() * Time.deltaTime;
                transform.position = Vector2.MoveTowards(transform.position, targetPosition, movementThisFrame);

                if (transform.position == targetPosition)
                {
                    waypointIndex++;
                }
            }
            else if (DestroyEndWLoop)
            {
                Destroy(gameObject);
                gameSession.AddDestroyEnemies();
            }
            else
            {
                PathLoopPlayingAfterWaveLoop = true;
            }
        }
        else
        {
            Debug.Log("Check enemy Pathing script. Else option triggered. No code.");
        }
    }