Example #1
0
        public bool Shoot()
        {
            if (!isSpecialWeapon && isNormallWeapon)
            {
                if (_isInCooldown)
                {
                    return(false);
                }

                // Get the projectile from the pool and set its position and rotation.
                Projectile projectile = LevelController.Current.GetProjectile(_owner.UnitType);
                if (projectile != null)
                {
                    projectile.transform.position = transform.position;
                    projectile.transform.rotation = transform.rotation;
                    projectile.Launch(this, transform.up);

                    // Go to the cooldown phase.
                    _isInCooldown = true;
                    // We just shot the projectile so time since shot is 0.
                    _timeSinceShot = 0;

                    return(true);
                }
                return(false);
            }
            Debug.Log(activetedWeapons);

            if (isSpecialWeapon && activetedWeapons && !isNormallWeapon)
            {
                if (_isInCooldown)
                {
                    return(false);
                }

                // Get the projectile from the pool and set its position and rotation.
                Projectile projectile = LevelController.Current.GetProjectile(_owner.UnitType);
                if (projectile != null)
                {
                    projectile.transform.position = transform.position;
                    projectile.transform.rotation = transform.rotation;
                    projectile.Launch(this, transform.up);

                    // Go to the cooldown phase.
                    _isInCooldown = true;
                    // We just shot the projectile so time since shot is 0.
                    _timeSinceShot      = 0;
                    _timeSinceActivated = 0;

                    return(true);
                }
                return(false);
            }
            return(false);
        }
Example #2
0
        public bool Shoot()
        {
            if (_isInCooldown)
            {
                return(false);
            }
            Projectile projectile = Instantiate(_projectilePrefab, transform.position, transform.rotation);

            projectile.Launch(transform.up);

            _isInCooldown  = true;
            _timeSinceShot = 0;

            return(true);
        }
        public bool Shoot()
        {
            if (_isInCooldown)
            {
                return(false);
            }
            Projectile projectile = LevelController.Current.GetProjectile(_owner.UnitType);

            if (projectile != null)
            {
                projectile.transform.position = transform.position;
                projectile.transform.rotation = transform.rotation;
                projectile.Launch(this, transform.up);
            }
            //Projectile projectile = Instantiate(_projectilePrefab, transform.position, transform.rotation);
            _isInCooldown  = true;
            _timeSinceShot = 0f;
            return(true);
        }
Example #4
0
        public bool Shoot()
        {
            if (_isInCooldown)
            {
                return(false);
            }

            // Instantiate Projectile object and launch it.
            Projectile projectile =
                Instantiate(_projectilePrefab, transform.position, transform.rotation);

            projectile.Launch(transform.up);

            // Go to the cooldown phase.
            _isInCooldown = true;
            // We just shot the projectile so time since shot is 0.
            _timeSinceShot = 0;

            return(true);
        }
Example #5
0
        public bool Shoot()
        {
            if (_isInCooldown)
            {
                return(false);
            }

            // Get the projectile from the pool and set its position and rotation.
            Projectile projectile = LevelController.Current.GetProjectile(_owner.UnitType);

            if (projectile != null)
            {
                projectile.transform.position = transform.position;
                projectile.transform.rotation = transform.rotation;
                projectile.Launch(this, transform.up);

                _isInCooldown  = true;
                _timeSinceShot = 0;

                return(true);
            }
            return(false);
        }
Example #6
0
        public bool Shoot()
        {
            if (_IsInCoolDown)
            {
                return(false);
            }

            //Projectile projectile =
            //    Instantiate(_ProjectilePrefab, transform.position, transform.rotation);
            //projectile.Launch(transform.up, this);
            Projectile projectile = LevelController.Current.GetProjectile(_Owner.UnitType);

            if (projectile != null)
            {
                projectile.transform.position = transform.position;
                projectile.transform.rotation = transform.rotation;
                projectile.Launch(transform.up, this);
            }
            _IsInCoolDown  = true;
            _timeSinceShot = 0;

            return(true);
        }
Example #7
0
        /// <summary>
        /// Makes the weapon fire a projectile.
        /// </summary>
        /// <returns>was the shot successfully fired</returns>
        public bool Shoot()
        {
            // Checks if the weapon is in cooldown phase
            // and if so, returns false for canceled shot
            if (isInCooldown || !initialWaitOver)
            {
                return(false);
            }

            // Gets an inactive projectile from the projectile pool
            Projectile projectile = owner.GetPooledProjectile();

            // If there is a projectile, it is initialized and launched
            if (projectile != null)
            {
                // Sets the projectile's starting position
                projectile.transform.position = transform.position;

                // Sets the projectile's rotation
                projectile.transform.rotation = transform.rotation;

                // Launches the projectile
                projectile.Launch(this, transform.up, projectileSpeed);

                // Goes to the cooldown phase
                isInCooldown = true;

                // Resets the time since shot
                elapsedWaitTime = 0f;

                // The shot is successful -> returns true
                return(true);
            }

            // The shot is unsuccessful -> returns false
            return(false);
        }