// Update is called once per frame
        void Update()
        {
            if (timerMeteor >= 0)
            {
                timerMeteor -= Time.deltaTime;
            }

            float currentHeight = heroTrans.position.y;

            if (currentHeight > 10 && currentHeight < 200)
            {
                if (currentHeight > 180)
                {
                }
                else if (currentHeight > nextCoconut)
                {
                    float x = Random.Range(1.5f, 3f) * (Random.Range((int)0, (int)2) * 2 - 1);
                    Instantiate(prefabEnemies[0], new Vector3(x, currentHeight + 10, 0), Quaternion.identity, enemyMapPool);
                    Instantiate(prefabEnemies[0], new Vector3(x, currentHeight + 12, 0), Quaternion.identity, enemyMapPool);
                    Instantiate(prefabEnemies[0], new Vector3(x, currentHeight + 14, 0), Quaternion.identity, enemyMapPool);
                    nextCoconut += 20;
                }
            }
            if (currentHeight > 220 && currentHeight < 400)
            {
                if (currentHeight > 380)
                {
                    if (currentFlight != null && !retreated)
                    {
                        ((GameObject)currentFlight).GetComponent <Enemy>().ChangeStatus(301);
                        retreated = true;
                    }
                }
                else
                {
                    if (currentFlight == null)
                    {
                        currentFlight = Instantiate(prefabEnemies[1], new Vector3(0, currentHeight + 8, 0), Quaternion.identity, enemyFloatPool);
                    }
                }
            }
            if (currentHeight > 400 && currentHeight < 500)
            {
                if (currentHeight > 480)
                {
                }
                else if (timerMeteor < 0)
                {
                    float       x  = Random.Range(1.5f, 2.5f) * (Random.Range((int)0, (int)2) * 2 - 1);
                    Rigidbody2D sp =
                        ((GameObject)Instantiate(prefabEnemies[2], new Vector3(x, currentHeight + 6, 0), Quaternion.identity, enemyMapPool))
                        .GetComponent <Rigidbody2D>();
                    sp.velocity = Vector3.Scale(Vector3.Normalize(new Vector3(-x, -3, 0)), new Vector3(2, 2, 0));

                    Onpu.print("Meteor:" + x.ToString() + " " + (currentHeight + 6) + " " + sp.velocity.ToString());
                    timerMeteor = 2.5f;
                }
            }
        }
 void OnTriggerEnter2D(Collider2D e)
 {
     if (e.gameObject.tag.CompareTo("Player") == 0 && (e.gameObject.GetComponent <Player>().velocity.y < 0))
     {
         Onpu.print("Touch");
         //speedplus += 2f;
         e.gameObject.GetComponent <Player>().velocity = new Vector2(0, 8);            //old:12
         //Destroy(e.gameObject);
     }
 }
 void OnTriggerEnter2D(Collider2D e)
 {
     if (e.gameObject.tag.CompareTo("Player") == 0 && (e.gameObject.GetComponent <Player>().velocity.y < 0))
     {
         Onpu.print("Shooted");
         //speedplus += 2f;
         e.gameObject.GetComponent <Player>().hp -= damage;
         Destroy(gameObject);
     }
 }
Пример #4
0
 void OnTriggerEnter2D(Collider2D e)
 {
     if (e.gameObject.tag.CompareTo("Floor") == 0 && (nowvelocity.y < 0))
     {
         Onpu.print("Touch");
         //speedplus += 2f;
         m_RigidBody2D.velocity = new Vector2(0, 15);
         //Destroy(e.gameObject);
     }
 }
Пример #5
0
 void OnTriggerEnter2D(Collider2D e)
 {
     if (e.gameObject.tag.CompareTo("Player") == 0)
     {
         Player player = e.gameObject.GetComponent <Player>();
         if (player.velocity.y < 0)
         {
             Onpu.print("Touch");
             player.velocity = new Vector2(0, player.CurrentMorphoStatus.Jump * (1 + player.buffStatus.JumpMul) * (1 + JumpMul));//old:12
             audios[0].Play();
             //Destroy(e.gameObject);
         }
     }
 }