Exemplo n.º 1
0
    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);
    }