Initial import
This commit is contained in:
parent
71fb5e578f
commit
3cb9eb5031
69 changed files with 4197 additions and 0 deletions
37
Assets/Battle/MonsterDatabase.cs
Normal file
37
Assets/Battle/MonsterDatabase.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue