Beispiel #1
0
    void Update()
    {
        //Check for powerup application
        if (Input.GetKeyDown(KeyCode.Space))
        {
            switch (this.current_powerup)
            {
            case PowerUp.Powerups.Chains:
                LaunchChains();
                break;

            case PowerUp.Powerups.Thunder:
                LaunchThunder();
                break;

            case PowerUp.Powerups.Bricks:
                LaunchBricks();
                break;

            default:
                break;
            }

            this.current_powerup = PowerUp.Powerups.None;
        }

        //Check highest block
        float max_height = 0;

        foreach (GameObject g in blockList)
        {
            if (g.tag == "set")
            {
                if (max_height < g.transform.position.y)
                {
                    max_height = g.transform.position.y;
                }
            }
        }

        //Move camera according to previous check
        if (spawner.transform.position.y - 15 > max_height)
        {
            DownSpawnnerAndCam();
        }
        else if (spawner.transform.position.y - 13 < max_height)
        {
            UpSpawnnerAndCam();
        }
    }
Beispiel #2
0
    private void AddPowerUp()
    {
        Array values = Enum.GetValues(typeof(PowerUp.Powerups));

        System.Random random = new System.Random();
        int           rand   = random.Next(values.Length);

        //Avoid getting "None"
        while (rand == 0)
        {
            rand = random.Next(values.Length);
        }

        this.current_powerup = (PowerUp.Powerups)values.GetValue(rand);
        //this.current_powerup = PowerUp.Powerups.Bricks; //Used for debug
    }
Beispiel #3
0
    void Start()
    {
        blockList = new List <GameObject>();
        powerUp   = this.GetComponent <PowerUp>();

        //Set camera movement distance
        up_distance   = 20f;
        down_distance = 30f;

        //Set player stats
        current_health       = max_health;
        score                = 0;
        next_score_for_pwr   = next_score_for_pwr_add_value;
        last_loss_brick_time = Time.time + cooldown_duration;

        //Set current power up
        current_powerup = PowerUp.Powerups.None;

        //Spawn first brick
        Spawn();
    }