Example #1
0
    //"shooooooot!" -arnold schwarzenegger
    void Shoot()
    {
        if (Time.time > nextShot)
        {
            nextShot = Time.time + fireRate;

            GameObject instantiatedGameObjectShot = Instantiate(shot, shotSpawn.position, shotSpawn.rotation) as GameObject;
            instantiatedShot            = instantiatedGameObjectShot.GetComponent <MoveShot> ();
            instantiatedShot.playerNumb = playerNumb;
            if (OverKill == true)
            {
                instantiatedShot.overkill = true;
            }
            else
            {
                instantiatedShot.overkill = false;
            }

            if (Slayer == true)
            {
                instantiatedShot.shotSpeed     = 15.0f;
                instantiatedShot.damageToDeal *= 2.0f;
            }

            instantiatedShot.shotSpeed = 20.0f;
        }
    }
Example #2
0
    //--------------------------------
    // 3 - Shooting from another script
    //--------------------------------

    /// <summary>
    /// Create a new projectile if possible
    /// </summary>
    public void Attack(bool isEnemy)
    {
        if (CanAttack)
        {
            shootCooldown = shootingRate;

            // Create a new shot
            var shotTransform = Instantiate(shotPrefab) as Transform;

            // Assign position
            shotTransform.position = transform.position;

            // The is enemy property
            Shot shot = shotTransform.gameObject.GetComponent <Shot>();
            if (shot != null)
            {
                shot.isEnemyShot = isEnemy;
            }

            // Make the weapon shot always towards it
            MoveShot move = shotTransform.gameObject.GetComponent <MoveShot>();
            if (move != null)
            {
                move.direction = this.transform.right; // towards in 2D space is the right of the sprite
            }
        }
    }
Example #3
0
    void Shoot()
    {
        if (Time.time > nextShot)
        {
            nextShot = Time.time + fireRate;

            GameObject instantiatedGameObjectShot = Instantiate(bullet, shotspawn.position, shotspawn.rotation) as GameObject;
            instantiatedShot = instantiatedGameObjectShot.GetComponent <MoveShot> ();
            if (upgrade)
            {
                instantiatedShot.shotSpeed = 25.0f;
            }
            instantiatedShot.playerNumb   = playerNumb;
            instantiatedShot.damageToDeal = damageToDeal;
        }
    }
Example #4
0
    //stuff for spawning shot
    void SpawnTheBullet(Quaternion ang)
    {
        GameObject instantiatedGameObjectShot = Instantiate(shot, shotSpawn.position, ang) as GameObject;

        instantiatedShot              = instantiatedGameObjectShot.GetComponent <MoveShot> ();
        instantiatedShot.playerNumb   = playerNumb;
        instantiatedShot.damageToDeal = damageToDealWithShot;
        if (OverKill == true)
        {
            instantiatedShot.overkill = true;
        }
        else
        {
            instantiatedShot.overkill = false;
        }

        if (Slayer == true)
        {
            instantiatedShot.shotSpeed     = 15.0f;
            instantiatedShot.damageToDeal *= 2.0f;
        }
    }