Example #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #2
0
        public void StartGame()
        {
            player        = new Player(screenWidth / 2 - playerTexture.Width / 2, screenHeight / 3 * 2);
            platform      = new Platform(screenWidth / 2 - platformTexture.Width / 2, screenHeight / 3 * 2);
            level         = new Level(platform, player);
            Player.score  = 0;
            seconds       = 0;
            scoreTextSize = scoreTextSizeMin;
            timer         = 0;
            goal          = 0;

            if (gameLevel == 0)
            {
                boss1 = new Boss1(screenWidth - boss1Head.Width, screenHeight);
                MediaPlayer.Play(gameSong1);
            }
            if (gameLevel == 1)
            {
                MediaPlayer.Play(gameSong2);
            }
            if (gameLevel == 2)
            {
                MediaPlayer.Play(gameSong3);
            }
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
        boss   = GameObject.FindGameObjectWithTag("Boss1").GetComponent <Boss1>();

        check = true;
    }
Example #4
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        boss = FindObjectOfType <Boss1>();
        animator.SetBool("expandStart", false);
        animator.SetBool("endAnimation", true);
        boss.endAttack1();
    }
    private void LevelComplete()
    {
        game.PlayerScore = ((HUD)GetNode("HUD")).GetCoins();

        if (game.PlayerScore > game.HighestScore)
        {
            game.HighestScore = game.PlayerScore;
        }

        game.PlayerHealth = this.GetNode <HUD>("HUD").GetHealth();
        game.StorePersistedData();

        // Get rid of any enemies that are still on-screen when the boss shows up.
        var enemies = this.GetTree().GetNodesInGroup("enemies");

        foreach (var enemy in enemies)
        {
            ((IEnemy)enemy).Destroy();
        }

        ((AudioStreamPlayer2D)GetNode("Level1Music")).Playing = false;
        ((AudioStreamPlayer2D)GetNode("Boss1Music")).Playing  = true;

        this.GetNode <HUD>("HUD").ShowBossHealthBar();

        var   boss         = (PackedScene)ResourceLoader.Load("res://Components/Boss1.tscn");
        Boss1 bossInstance = (Boss1)boss.Instance();

        AddChild(bossInstance);

        this.GetNode("Boss1").Connect("BossDefeated", this, nameof(Boss_Defeated));

        fightingBoss = true;
    }
Example #6
0
 // Use this for initialization
 void Start()
 {
     launched = true;
     parent   = GameObject.FindGameObjectWithTag("Boss").GetComponent <Boss1> ();
     rb2d     = GetComponent <Rigidbody2D> ();
     rb2d.AddForce(Random.insideUnitCircle * 200);
     GetComponent <SpriteRenderer> ().color = ColorLibrary.colorLib.darkgrey;
     size = new Vector2(1f, 1f);
 }
Example #7
0
    private void Awake()
    {
        currentHP = maxHP; //시작시 현채체력과 최대체력을 동일하게 맞춤

        boss  = GetComponent <Boss>();
        boss1 = GetComponent <Boss1>();
        boss2 = GetComponent <Boss2>();
        boss3 = GetComponent <Boss3>();
    }
Example #8
0
 //OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     player       = GameObject.FindWithTag("Player").GetComponent <Transform>();
     rb           = GameObject.FindWithTag("Boss1").GetComponent <Rigidbody2D>();
     Bossrotation = GameObject.FindWithTag("Boss1").GetComponent <Transform>();
     boss1        = GameObject.FindWithTag("Boss1").GetComponent <SpriteRenderer>();
     //animator.GetComponent<Rigidbody2D>();
     bosss1 = animator.GetComponent <Boss1>();
 }
Example #9
0
    public void BossSkill1(Transform tf, string strJson)
    {
        JsonData              data  = JsonMapper.ToObject(strJson);
        Boss1                 enemy = tf.GetComponent <Boss1>();
        GameObject            go    = Pool.Instance.GetObj(AllPath.Instance.effectPrefabsPath + enemy.roledata.ID, tf.position + tf.forward, tf.rotation, null);
        EnemyEffectController efc   = go.GetComponent <EnemyEffectController>();

        efc.data = new EffectData(5, 4, 180,
                                  (int)data["Parameter1"] + enemy.roledata.LV * (int)data["Parameter2"],
                                  (int)data["Parameter3"] / 10
                                  );
    }
Example #10
0
 private void OnCollisionEnter2D(Collision2D col)
 {
     boss1 = col.collider.GetComponent <Boss1>();
     if (col.gameObject.tag == "Player")
     {
         if (check)
         {
             boss.Damage();
             check = false;
             Invoke("espera", 2);
         }
     }
 }
Example #11
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Ground" || col.gameObject.tag == "obstaculo")
        {
            grounded = true;
        }

        //Declaramos los scripts de los enemigos
        EnemigoHexagono  amarillo = col.collider.GetComponent <EnemigoHexagono>();
        EnemigoRapid     morado   = col.collider.GetComponent <EnemigoRapid>();
        EnemigoRojo      rojo     = col.collider.GetComponent <EnemigoRojo>();
        EnemigoTriangulo gris     = col.collider.GetComponent <EnemigoTriangulo>();
        Boss1            b1       = col.collider.GetComponent <Boss1>();
        Boss2            b2       = col.collider.GetComponent <Boss2>();

        //si colisiona con alguno...
        if (gris != null || b1 != null || b2 != null)
        {
            sonido.Play();
        }
        if (amarillo != null || morado != null || rojo != null)
        {
            sonido.Play();
            foreach (ContactPoint2D point in col.contacts)
            {
                //Si golpea por arriba muere el enemigo
                if (point.normal.y >= 0.7f)
                {
                    Destroy(col.gameObject);
                }
                //sino pierde vida
                else
                {
                    Damage(1);
                }
            }
        }
        if (gris != null)
        {
            Damage(1);
        }

        if (b1 != null || b2 != null)
        {
            foreach (ContactPoint2D point in col.contacts)
            {
                Damage(1);
            }
        }
    }
