private void OnTriggerEnter2D(Collider2D collision)
    {
        if (GetComponent <BoxCollider2D>().GetType() == typeof(BoxCollider2D))
        {
            if (collision.tag == "ennemi" || collision.tag == "ennemibullet")
            {
                SetDead(0);
            }
            else if (collision.tag == "ammocontainer")
            {
                bulletManager.weaponType = collision.GetComponent <AmmoContainerScript>().weaponType;
                bulletManager.bulletType = collision.GetComponent <AmmoContainerScript>().bulletType;
                bulletManager.ammo       = collision.GetComponent <AmmoContainerScript>().ammo;
                bulletManager.maxAmmo    = collision.GetComponent <AmmoContainerScript>().ammo;
                haveAmmo   = true;
                haveWeapon = true;
            }
            else if ((collision.tag == "weapon") && (haveWeapon == false))
            {
                WeaponDropedscript weaponDroped = collision.gameObject.GetComponent <WeaponDropedscript>();
                EventManager.TriggerEvent("GetWeapon", 1);
                haveWeapon = true;
                if (weaponDroped.ammoInside > 0)
                {
                    haveAmmo = true;
                }
                bulletManager.bulletType = weaponDroped.myBulletType;
                bulletManager.weaponType = weaponDroped.myWeaponType;
                bulletManager.ammo       = weaponDroped.ammoInside;
                bulletManager.maxAmmo    = weaponDroped.maxAmmo;

                Destroy(collision.gameObject);
            }
        }
    }
Exemplo n.º 2
0
    public void SetDataInWeapon()
    {
        GameObject         test       = Instantiate(weapon, transform.position + transform.up, transform.rotation);
        WeaponDropedscript weaponData = test.GetComponent <WeaponDropedscript>();

        weaponData.owner        = this.gameObject;
        weaponData.myBulletType = ennemiShootScript.myBulletType;
        weaponData.myWeaponType = ennemiShootScript.myWeaponType;
        weaponData.ammoInside   = ennemiShootScript.ammo;
        weaponData.maxAmmo      = ennemiShootScript.maxAmmo;
    }
Exemplo n.º 3
0
    private void DropWeapon()
    {
        GameObject         test       = Instantiate(playerData.weapon, transform.position + transform.up * canonOut * 2, transform.rotation);
        WeaponDropedscript weaponData = test.GetComponent <WeaponDropedscript>();

        weaponData.owner        = this.gameObject;
        weaponData.myBulletType = this.bulletType;
        weaponData.myWeaponType = this.weaponType;
        weaponData.ammoInside   = this.ammo;
        weaponData.maxAmmo      = this.maxAmmo;

        bulletType = BulletType.None;
        weaponType = WeaponType.None;
        ammo       = 0;
        maxAmmo    = 0;
    }