static Interfacing.EntityHandle CreateEntity(Entity ent) { string prefabPath = "Prefabs/" + ent.entityClass.ToString() + "/"; switch (ent.entityClass) { case EntityClass.Character: prefabPath += ((CharacterType)ent.entityType).ToString(); break; case EntityClass.Rune: prefabPath += ((RuneType)ent.entityType).ToString(); break; case EntityClass.Collectible: prefabPath += ((CollectibleType)ent.entityType).ToString(); break; case EntityClass.SpellEffect: prefabPath += ((SpellEffectType)ent.entityType).ToString(); break; case EntityClass.Mech: prefabPath += ((MechType)ent.entityType).ToString(); break; } GameObject obj = Instantiate((GameObject)Resources.Load(prefabPath)); obj.transform.SetParent(GameObject.Find("Entities").transform, false); obj.SetActive(false); var handle = new Interfacing.EntityHandle() { idx = (uint)entities.Count }; var objGr = obj.GetComponent <EntityGraphics>(); objGr.entity = ent; objGr.entityType = ent.entityType; entities.Add(handle, obj); return(handle); }
static void PerformInterfaceUpdateRotation(Interfacing.EntityHandle objHandle, uint dir) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().UpdateInterfaceRotation(dir); }
static void PerformInterfaceDie(Interfacing.EntityHandle objHandle) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().Die(); }
static void PerformInterfaceUpdateHP(Interfacing.EntityHandle objHandle, float currentHP, float maxHP) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().UpdateHP(currentHP, maxHP); }
static void PerformInterfaceDamage(Interfacing.EntityHandle objHandle, float dmg) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().Damage(dmg); }
static void PerformInterfaceStop(Interfacing.EntityHandle objHandle, HexXY pos) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().Stop(pos); }
static void PerformInterfaceMovePrecise(Interfacing.EntityHandle objHandle, Vector2 pos, float timeToGetThere) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().MovePrecise(pos, timeToGetThere); }
static void PerformInterfaceSpawn(Interfacing.EntityHandle objHandle, HexXY pos, uint dir) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().Spawn(pos, dir); }
void PerformInterfaceTeleport(Interfacing.EntityHandle objHandle, HexXY to) { GameObject obj = entities[objHandle]; obj.GetComponent <EntityGraphics>().Teleport(to); }