Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(powerupType_prop);
        PowerupInfo.Type type = (PowerupInfo.Type)powerupType_prop.enumValueIndex;

        switch (type)
        {
        case PowerupInfo.Type.FasterReload:
            EditorGUILayout.PropertyField(duration_prop);
            EditorGUILayout.PropertyField(reloadTimeFactor_prop);
            break;

        case PowerupInfo.Type.DamageBoost:
            EditorGUILayout.PropertyField(duration_prop);
            EditorGUILayout.PropertyField(damageBoostFactor_prop);
            break;

        case PowerupInfo.Type.MovementSpeedBoost:
            EditorGUILayout.PropertyField(duration_prop);
            EditorGUILayout.PropertyField(movementSpeedBoostFactor_prop);
            break;

        case PowerupInfo.Type.TemporaryBonusHP:
            EditorGUILayout.PropertyField(duration_prop);
            EditorGUILayout.PropertyField(bonusHP_prop);
            break;

        case PowerupInfo.Type.AutoHPRegen:
            EditorGUILayout.PropertyField(duration_prop);
            EditorGUILayout.PropertyField(regenerationAmountPerSec_prop);
            break;

        case PowerupInfo.Type.ScattershotWeapon:
            EditorGUILayout.PropertyField(duration_prop);
            break;

        case PowerupInfo.Type.BarrelBombweapon:
            EditorGUILayout.PropertyField(duration_prop);
            break;

        default:
            break;
        }

        serializedObject.ApplyModifiedProperties();
    }
    public void ActivatePowerup(PowerupInfo powerupInfo)
    {
        _powerupTimer  = powerupInfo.duration;
        _activePowerup = powerupInfo.powerupType;

        switch (_activePowerup)
        {
        case PowerupInfo.Type.FasterReload:
            for (int i = 0; i < _cannonballSpawners.Length; i++)
            {
                _cannonballSpawners[i].ChangeCooldown(powerupInfo.reloadTimeFactor);
            }

            _bombSpawner.ChangeCooldown(powerupInfo.reloadTimeFactor);
            break;

        case PowerupInfo.Type.DamageBoost:
            for (int i = 0; i < _cannonballSpawners.Length; i++)
            {
                _cannonballSpawners[i].ChangeDamage(powerupInfo.damageBoostFactor);
            }

            _bombSpawner.ChangeDamage(powerupInfo.reloadTimeFactor);
            break;

        case PowerupInfo.Type.MovementSpeedBoost:
            _shipMovement.ChangeMaxSpeed(powerupInfo.movementSpeedBoostFactor);
            break;

        case PowerupInfo.Type.TemporaryBonusHP:
            _healthScript.AddTempHP(powerupInfo.bonusHP);
            break;

        case PowerupInfo.Type.AutoHPRegen:
            _healthScript.ApplyRegeneration(powerupInfo.duration, powerupInfo.regenerationAmountPerSec);
            break;

        default:
            break;
        }
    }
    public void DeactivatePickup()
    {
        switch (_activePowerup)
        {
        case PowerupInfo.Type.FasterReload:
            for (int i = 0; i < _cannonballSpawners.Length; i++)
            {
                _cannonballSpawners[i].ResetCooldown();
            }

            _bombSpawner.ResetCooldown();
            break;

        case PowerupInfo.Type.DamageBoost:
            for (int i = 0; i < _cannonballSpawners.Length; i++)
            {
                _cannonballSpawners[i].ResetDamage();
            }

            _bombSpawner.ResetDamage();
            break;

        case PowerupInfo.Type.MovementSpeedBoost:
            _shipMovement.ResetMaxSpeed();
            break;

        case PowerupInfo.Type.TemporaryBonusHP:
            _healthScript.RemoveTempHP();
            break;

        default:
            break;
        }

        _activePowerup = PowerupInfo.Type.None;
    }