Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        manager = GetComponent <PowerUpManager>();

        // good powerups
        scoreMultiplier = holder.AddComponent <ScorePowerUp>();
        killEnemies     = holder.AddComponent <KillEnemiesPowerUp>();
        quickfire       = holder.AddComponent <QuickfirePowerUp>();

        //bad powerups
        barrage     = holder.AddComponent <BarragePowerUp>();
        fastEnemies = holder.AddComponent <FastEnemiesPowerUp>();
        moveTargets = holder.AddComponent <MoveTargetsPowerUp>();

        // random powerups
        explode    = holder.AddComponent <ExplodePowerUp>();
        bounce     = holder.AddComponent <BouncyPowerUp>();
        bigObjects = holder.AddComponent <BigObjectsPowerUp>();

        goodPowerUps = new PowerUp[3] {
            scoreMultiplier, killEnemies, quickfire
        };

        badPowerUps = new PowerUp[3] {
            barrage, fastEnemies, moveTargets
        };

        randomPowerUps = new PowerUp[3] {
            explode, bounce, bigObjects
        };
    }
Ejemplo n.º 2
0
    public void SpawnPickUp(PlayerInteractions playerInteractions)
    {
        float      randomPosX         = Random.Range(colliderPos.x - Boxcollider.size.x / 2, colliderPos.x + Boxcollider.size.x / 2);
        float      randomPosY         = Random.Range(colliderPos.y - Boxcollider.size.y / 2, colliderPos.y + Boxcollider.size.y / 2);
        GameObject SpawnItem          = PickUpPrefabs[Random.Range(0, PickUpPrefabs.Length)];
        GameObject instantiatedObject = Instantiate(SpawnItem, new Vector3(randomPosX, randomPosY), Quaternion.identity, GameObject.FindGameObjectWithTag("Canvas").transform);

        if (instantiatedObject.tag == "ScorePickup")
        {
            ScorePowerUp scorePowerUp = instantiatedObject.GetComponent <ScorePowerUp>();
            scorePowerUp.playerInteractions = playerInteractions;
            scorePowerUp.SetUi();
        }
        else if (instantiatedObject.tag == "TimePowerUp")
        {
            TimePoweUp timePoweUp = instantiatedObject.GetComponent <TimePoweUp>();
            timePoweUp.playerInteractions = playerInteractions;
            timePoweUp.SetUi();
        }
    }