void GenerateAbilityRocketBarragePool(int quantity)
    {
        print("Created " + quantity + " AbilityRocketBarrage");

        for (int currentObject = 0; currentObject < quantity; currentObject++)
        {
            GameObject           instantiatedObject   = gameManager.InstantiateObject(abilityRocketBarragePrefab, transform, 0.0f, 30.0f, 0.0f, 1.0f, 1.0f, 1.0f);
            AbilityRocketBarrage abilityRocketBarrage = instantiatedObject.GetComponent <AbilityRocketBarrage>();
            abilityRocketBarrage.prefabPools = this;
            abilityRocketBarrage.gameManager = gameManager;
            abilityRocketBarrage.StartSetup();
            //abilityRocketBarrage.PushOnStack();
        }
    }
Beispiel #2
0
    IEnumerator OnMouseDown()
    {
        int moduleType = Mathf.FloorToInt(whichModule / 5);

        if (topPanel.moduleEnergyCurrent[moduleType] >= energyCost)
        {
            ToggleCollider(false);
            switch (whichModule)
            {
            case 0:     //Rocket Barrage
                float numberRocketsToFire = Mathf.Floor(topPanel.moduleEnergyCurrent[0] / energyCost);
                for (int rocketNumber = 0; rocketNumber < numberRocketsToFire; rocketNumber++)
                {
                    AbilityRocketBarrage abilityRocketBarrage = gameManager.prefabPools.PopAbilityRocketBarrage();
                    if (abilityRocketBarrage != null)
                    {
                        abilityRocketBarrage.enabled = true;
                        abilityRocketBarrage.PopOffStack(ship.transform);
                    }

                    topPanel.DecreaseEnergy(energyCost, 0);
                    yield return(new WaitForSeconds(0.08f));
                }
                ToggleCollider(true);
                break;

            case 1:      //Super Laser
                //if (gameManager.space.enemy != null && topPanel.moduleEnergyCurrent[0] >= energyCost)
                if (gameManager.space.enemy.Count > 0.0f || gameManager.prefabPools.stackAsteroid.Count < 5.0f)
                {
                    if (ability01 == null)
                    {
                        GameObject instantiatedAbility = gameManager.InstantiateObject(ability01Prefab, ship.shipAnimation.transform, -0.05f, 0, 0, 0.9f, 0.8f, 1.0f);
                        ability01         = instantiatedAbility.GetComponent <Ability01>();
                        ability01.enabled = true;
                        ability01.ability = this;
                        ability01.space   = gameManager.space;
                        ability01.StartSetup();
                    }
                    else
                    {
                        ability01.enabled = true;
                    }

                    ability01.ActivateModule();

                    topPanel.DecreaseEnergy(energyCost, 0);
                }
                else
                {
                    ToggleCollider(true);
                }
                break;

            case 2:      //Corrosion
                ship.ShootArmamentPrimary(Mathf.CeilToInt(gameManager.upgradeValues[20, PlayerStats.playerStats.upgradeStatus[20]]), PlayerStats.playerStats.upgradeStatus[35], 1);
                topPanel.DecreaseEnergy(energyCost, 0);
                ToggleCollider(true);
                break;

            case 3:      //Ram
                ship.ActivateRam();
                topPanel.DecreaseEnergy(energyCost, 0);
                break;

            case 4:      //Mines
                float numberMinesToLaunch = Mathf.Floor(topPanel.moduleEnergyCurrent[0] / energyCost);
                for (int mineNumber = 0; mineNumber < numberMinesToLaunch; mineNumber++)
                {
                    ModuleMines moduleMines = gameManager.prefabPools.PopModuleMines();
                    if (moduleMines != null)
                    {
                        moduleMines.enabled = true;
                        moduleMines.PopOffStack(ship.transform);
                    }

                    topPanel.DecreaseEnergy(energyCost, 0);
                    yield return(new WaitForSeconds(0.08f));
                }
                ToggleCollider(true);
                break;

            case 5:      //Black Hole
                if (abilityBlackHole == null)
                {
                    GameObject instantiatedAbility = gameManager.InstantiateObject(abilityBlackHolePrefab, gameManager.space.transform, 1.9f, 0, 0, 1.0f, 1.0f, 1.0f);
                    abilityBlackHole         = instantiatedAbility.GetComponent <AbilityBlackHole>();
                    abilityBlackHole.ability = this;
                    abilityBlackHole.enabled = true;
                    abilityBlackHole.StartSetup();
                }
                else
                {
                    abilityBlackHole.enabled = true;
                }
                abilityBlackHole.ActivateModule();
                topPanel.DecreaseEnergy(energyCost, 1);
                break;

            case 6:      //Reflective Shield
                ship.ActivateReflectiveShield();
                break;

            case 7:      //Side Drones
                ship.ActivateSideDrones();
                break;

            case 8:      //Repair Bots
                ship.ActivateNanobots();
                break;

            case 9:      //Redirect
                ship.ActivateModuleRedirect();

                topPanel.DecreaseEnergy(energyCost, 1);
                break;

            case 10:      //Destablize
                if (abilityScrapColumn == null)
                {
                    GameObject instantiatedAbility = gameManager.InstantiateObject(abilityScrapColumnPrefab, gameManager.transformBoard.transform, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
                    abilityScrapColumn         = instantiatedAbility.GetComponent <AbilityScrapColumn>();
                    abilityScrapColumn.enabled = true;
                    abilityScrapColumn.ability = this;
                    abilityScrapColumn.StartSetup();
                }
                else
                {
                    abilityScrapColumn.enabled = true;
                }
                abilityScrapColumn.ActivateModule();

                topPanel.DecreaseEnergy(energyCost, 2);
                break;

            case 11:      //Shuffle
                topPanel.DecreaseEnergy(energyCost, 2);
                StartCoroutine(gameManager.board.Shuffle());
                yield return(new WaitForSeconds(1.6f));

                ToggleCollider(true);
                break;

            case 12:      //Empower
                topPanel.DecreaseEnergy(energyCost, 2);
                int iconsToEmpower = (int)gameManager.upgradeValues[30, PlayerStats.playerStats.upgradeStatus[30]];
                for (int empowerNumber = 0; empowerNumber < iconsToEmpower; empowerNumber++)
                {
                    int  attempts = 49;
                    int  randRow;
                    int  randColumn;
                    Icon icon;
                    do
                    {
                        randRow    = Random.Range(0, Board.GridRows);
                        randColumn = Random.Range(0, Board.GridColumns);
                        icon       = board.boardIcons[randColumn, randRow];
                        attempts--;
                    } while (icon.currentEffectMultiplier > 1.0f && attempts > 0);
                    icon.ActivateEmpower();
                }
                ToggleCollider(true);
                break;

            case 13:      //Energy Conversion
                ship.ActivateEnergyConversion();
                break;

            case 14:      //Shatter
                yield return(StartCoroutine(board.ActivateModuleShatter()));

                topPanel.DecreaseEnergy(energyCost, 2);
                ToggleCollider(true);
                break;
            }
        }
    }