예제 #1
0
    public void SpawnPowerUp(Vector3 position)
    {
        int             randomPowerupType = Random.Range(0, 2);
        var             powerUp           = Instantiate(PowerUpPrefab, powerups);
        PowerUpGainType randomType        = (randomPowerupType == 0) ? PowerUpGainType.Canons : PowerUpGainType.Speed;

        powerUp.GetComponent <PowerUp>().SetType(randomType);
        powerUp.transform.position = position;
    }
예제 #2
0
    public void SetType(PowerUpGainType type)
    {
        PowerUpType = type;
        switch (PowerUpType)
        {
        case PowerUpGainType.Canons:
            transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.red;
            break;

        case PowerUpGainType.Speed:
            transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.yellow;
            break;
        }
        //transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = Skins[(int)PowerUpType];
    }
예제 #3
0
    private void PowerUpCollected(PowerUpGainType type)
    {
        switch (type)
        {
        case PowerUpGainType.Canons:
            int newWeapon = Mathf.Clamp(currentWeapon + 1, 0, transform.childCount);
            EnableWeapon(newWeapon);
            break;

        case PowerUpGainType.Speed:
            UpgradeShootSpeed();
            break;
        }
        UiManager.Instance.RestartPowerUp(PowerUpDuration);
    }