Exemplo n.º 1
0
    public static GameObject CreateEnemy(GameObject enemy, Vector3 spawn_point, Quaternion quaternion, Vector3 text_point)
    {
        enemies_in_scene += 1;
        GameObject   obj    = Instantiate(enemy, spawn_point, quaternion);
        Slime_Script script = obj.GetComponent <Slime_Script> ();

        /*script.life_text = Instantiate (script.life_text,canvas_back.transform);
         * script.life_slider = Instantiate (script.life_slider,canvas_back.transform);
         * script.canva = new Canvas_Character (script.life, script.life_text, script.life_slider);*/
        script.life_text.transform.position   = text_point;
        script.life_slider.transform.position = text_point + new Vector3(10, 5, 0);
        return(obj);
    }
Exemplo n.º 2
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Enemy"))
     {
         if (!invulnerable && life > 0)
         {
             invulnerable = true;
             Slime_Script other_script = other.gameObject.GetComponent <Slime_Script> ();
             CambioVida(other_script.fuerza * -0.5f * Statics.level - 0.5f);
             //print (life);
             Golpeado(Mathf.Sign(other.gameObject.transform.position.x - gameObject.transform.position.x));
             other_script.AtaqueHecho();
         }
     }
 }
Exemplo n.º 3
0
    /*public bool SacarGameObject(GameObject obj){
     *      if (enemigos_activos.Contains (obj)) {
     *              enemigos_activos.Remove (obj);
     *              return true;
     *      }
     *      throw new UnityException ("no hay elemento");
     * }*/

    public IEnumerator CreateEnemies(int num)
    {
        Vector3[] puntos_generados = new Vector3[num];
        puntos_generados [0] = spawn_points [0];
        Vector3[] puntos_texto = new Vector3[num];
        puntos_texto [0] = text_points [0];
        for (int j = 1; j < num; j++)
        {
            puntos_generados[j] = new Vector3(puntos_generados[j - 1].x + 2, puntos_generados[j - 1].y);
            puntos_texto[j]     = new Vector3(puntos_texto[j - 1].x, puntos_texto[j - 1].y - 18);
        }
        for (int i = 0; i < num; i++)
        {
            int enemy = Random.Range(0, enemies.Length);
            int point = Random.Range(0, spawn_points.Length);
            //print (text_points [i]);
            //print (point);
            //print (spawn_points [point]);
            //print (enemies [enemy]);
            yield return(new WaitForSeconds(0.1f));

            Slime_Script.CreateEnemy(enemies [enemy], puntos_generados [i], Quaternion.identity, puntos_texto[i]);
        }
    }
Exemplo n.º 4
0
 public void AtaqueRecibido(Slime_Script script)
 {
     KillMe();
     script.FinAtaque();
 }