Beispiel #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("Collision - Mask");


        if (other.gameObject.tag.Equals("playerBullet"))
        {
            KBReport kb = other.gameObject.GetComponent <BClass>().GetKBReport();


            float anglerad = Mathf.Atan2(kb.dir.y, kb.dir.x);

            float angle = anglerad * Mathf.Rad2Deg;

            goreindextest = Random.Range(0, 4);


            //Add blood splatter
            GameObject splatter = Instantiate(mask, this.gameObject.transform.position, other.gameObject.transform.rotation);

            splatter.GetComponent <SpriteMask>().sprite = goresets.GetComponent <GoreSprites>().splatters[goreindextest];

            splatter.transform.rotation = Quaternion.Euler(0, 0, angle);

            //Add blood pool:
            GameObject pool = Instantiate(mask, this.gameObject.transform.position, other.gameObject.transform.rotation);

            goreindextest = Random.Range(0, 2);

            pool.GetComponent <SpriteMask>().sprite = goresets.GetComponent <GoreSprites>().splatters[goreindextest];

            pool.transform.rotation = Quaternion.Euler(0, 0, angle);
        }
    }
Beispiel #2
0
 void Start()
 {
     kb = new KBReport();
     this.kb.kbspeed = kbspeed;
     this.kb.kbdur   = kbdur;
     timer           = 60.0f / tpm;
     // Debug.Log("Timer = " + timer);
 }
Beispiel #3
0
 public KBReport GetKBReport()
 {
     kb         = new KBReport();
     kb.dir     = dir;
     kb.kbspeed = kbspeed;
     kb.kbdur   = kbdur;
     return(kb);
 }
    void Start()
    {
        //Ao iniciar pegamos o sprite da arma e o holster.
        holster = this.gameObject;
        fevent  = new KBReport();
        //Nova versao
        wpimg = gunTypes[Belt[held]].GetComponent <SpriteRenderer>();

        CleanAllSprites();

        //Pegar a imagem da arma empunhada (no caso a 0 no inicio);
        //wpimg = gunBelt[held].GetComponent<SpriteRenderer>();
        player           = GameObject.Find("player").transform;
        player_scale_ini = new Vector3(player.localScale.x,
                                       player.localScale.y,
                                       player.localScale.z);

        //Estamos na primeira cena ou nao - carregar estado do player;
        int default_ = PlayerPrefs.GetInt("use_default");

        if (default_ != 1)
        {
            //Debug.Log("Here");
            held   = PlayerPrefs.GetInt("held");
            _other = PlayerPrefs.GetInt("_other");

            Belt[0] = PlayerPrefs.GetInt("weaponindex_1");
            Belt[1] = PlayerPrefs.GetInt("weaponindex_2");


            gunTypes[Belt[0]].GetComponent <Gun>().ammo    = PlayerPrefs.GetInt("ammo_weapon_1");
            gunTypes[Belt[0]].GetComponent <Gun>().curammo = PlayerPrefs.GetInt("curammo_weapon_1");


            gunTypes[Belt[1]].GetComponent <Gun>().ammo    = PlayerPrefs.GetInt("ammo_weapon_2");
            gunTypes[Belt[1]].GetComponent <Gun>().curammo = PlayerPrefs.GetInt("curammo_weapon_2");
        }

        UpdateWeapon();


        //kb test
        knockd = false;
        kill   = false;
        //Mun~ição na arma
        UI.SetBulletGun(gunTypes[Belt[held]].GetComponent <Gun>().curammo, held);
        UI.SetBulletColdre(gunTypes[Belt[held]].GetComponent <Gun>().ammo, held);


        UI.SetBulletGun(gunTypes[Belt[_other]].GetComponent <Gun>().curammo, _other);
        UI.SetBulletColdre(gunTypes[Belt[_other]].GetComponent <Gun>().ammo, _other);

        UI.setGunImages(Belt[0], Belt[1]);
    }
Beispiel #5
0
    private void Start()
    {
        // define o scale da barra de vida inicial
        iniHealthScale = new Vector3(healthBarG.transform.localScale.x,
                                     healthBarG.transform.localScale.y,
                                     healthBarG.transform.localScale.z);
        // define quanto é vida cheia
        fullHealth = health;
        // define a posição da barra de vida do inimigo

        //Partes do knockback
        fevent         = new KBReport();
        fevent.dir     = new Vector2(0, 0);
        fevent.kbdur   = 0f;
        fevent.kbspeed = 0f;
    }
