예제 #1
0
 private void Awake()
 {
     if (_intance == null)
     {
         _intance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
    // Use this for initialization
    private void Start()
    {
        bulletGO = Resources.LoadAll <Rigidbody>("Prefabs/Bullets");
        if (bulletGO == null)
        {
            enabled = false;
        }
        mRig    = GetComponent <Rigidbody>();
        pTrans  = GameObject.Find("Player").GetComponent <Transform>();
        pPlayer = GameObject.Find("Player").GetComponent <Player>();
        puntos  = GameObject.Find("Canvas").GetComponent <ControladorDePartida>();
        switch (type)
        {
        case TipoDeEnemigo.Debil:
            vida            = 1;
            velocidad       = 1;
            puntaje         = 1;
            tiempoDeDisparo = 1f;
            shootSpeed      = 10f;
            transform.GetComponent <Renderer>().material.color = new Color(1, 0, 0, 1);
            break;

        case TipoDeEnemigo.Normal:
            vida            = 2;
            velocidad       = 2;
            puntaje         = 2;
            tiempoDeDisparo = 3f;
            shootSpeed      = 20f;
            transform.GetComponent <Renderer>().material.color = new Color(1, 1, 0, 1);
            break;

        default:
            vida            = 4;
            velocidad       = 4;
            puntaje         = 4;
            tiempoDeDisparo = 1f;
            shootSpeed      = 50f;
            transform.GetComponent <Renderer>().material.color = new Color(1, 1, 1, 1);
            break;
        }
        mRig.AddForce(transform.up * -1 * velocidad, ForceMode.Impulse);
    }