Hey everyone! Currently working on the top down action pixel RPG course and I just wanted to stop for a moment and say that I was proud to modify the code from an if statement to a switch statement in my code! I feel like my game development skills are growing! Thank you guys!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickupSpawner : MonoBehaviour
{
[SerializeField] private GameObject goldCoinPrefab, healthGlobePrefab, staminaGlobePrefab;
public void DropItems()
{
int randomNum = Random.Range(1, 20);
switch (randomNum)
{
case 1:
int randomAmountOfGold = Random.Range(1,5);
for (int i = 0; i < randomAmountOfGold; i++)
{
Instantiate(goldCoinPrefab, transform.position, Quaternion.identity);
}
break;
case 2:
Instantiate(healthGlobePrefab, transform.position, Quaternion.identity);
break;
case 3:
Instantiate(staminaGlobePrefab, transform.position, Quaternion.identity);
break;
default:
break;
}
}
}