Beispiel #6
0
 //Teste usando trigger ao inves de collisao.
 void OnTriggerEnter2D(Collider2D other)
 {
     // Debug.Log("Zombie Side collision");
     // de colidir com bala então diminui a vida
     if (other.gameObject.tag.Equals("playerBullet"))
     {
         health = health - other.gameObject.GetComponent <BClass>().damage;
         //Parte experimental Knockback
         KBReport kb = other.gameObject.GetComponent <BClass>().GetKBReport();
         // Debug.Log("Hit - Kb from:" + kb.dir);
         fevent = new KBReport();
         fevent = kb;
         //gameObject.transform.position = gameObject.transform.position + kb.dir*2;
         //DealKnockback(1);
         hit = true;
     }
 }
Beispiel #7
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag.Equals("playerBullet"))
        {
            UpdateCorners();

            KBReport kb = other.gameObject.GetComponent <BClass>().GetKBReport();

            //Ponto de impacto.
            Vector2 travelpoint = other.gameObject.transform.position;

            Debug.Log("Enter at:" + travelpoint);

            Debug.Log("With angle:" + kb.dir);

            Vector2 travelangle = kb.dir;

            travelpoint = travelpoint + travelangle * acuracy;

            //While:
            //Enquanto ainda dentro do retangulo, continuamos "andando"
            //Quando ele sair de um dos extremos, ele estara fora.

            while ((corner1.x < travelpoint.x && travelpoint.x < corner4.x) && (corner4.y < travelpoint.y && travelpoint.y < corner1.y))
            {
                //Problema - a bala nao esta "dentro" da area inicialmente, para remediar isso, use acuracy baixa
                //Podemos também colocar um "containment" aqui.
                travelpoint = travelpoint + travelangle * acuracy;
            }

            float anglerad = Mathf.Atan2(travelangle.y, travelangle.x);

            float angle = anglerad * Mathf.Rad2Deg;


            Debug.Log("Leave at:" + travelpoint);

            Debug.Log("Angle:" + angle);

            GameObject splatter = Instantiate(mask, travelpoint, other.gameObject.transform.rotation);

            splatter.transform.rotation = Quaternion.Euler(0, 0, angle);
        }
    }
    // Update is called once per frame
    void Update()
    {
        UpdateWeapon();

        DealKnockback(0);

        wpimg = gunTypes[Belt[held]].GetComponent <SpriteRenderer>();
        //wpimg = gunBelt[held].GetComponent<SpriteRenderer>();
        //definimos o angulo que vamos usar para a mira.
        AimAngle();
        //invertendo o personagem
        //Como temos tiros por segundo, devemos usar o botão pressionado.
        if (Input.GetButton("Fire1"))
        {
            fevent = gunTypes[Belt[held]].GetComponent <Gun>().Shoot(camvec);
            //int fevent = gunBelt[held].GetComponent<Gun>().Shoot(camvec);


            if (fevent.status == 1)
            {
                //Debug.Log("Shot Fired");
                //Debug.Log("Segurando" +  gunTypes[Belt[held]].GetComponent<Gun>());
                //Debug.Log("Gun Type" + Belt[held]);
                ShakeHandler.PlayShake((ShakeHandler.Shake)Belt[held]);
                //test for knockback:
                DealKnockback(1);
            }
            if (fevent.status == 2)
            {
                // Debug.Log("Gun -resting-");
            }
            if (fevent.status == 0)
            {
                //  Debug.Log("Must Reload");
            }

            UI.SetBulletGun(gunTypes[Belt[held]].GetComponent <Gun>().curammo, held);
        }

        //Se estamos recarregando
        if (Input.GetKeyDown(KeyCode.R))
        {
            // Debug.Log("R pressed" + held);
            int fevent2 = gunTypes[Belt[held]].GetComponent <Gun>().Reload();
            //int fevent = gunBelt[held].GetComponent<Gun>().Reload();
            if (fevent2 == 0)
            {
                // Debug.Log("No ammo");
            }
            else
            {
                // Debug.Log("Reloaded");
            }

            UI.SetBulletGun(gunTypes[Belt[held]].GetComponent <Gun>().curammo, held);
            UI.SetBulletColdre(gunTypes[Belt[held]].GetComponent <Gun>().ammo, held);
        }

        //Setamos qual eh a arma que estamos usando.
        if (Input.mouseScrollDelta.y != 0)
        {
            //scroll pra cima
            //Como temos duas armas, ambas fazem a mesma coisa, mas esse codigo serve se tivermos mais armas no futuro
            if (held == 0)
            {
                held   = 1;
                _other = 0;
            }
            //scroll pra baixo;
            else
            {
                held   = 0;
                _other = 1;
            }

            //Debug.Log("Scroll Moved");
            //Debug.Log(held);
        }
    }