Example #12
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy enemy = hitInfo.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy2 enemy2 = hitInfo.GetComponent <Enemy2>();

        if (enemy2 != null)
        {
            enemy2.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy3 enemy3 = hitInfo.GetComponent <Enemy3>();

        if (enemy3 != null)
        {
            enemy3.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy4 enemy4 = hitInfo.GetComponent <Enemy4>();

        if (enemy4 != null)
        {
            enemy4.TakeDamage(damage);
            Destroy(gameObject);
        }

        Boss1 boss1 = hitInfo.GetComponent <Boss1>();

        if (boss1 != null)
        {
            boss1.TakeDamage(damage);
            Destroy(gameObject);
        }

        Boss2 boss2 = hitInfo.GetComponent <Boss2>();

        if (boss2 != null)
        {
            boss2.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Example #13
0
    private GameObject Pause;                           // Pause menu object

    // Get UI elements, PlayerStats, Gamemaster, Bosses, Curtain, Weapon Images
    private void Start()
    {
        // Get Gamemaster
        if (gm == null)
        {
            gm = GameObject.Find("Gamemaster").GetComponent <Gamemaster>();
        }

        // Get buttons
        volume = GameObject.Find("Button: Volume").GetComponent <Button>();

        // Get fading curtain
        blackCurtain = GameObject.Find("Black Curtain").GetComponent <FadeInAndOut>();

        // Get level UI elements
        if (SceneManager.GetActiveScene().name != "menu" &&
            SceneManager.GetActiveScene().name != "shop" &&
            SceneManager.GetActiveScene().name != "gameover")
        {
            stats                   = GameObject.Find("Player").GetComponent <PlayerStats>();                   // PlayerStats
            healthDisplay           = GameObject.Find("Text: Health").GetComponent <Text>();                    // Health text
            healthDisplayBG         = GameObject.Find("Image: Health BG").GetComponent <Image>();               // Health BG
            moneyDisplay            = GameObject.Find("Text: Money").GetComponent <Text>();                     // Money text
            moneyDisplayBG          = GameObject.Find("Image: Money BG").GetComponent <Image>();                // Money BG
            attackReady             = GameObject.Find("Image: Attack ready").GetComponent <Image>();            // Attach ready indicator
            bossHealthDisplay       = GameObject.Find("Text: Boss Health").GetComponent <Text>();
            bossHealthDisplay.color = new Color(0f, 0f, 0f, 0f);
            bossHealthBG            = GameObject.Find("Image: Boss Health BG").GetComponent <Image>();
            bossHealthBG.color      = new Color(0f, 0f, 0f, 0f);
            Pause                   = GameObject.Find("Pause");                                                                                                 // Pause menu
            Pause.SetActive(false);                                                                                                                             // Pause is inactive at level start

            // Get Bosses, hide their health display until entry is done
            if (SceneManager.GetActiveScene().buildIndex == 1)
            {
                boss1 = GameObject.Find("Boss1").GetComponent <Boss1> ();
            }
            else if (SceneManager.GetActiveScene().buildIndex == 2)
            {
                boss2 = GameObject.Find("Boss2").GetComponent <Boss2> ();
            }
//			else if (SceneManager.GetActiveScene ().buildIndex == 3) {
//				boss3 = GameObject.Find ("Boss3").GetComponent<Boss3> ();
//			} else if (SceneManager.GetActiveScene ().buildIndex == 4) {
//				boss4 = GameObject.Find ("Boss4").GetComponent<Boss4> ();
//			} else if (SceneManager.GetActiveScene ().buildIndex == 5) {
//				boss5 = GameObject.Find ("Boss5").GetComponent<Boss5> ();
//			}
        }
    }
Example #14
0
    // Use this for initialization
    void Awake()
    {
        boss      = GetComponent <Boss1>();
        cannon    = new Boss_Cannon[2];
        cannon[0] = transform.Find("Cannon_L").GetComponent <Boss_Cannon>();
        cannon[0].SetDelay(cannonDelay);
        cannon[1] = transform.Find("Cannon_R").GetComponent <Boss_Cannon>();
        cannon[1].SetDelay(cannonDelay);
        launcher = transform.Find("Launcher").GetComponent <Boss_Launcher>();
        launcher.SetMissileDelay(launcherDelay);
        launcher.SetMissileAmount(fire_missile_number);

        wfs_cannon   = new WaitForSeconds(cannonCool);
        wfs_launcher = new WaitForSeconds(launcherCool);
    }
    }//Does an initial setup of the battle

    IEnumerator SetUpBossFight1()
    {
        MusicManager.bossBattleMusic = true;

        MusicManager.normalBattleMusic = false;

        EnemyHolder.enemyAmount = 0;

        GameObject enemyGO = Instantiate(bosses[0], enemyBattleStations[1]); //Instantiates enemy

        enemyGO.name = "boss" + 1;                                           //Gives it a name and number

        currentEnemies[0] = enemyGO;                                         //Assigns Panama to the first space in the enemy array

        enemyUnit[0] = enemyGO.GetComponent <UnitStats>();                   //Grabs the enemy's stats
        bossUnit[0]  = enemyGO.GetComponent <UnitStats>();

        enemyUnit[0].affinity = 1;                                          //Sets Index's affinity to Soma

        enemyColor[0] = enemyGO.GetComponent <Image>();                     // Grabs the color of the enemy so it can be changed

        enemyHUDs[0].SetHUD(enemyUnit[0]);                                  //Sets the hud with the enemy stats

        enemyLightingEffects[0] = enemyGO.transform.GetChild(0).gameObject; //Assigns the lighting effects from Panama

        #region InitialSetup

        playerUnit  = playerPrefab.GetComponent <UnitStats>();
        playerColor = playerPrefab.GetComponent <Image>();

        playerHUD.SetHUD(playerUnit);

        buttons.SetActive(true);

        boss1Attack = GameObject.FindGameObjectWithTag("EnemyStuff").GetComponent <Boss1>();

        #endregion InitialSetup

        yield return(new WaitForSeconds(.5f));

        if (GameObject.FindGameObjectsWithTag("Boss1").Length > 2)
        {
            Destroy(GameObject.Find("boss1"));
        }

        state = BattleStateFossil.PLAYERTURN;
        PlayerTurn();
    }
Example #16
0
    void SetupLevel()
    {
        Background background = new Background(0, 0);

        game.AddChild(background);

        Tyler                = new Sound("Sounds/Frank/boogaloo.mp3", false, false);
        _musicChannel        = Tyler.Play();
        _musicChannel.Volume = 0.10f;

        if (Input.GetKeyDown(Key.M))
        {
            _musicChannel.Volume = 0f;
        }

        boss1 = new Boss1(1700, 700, player);
        game.AddChild(boss1);

        boss1.HP     = 300;
        player.Lifes = 5;

        HUD_Boss hud = new HUD_Boss(boss1);

        game.AddChild(hud);


        Platform platform1 = new Platform(450, game.height / 2 + 300);

        game.AddChild(platform1);

        Platform platform2 = new Platform(850, game.height / 2);

        game.AddChild(platform2);

        Platform platform3 = new Platform(1250, game.height / 2 + 300);

        game.AddChild(platform3);

        game.AddChild(player);

        HUD_Player hud_player = new HUD_Player(player);

        game.AddChild(hud_player);

        HUD_Score hud_score = new HUD_Score(mygame);

        game.AddChild(hud_score);
    }
Example #17
0
 // Use this for initialization
 void Start()
 {
     Instance  = this;
     fun_count = 8;
     for (int i = 0; i < 8; i++)
     {
         Vector3    point = transform.position + new Vector3(0, 0, -50 + 15 * i);
         GameObject go    = (GameObject)Instantiate(funnel, point, Quaternion.identity);
         go.transform.parent     = transform;
         go.transform.rotation   = Quaternion.Euler(0, 90, 90);
         go.transform.localScale = go.transform.localScale * 20;
         ful[i] = go;
     }
     t = 1;
     forRandom();
 }
Example #18
0
    public void SuperBullet()
    {
        for (int i = 0; i < spawnedEnemies.Count; i++)
        {
            Enemy enemy = spawnedEnemies[i].GetComponent <Enemy>();
            if (enemy != null)
            {
                enemy.Damage(10);
            }
            else if (enemy == null)
            {
                Boss1 boss = GetComponent <Boss1>();
                boss.Damage(10);
            }
        }

        DeleteAllBullet();
    }
Example #19
0
    void Start()
    {
        // Bossクラスの変数を宣言してインスタンスを代入


        Boss1 lastboss = new Boss1();

        for (int i = 0; i < 11; i++)
        {
            lastboss.Magic();
        }



        //if(i<=0){
        //Debug.Log("Mpが足りないため魔法が使えない");
        //lastboss.magic();
    }
Example #20
0
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        Boss1 boss1 = other.gameObject.GetComponent <Boss1>();
        Enemy enemy = other.gameObject.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.Damage(damage);
        }
        else if (boss1 != null)
        {
            boss1.Damage(damage);
        }

        if (boss1 != null || enemy != null)
        {
            Destroy(this.gameObject);
        }
    }
Example #21
0
        public static void LoadContent(ContentManager content, GameWindow window)
        {
            GameElements.player   = new Player(content.Load <Texture2D>("Images/player/Player"), 0f, 200f, 2.5f, 4.5f, content.Load <Texture2D>("Images/player/bullet"));
            GameElements.bakgrund = new Bakgrund(content.Load <Texture2D>("Images/bakgrund"), window);
            GameElements.boss1    = new Boss1(content.Load <Texture2D>("Images/Enemies/Boss1"), 700f, 360f);
            GameElements.meny     = new Meny(0);
            GameElements.meny.AddItem(content.Load <Texture2D>("Images/Meny/Start"), 1, window);
            GameElements.meny.AddItem(content.Load <Texture2D>("Images/Meny/Highscore"), 6, window);
            GameElements.meny.AddItem(content.Load <Texture2D>("Images/Meny/Avsluta"), 7, window);
            GameElements.levels = new Levels(1);
            GameElements.levels.AddItem(content.Load <Texture2D>("Images/Meny/Level 1"), 2, window);
            GameElements.levels.AddItem(content.Load <Texture2D>("Images/Meny/Level 2"), 3, window);
            GameElements.levels.AddItem(content.Load <Texture2D>("Images/Meny/Level 3"), 4, window);
            GameElements.Fiende = new List <Fiender>();
            Random    random    = new Random();
            Texture2D tmpsprite = content.Load <Texture2D>("Images/Enemies/Predator");

            for (int i = 0; i < 5; i++)
            {
                int      rndX = random.Next(window.get_ClientBounds().Width / 2, window.get_ClientBounds().Width - tmpsprite.get_Width());
                int      rndY = random.Next(0, window.get_ClientBounds().Height - tmpsprite.get_Height());
                Predator temp = new Predator(tmpsprite, (float)rndX, (float)rndY);
                GameElements.Fiende.Add(temp);
            }
            tmpsprite = content.Load <Texture2D>("Images/Enemies/mina");
            for (int i = 0; i < 5; i++)
            {
                int  rndX  = random.Next(window.get_ClientBounds().Width / 2, window.get_ClientBounds().Width - tmpsprite.get_Width());
                int  rndY  = random.Next(0, window.get_ClientBounds().Height - tmpsprite.get_Height());
                Mine temp2 = new Mine(tmpsprite, (float)rndX, (float)rndY);
                GameElements.Fiende.Add(temp2);
            }
            GameElements.printText                = new Utskrifter(content.Load <SpriteFont>("Font1"));
            GameElements.guldMyntSprite           = content.Load <Texture2D>("Images/Powerups/SpelMynt");
            GameElements.SuperskeppSprite         = content.Load <Texture2D>("Images/Powerups/PowerUp");
            GameElements.PenetratingbulletsSprite = content.Load <Texture2D>("Images/Powerups/PowerUp2");
        }
