예제 #1
0
    /// <summary>
    /// If the hit was somewhere in space(infinity distance).
    /// </summary>
    /// <param name="ray"></param>
    public void OnMiss(Ray ray)
    {
        if (!lineRenderer)
        {
            return;
        }

        BulletTracer lineObject = vp_Utility.Instantiate(lineRenderer, muzzle.position, Quaternion.identity) as BulletTracer;

        if (lineObject)
        {
            lineObject.OnMissLine(muzzle.position, ray.GetPoint(range));
        }
    }
예제 #2
0
    /// <summary>
    /// If the hit was on some object based on the Range.
    /// </summary>
    /// <param name="hit"></param>
    public void OnHit(RaycastHit hit)
    {
        if (!lineRenderer)
        {
            return;
        }

        BulletTracer lineObject = vp_Utility.Instantiate(lineRenderer, muzzle.position, Quaternion.identity) as BulletTracer;

        if (lineObject)
        {
            lineObject.OnHitLine(hit.point, muzzle.position);
        }
    }
예제 #3
0
    public void CreateTracer(Vector3 position, Vector3 direction)
    {
        GameObject tracer = GameObject.Instantiate(m_TracerFX) as GameObject;

        if (null != tracer)
        {
            BulletTracer bt = tracer.GetComponent <BulletTracer>();

            if (null != bt)
            {
                bt.Init(position, direction);
            }
        }
    }
예제 #4
0
파일: Bullet.cs 프로젝트: norleaf/Burgerman
        public Bullet(Texture2D spriteTexture, Vector2 position, Sprite shooter) : base(spriteTexture, position)
        {
            Random ran = new Random();

            SlideSpeed = new Vector2(0, 0);
            game       = Game1.Instance;
            Shooter    = shooter;
            List <Texture2D> tracerTex = new List <Texture2D>();

            tracerTex.Add(game.BulletTracer);
            Tracer = new BulletTracer(tracerTex, position);
            float x = game.Player.Center.X - position.X + (float)(ran.NextDouble() - 1) * _spray;
            float y = game.Player.Center.Y + -position.Y + (float)(ran.NextDouble() - 1) * _spray;

            _moveVector = new Vector2(x, y);
            _moveVector = Vector2.Normalize(_moveVector);
        }
예제 #5
0
        private void RpcDoWeaponShootEffects(WeaponShootEffectsTargets hitTargets)
        {
            TCWeapon       weapon         = weaponManager.GetActiveWeapon().GetTCWeapon();
            WeaponGraphics weaponGraphics = weaponManager.GetActiveWeaponGraphics();

            for (int i = 0; i < hitTargets.Targets.Length; i++)
            {
                //Do bullet tracer
                BulletTracer tracer =
                    Instantiate(weapon.bulletTracerEffect, weaponGraphics.bulletTracerPosition.position,
                                weaponGraphics.bulletTracerPosition.rotation).GetComponent <BulletTracer>();
                tracer.Play(hitTargets.Targets[i]);

                //Do bullet holes
                Instantiate(weapon.bulletHitEffectPrefab, hitTargets.Targets[i],
                            Quaternion.LookRotation(hitTargets.TargetNormals[i]));
                Instantiate(weapon.bulletHolePrefab, hitTargets.Targets[i],
                            Quaternion.FromToRotation(Vector3.back, hitTargets.TargetNormals[i]));
            }
        }