Exemplo n.º 1
0
    void Toggle_Shoot()
    {
        // var so player cant shoot when paused
        GameObject ship = GameObject.FindWithTag("Ship");

        if (ship != null)
        {
            // get scripts for each type of shot
            ShipFire       shootScript  = ship.GetComponent <ShipFire>();
            ShipDoubleShot doubleScript = ship.GetComponent <ShipDoubleShot>();
            ShipLongShot   longScript   = ship.GetComponent <ShipLongShot>();
            // then toggle them
            if (shootScript.ToggleShot == true && doubleScript.ToggleShot == true && longScript.ToggleShot == true)
            {
                shootScript.ToggleShot  = false;
                doubleScript.ToggleShot = false;
                longScript.ToggleShot   = false;
            }
            else if (shootScript.ToggleShot == false && doubleScript.ToggleShot == false && longScript.ToggleShot == false)
            {
                shootScript.ToggleShot  = true;
                doubleScript.ToggleShot = true;
                longScript.ToggleShot   = true;
            }
        }
    }
Exemplo n.º 2
0
    // Long Shot
    public void Power4()
    {
        // find the ship
        GameObject ship = GameObject.FindWithTag("Ship");
        // get the shoot scripts
        ShipFire       singleFire = ship.GetComponent <ShipFire> ();
        ShipDoubleShot doubleShot = ship.GetComponent <ShipDoubleShot> ();
        ShipLongShot   longShot   = ship.GetComponent <ShipLongShot> ();

        // Disable single fire and doubleshot
        singleFire.enabled = false;
        doubleShot.enabled = false;
        // Enable longshot
        longShot.enabled = true;
    }