Example #22
0
 void Start()
 {
     boss1 = GameObject.FindGameObjectWithTag("Boss1").GetComponent <Boss1>();
 }
Example #23
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     boss1 = animator.GetComponent <Boss1>();
 }
Example #24
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     boss1 = animator.GetComponent <Boss1>();
     timer = Random.Range(minTime, maxTime);
 }
Example #25
0
 protected override void LoadContent()
 {
     go = 0;
     spriteBatch = new SpriteBatch(GraphicsDevice);
     texto = Content.Load<SpriteFont>("fuente");
     //menu
     menuu = Content.Load<Texture2D>("img/wip menu");
     menu1 = Content.Load<Texture2D>("img/menu1");
     menu2 = Content.Load<Texture2D>("img/menu2");
     mgo1 = Content.Load<Texture2D>("img/Continue");
     mgo2 = Content.Load<Texture2D>("img/Exit");
     mgo3 = Content.Load<Texture2D>("img/GO");
     mmenu = new Menu(menuu, menu1, menu2, mgo1, mgo2, mgo3);
     MainMenu = Content.Load<SoundEffect>("BGM/NativeSon");
     //balloon
     balloon = Content.Load<Texture2D>("img/balloon");
     bloo = new Balloony(balloon, new Vector2(100, 100));
     vidas = new Lives(balloon);
     //nivel 1
     BGM1 = Content.Load<SoundEffect>("BGM/jo1");
     swordfish = Content.Load<Texture2D>("img/level1");
     boss1 = Content.Load<Texture2D>("img/boss1");
     Crab = new Boss1(boss1, new Vector2(800, 300));
     scrolling11 = new Scrolling(Content.Load<Texture2D>("Background/fondo_1"), new Rectangle(0, 0, 1500, 600));
     scrolling12 = new Scrolling(Content.Load<Texture2D>("Background/fondo_2"), new Rectangle(1500, 0, 1500, 600));
     scrolling13 = new Scrolling(Content.Load<Texture2D>("Background/fondo_3"), new Rectangle(3000, 0, 1500, 600));
     scrolling14 = new Scrolling(Content.Load<Texture2D>("Background/fondo_4"), new Rectangle(4500, 0, 1500, 600));
     //nivel 2
     BGM2 = Content.Load<SoundEffect>("BGM/jo2");
     dragon = Content.Load<Texture2D>("img/level2");
     boss2 = Content.Load<Texture2D>("img/boss2");
     Robot = new Boss2(boss2, new Vector2(800,130));
     scrolling21 = new Scrolling(Content.Load<Texture2D>("Background/bg2_1"), new Rectangle(0, 0, 1500, 600));
     scrolling22 = new Scrolling(Content.Load<Texture2D>("Background/bg2_2"), new Rectangle(1500, 0, 1500, 600));
     scrolling23 = new Scrolling(Content.Load<Texture2D>("Background/bg2_3"), new Rectangle(3000, 0, 1500, 600));
     scrolling24 = new Scrolling(Content.Load<Texture2D>("Background/bg2_4"), new Rectangle(4500, 0, 1500, 600));
     //nivel 3
     BGM3 = Content.Load<SoundEffect>("BGM/jo3");
     space = Content.Load<Texture2D>("img/level3");
     scrolling31 = new Scrolling(Content.Load<Texture2D>("Background/bg3_1"), new Rectangle(0, 0, 1300, 600));
     scrolling32 = new Scrolling(Content.Load<Texture2D>("Background/bg3_2"), new Rectangle(1300, 0, 1300, 600));
     scrolling33 = new Scrolling(Content.Load<Texture2D>("Background/bg3_3"), new Rectangle(2600, 0, 1300, 600));
     scrolling34 = new Scrolling(Content.Load<Texture2D>("Background/bg3_4"), new Rectangle(3900, 0, 1300, 600));
     //splash screens
     sp1 = Content.Load<Texture2D>("img/Splash1");
     sp2 = Content.Load<Texture2D>("img/Splash2");
     sp3 = Content.Load<Texture2D>("img/Splash3");
     //video
     Ending = Content.Load<Video>("video/balloonadventure");
     //main menu music
     sfx = MainMenu.CreateInstance();
     sfx.Play();
 }
