private void SendCommand(GameCommand command) { if (currentCommand) { Debug.LogError("Can't send command while awaiting response."); return; } GameObject commandPrefab = null; if (command.CommandPrefabName != null) { commandPrefab = commandPrefabs.GetPrefab(command.CommandPrefabName); if (commandPrefab == null) { Debug.LogError("Command specified a prefab, but one was not found by that name: " + command.CommandPrefabName); } } if (commandPrefab != null) { GameObject go = Instantiate(commandPrefab); currentCommand = go.GetComponent <CommandBehaviour>(); go.transform.parent = transform; if (currentCommand == null) { Debug.LogError("Command prefab missing CommandBehaviour"); } currentCommand.Command = command; } validPlays = null; if (commandFilter != null) { commandFilter.HandleCommand(command); } GameClient.Instance.SendRequest(command); }
public GameObject SpawnCard(string prefabName, EntityView entityData) { GameObject prefab = prefabStore.GetPrefab(prefabName); if (prefab == null) { throw new System.Exception("Could not find prefab '" + prefabName + "'"); } GameObject go = Instantiate(prefab); GameEntity entity = go.GetComponent <GameEntity>(); if (entity == null) { Debug.LogError("Entity prefab lacked " + typeof(GameEntity).ToString() + " component"); Destroy(go); return(null); } entity.EntityView = entityData; AddEntity(entity); return(go); }