Пример #1
0
        public override void Shoot(VehicleShootBehaviour shootBehaviour)
        {
            var randomOffset = new Vector3(Random.Range(-Spread, Spread), Random.Range(0, Spread), 0);
            var point        = GunBarrel.TransformPoint(randomOffset);

            shootBehaviour.CmdFireRound(point, GunBarrel.rotation, ShotStrength);
        }
Пример #2
0
        public override void Shoot(VehicleShootBehaviour shootBehaviour)
        {
            for (int i = 0; i < PelletCount; i++)
            {
                var point             = new Vector2(Random.Range(-Spread, Spread), Random.Range(-Spread, Spread));
                var transformed_point = GunBarrel.TransformPoint(point);

                shootBehaviour.CmdFireRound(transformed_point, GunBarrel.rotation, ShotStrength);
                //weaponAnimator.SetTrigger("Fire");
            }
        }
        void Start()
        {
            //gameObject.name = netId.ToString();

            //Cursor.visible = false;

            shootBehaviour = GetComponentInParent <VehicleShootBehaviour>();

            rb = GetComponent <Rigidbody>();

            if (!rb)
            {
                rb = gameObject.AddComponent <Rigidbody>();
            }

            originalSpeed = MaxSpeed;
        }
Пример #4
0
        public bool Fire(VehicleShootBehaviour shootBehaviour)
        {
            //SINGLE-FIRE
            if (Input.GetMouseButtonDown(0))
            {
                if (!hasFired)
                {
                    Shoot(shootBehaviour);
                    hasFired = true;
                    return(true);
                }
            }
            else
            {
                semiauto_timer += Time.deltaTime;
                if (semiauto_timer >= SemiAutoFireRate)
                {
                    hasFired       = false;
                    semiauto_timer = 0.0f; //RESET THE TIMER
                    return(false);
                }
            }

            //AUTOMATIC FIRE
            //LIMIT THE RATE OF FIRE
            if (Input.GetMouseButton(0))
            {
                automatic_timer += Time.deltaTime;
                if (automatic_timer > AutomaticFireRate)
                {
                    Debug.Log("SHOT FIRED");
                    Shoot(shootBehaviour);
                    automatic_timer = 0.0f;
                    return(true);
                }
            }
            else
            {
                automatic_timer = 0.0f;
                return(false);
            }

            return(false);
        }
        void Start()
        {
            if (!isLocalPlayer)
            {
                return;
            }

            mode = new VehicleState {
                _mode = 0,
            };

            shootBehaviour = GetComponentInParent <VehicleShootBehaviour>();

            rb = GetComponent <Rigidbody>();

            if (!rb)
            {
                rb = gameObject.AddComponent <Rigidbody>();
            }
        }
Пример #6
0
 public abstract void Shoot(VehicleShootBehaviour shootBehaviour);