Example #26
0
    void Update()
    {
        Vector2 currentPosition = new Vector2(transform.position.x, transform.position.y);
        Vector2 newPosition     = currentPosition + velocity * Time.deltaTime;

        Debug.DrawLine(currentPosition, newPosition, Color.green, 30000000000);
        RaycastHit2D[] hits = Physics2D.LinecastAll(currentPosition, newPosition);

        if (hits.Length == 0)
        {
            Invoke("DestroyFireRing", 2);
        }
        else
        {
            CancelInvoke("DestoyProjectile");
            foreach (RaycastHit2D hit in hits)
            {
                GameObject other = hit.collider.gameObject;
                if (other != player)
                {
                    if (other.gameObject.name == "EnemyColliders")
                    {
                        enemyScript = other.transform.parent.gameObject.GetComponent <Vida>();
                        if (other.transform.parent.gameObject.GetComponent <Enemies>() != null)
                        {
                            enemyOther = other.transform.parent.gameObject.GetComponent <Enemies>();
                        }
                        else
                        {
                            Boss = other.transform.parent.gameObject.GetComponent <Boss1>();
                        }
                        if ((other.transform.parent.gameObject.GetComponent <Enemies>() != null && !enemyOther.dead))
                        {
                            enemyScript.TakeDamage(damage);
                            Debug.Log(enemyScript.currentHealth);
                            GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                            explosion.GetComponent <AudioSource>().volume = 0.2f;
                            Destroy(explosion, 2.3f);
                            Destroy(gameObject);
                            Debug.Log(other.name);
                        }
                        if (other.transform.parent.gameObject.GetComponent <Boss1>() != null)
                        {
                            enemyScript.TakeDamage(damage);
                            Debug.Log(enemyScript.currentHealth);
                            GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                            explosion.GetComponent <AudioSource>().volume = 0.2f;
                            Destroy(explosion, 2.3f);
                            Destroy(gameObject);
                            Debug.Log(other.name);
                        }
                        break;
                    }
                    if (other.CompareTag("TopWalls") || other.CompareTag("BottomWalls") || other.CompareTag("Obstacle"))
                    {
                        Destroy(gameObject);
                        GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                        explosion.GetComponent <AudioSource>().volume = 0.2f;
                        Destroy(explosion, 2.3f);
                        Debug.Log(other.name);
                        break;
                    }
                }
            }
        }

        transform.position = newPosition;
    }
