mixedcards/Assets/Battle/MonsterDatabase.cs
henriquenakashima 3cb9eb5031 Initial import
2020-09-17 22:52:50 -04:00

37 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum MonsterId {
Bat,
Golem,
}
public class MonsterDatabase
{
private static Dictionary<MonsterId, string> SPRITE_NAMES = new Dictionary<MonsterId, string> {
{MonsterId.Bat, "BatSprite"},
{MonsterId.Golem, "GolemSprite"},
};
public static BattleMonster createMonsterScript(MonsterId id) {
switch (id)
{
case MonsterId.Bat:
return new BatMonster();
case MonsterId.Golem:
return new GolemMonster();
default:
throw new System.ArgumentException("MonsterId unknown", "id");
}
}
public static GameObject createMonsterSprite(MonsterId id) {
GameObject spritePrefab = (GameObject) Resources.Load<GameObject>("MonsterImages/" + SPRITE_NAMES[id]);
if (spritePrefab == null) {
throw new System.ArgumentException("No sprite for MonsterId", "id");
}
return GameObject.Instantiate(spritePrefab);
}
}