示例#1
0
        public void init(tBullet owner)
        {
            this.owner = owner;

            transform.parent        = owner.transform;                  // Set the model's parent to the gem.
            transform.localPosition = new Vector3(0, 0, 0);             // Center the model on the parent.
            name = "Bullet Model";                                      // Name the object.

            mat        = GetComponent <Renderer>().material;
            mat.shader = Shader.Find("Sprites/Default");                                                // Tell the renderer that our textures have transparency. // Get the material component of this quad object.

            if (this.owner.name == "Bullet")
            {
                mat.mainTexture = Resources.Load <Texture2D> ("Textures/playerbullet");         // Set the texture.  Must be in Resources folder.
                //mat.color = new Color(1,1,1);
            }
            else if (this.owner.name == "SpecialBullet")
            {
                mat.mainTexture = Resources.Load <Texture2D> ("Textures/specialBullet");        // Set the texture.  Must be in Resources folder.
                //mat.color = new Color(1,0,0);
            }



            this.transform.rotation = new Quaternion(owner.transform.rotation.x, owner.transform.rotation.y, owner.transform.rotation.z, owner.transform.rotation.w);
        }
示例#2
0
        public void shoot(int x)
        {
            if (clock - cdbuf > cd)
            {
                if (this.firstRun)
                {
                    this.owner.m.PlayEffect(this.owner.m.shootClip);
                }

                GameObject bulletObject = new GameObject();
                tBullet    bullet       = bulletObject.AddComponent <tBullet>();
                bullet.transform.position    = new Vector3(this.transform.position.x, this.transform.position.y, 0);
                bullet.transform.eulerAngles = new Vector3(0, 0, x);
                bullet.init(this);
                cdbuf = clock;
            }
        }