Example #27
0
    void Update()
    {
        Vector2 currentPosition = new Vector2(transform.position.x, transform.position.y);
        Vector2 newPosition     = currentPosition + velocity * Time.deltaTime;

        Debug.DrawLine(currentPosition + offset, newPosition + offset, Color.green, 30000000000);

        RaycastHit2D[] hits = Physics2D.LinecastAll(currentPosition + offset, newPosition + offset);

        if (hits.Length == 0)
        {
            Invoke("DestoyProjectile", 2);
        }
        else
        {
            CancelInvoke("DestoyProjectile");
            foreach (RaycastHit2D hit in hits)
            {
                GameObject other = hit.collider.gameObject;
                if (other != player)
                {
                    if (other.gameObject.name == "EnemyColliders")
                    {
                        enemyHealth = other.transform.parent.gameObject.GetComponent <Vida>();
                        if (other.transform.parent.gameObject.GetComponent <Enemies>() != null)
                        {
                            enemyOther = other.transform.parent.gameObject.GetComponent <Enemies>();
                        }
                        else
                        {
                            Boss = other.transform.parent.gameObject.GetComponent <Boss1>();
                        }
                        //realDamage = (iceDamage / enemyHealth.damageReduction);
                        realDamage = iceDamage;
                        if ((other.transform.parent.gameObject.GetComponent <Enemies>() != null && !enemyOther.dead) || (other.transform.parent.gameObject.GetComponent <Boss1>() != null && Boss.vida.currentHealth != 0))
                        {
                            if (gameObject.CompareTag("Iceball"))
                            {
                                if (realDamage > 0 && iceCanDamage)
                                {
                                    if (other.transform.parent.gameObject.GetComponent <Enemies>() != null)
                                    {
                                        enemySpeed       = enemyOther.speed;
                                        enemyOther.speed = (enemyOther.speed / freeze);
                                        Debug.Log("Enemy mv" + enemyOther.speed);
                                    }
                                    enemyHealth.TakeDamage(realDamage);
                                    canHitWall = false;
                                    GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                                    Destroy(explosion, 2.3f);

                                    Debug.Log("Damage Dealt: " + realDamage);
                                    Debug.Log(enemyHealth.currentHealth);
                                    Debug.Log(other.name);
                                    StartCoroutine(Freezing());
                                }


                                IEnumerator Freezing()
                                {
                                    iceCanDamage = false;
                                    gameObject.GetComponent <SpriteRenderer>().enabled = false;
                                    yield return(new WaitForSeconds(1));

                                    iceCanDamage = true;
                                    if (other.transform.parent.gameObject.GetComponent <Enemies>() != null)
                                    {
                                        enemyOther.speed = enemySpeed;
                                        Debug.Log("Enemy mv" + enemyOther.speed);
                                    }
                                    Destroy(gameObject);
                                }
                            }
                            else
                            {
                                realDamage = fireDamage;
                                //realDamage = (fireDamage / enemyHealth.damageReduction);
                                enemyHealth.TakeDamage(realDamage);

                                GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                                Destroy(gameObject);
                                Destroy(explosion, 2.3f);

                                Debug.Log("Damage Dealt: " + realDamage);
                                Debug.Log(enemyHealth.currentHealth);
                                Debug.Log(other.name);
                            }
                        }
                        break;
                    }
                    if (other.CompareTag("TopWalls"))
                    {
                        if (triggerWall && canHitWall)
                        {
                            GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                            Destroy(explosion, 2.3f);
                            Destroy(gameObject);
                            Debug.Log(other.name);
                            break;
                        }
                    }
                    if (canHitWall && (other.CompareTag("BottomWalls") || other.CompareTag("Obstacle")))
                    {
                        GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                        Destroy(explosion, 2.3f);
                        Destroy(gameObject);
                        Debug.Log(other.name);
                        break;
                    }
                }
            }
        }
        transform.position = newPosition;
    }
Example #28
0
    private void Start()
    {
        actor = this.gameObject.GetComponent <Boss1>();

        //add nullchecks!
    }
Example #29
0
    //tätä funktiota kutsutaan pelaajan hyökkäyksessä
    public void TakeDamage()
    {
        /* First Boss */
        if (Boss1)
        {
            Boss1 boss = gameObject.GetComponent <Boss1>();
            if (boss.vulnerable)
            {
                health--;
                SoundManager.PlaySound("BOSSOOF");
                if (health == 0)
                {
                    boss.Die();
                }
                else
                {
                    boss.TakeDamage();
                }
            }
            else
            if (health <= 0)
            {
                Debug.Log("boss counter");
                boss.Counter();
                //kutsutaan pelaajan tappavaa funktioita
            }
        }
        /* Second Boss */
        else if (Boss2)
        {
            health--;

            if (health <= 0)
            {
                gameObject.GetComponent <Boss2>().Die();
            }
        }
        /*ranged ja melee */
        else if (normal)
        {
            RangedEnemy enemy = gameObject.GetComponent <RangedEnemy>();
            if (!enemy.dead)
            {
                SoundManager.PlaySound("DEEPOOF");
                health--;

                if (health <= 0)
                {
                    //kutsutaan vihollisen omaa die funktiota
                    enemy.Die();
                }
            }
        }
        else if (turret)
        {
            SoundManager.PlaySound("EXPLODE");
            health--;

            if (health <= 0)
            {
                //tuhotaan turret animaattorin avustuksella
                gameObject.GetComponent <TurretScript>().Dead();
            }
        }
        else if (charging)
        {
            if (gameObject.GetComponent <ChargingEnemy>().killable)
            {
                health--;

                if (health <= 0)
                {
                    gameObject.GetComponent <ChargingEnemy>().Die();
                }
            }
        }
    }
Example #30
0
 /*
  * 0 = shrink to summon enemies
  * 1 = stay small
  * 2 = grow back
  * 3 = damaged
  */
 // Use this for initialization
 void Awake()
 {
     boss = this;
 }
 public State1_Awake(Boss1 actor)
 {
     this.actor = actor;
 }