示例#1
0
    void SpawnBullet(Weapon weapon) //spawn a bullet and asign its values
    {
        GameObject bullet = Instantiate(Resources.Load <GameObject>(Weapon.bulletPrefabPath));

        bullet.transform.position = transform.position;
        bullet.transform.rotation = transform.rotation;
        BulletBehaviour bulletBehaviour = bullet.GetComponent <BulletBehaviour>();

        bulletBehaviour.dmg   = weapon.dmg;
        bulletBehaviour.speed = weapon.bulletSpeed;
        bulletBehaviour.GetComponent <MeshFilter>().sharedMesh       = Resources.Load <GameObject>(weapon.bulletMeshPath).GetComponent <MeshFilter>().sharedMesh;
        bulletBehaviour.GetComponent <MeshRenderer>().sharedMaterial = Resources.Load <GameObject>(weapon.bulletMeshPath).GetComponent <MeshRenderer>().sharedMaterial;
    }
示例#2
0
    private string SubText()
    {
        string text = "";

        ExplosionBehaviour e = prefabBullet.GetComponent <ExplosionBehaviour>();

        if (e != null)
        {
            text += e.Text();
        }

        ShotgunBehaviour s = prefabBullet.GetComponent <ShotgunBehaviour>();

        if (s != null)
        {
            text += s.Text();
        }

        return(text);
    }