Example #1
0
 private void Awake()
 {
     if (gainsController)
     {
         Destroy(this);
     }
     else
     {
         gainsController = this;
         UpdateGains(defaultGains, false);
     }
 }
 private void Start()
 {
     APIController   = ApiController.GetApiController();
     gainsController = GainsController.GetInstance();
 }
    public IEnumerator LoadNode(Node node)
    {
        if (node == null)
        {
            Debug.LogError("node == null");
            yield break;
        }

        missionProblem.text = node.dialog;
        ClearOptions();


        if (node.speaker == "player")
        {
            playerAvatar.gameObject.SetActive(true);
            alienAvatar.gameObject.SetActive(false);
        }
        else
        {
            playerAvatar.gameObject.SetActive(false);
            alienAvatar.gameObject.SetActive(true);
        }


        GainsController.GetInstance().UpdateGains(node.gains);
        Debug.Log(node);
        Debug.Log(node.options);
        if (node.options.Count == 0)
        {
            EndMission(node);
        }
        else
        {
            if (node.options.Count == 1)
            {
                Node optionNode = node.options[0];
                StartCoroutine(ResponseDialogue(optionNode.speaker, optionNode.option_player_dialog, optionNode));
            }
            else
            {
                foreach (Node optionNode in node.options)
                {
                    var option = Instantiate(optionPrefab, choicesPanel.transform);
                    option.name = "Option" + optionNode.id;

                    string dialogText = node.options.Count == 1 ? "->" : optionNode.id + ": " + optionNode.dialog;
                    if (optionNode.unlocking_trust > GainsController.GetInstance().GetGains().GetTrust())
                    {
                        dialogText = "Locked";
                    }
                    option.GetComponentInChildren <TMP_Text>().text = dialogText;
                    option.GetComponent <Button>().onClick.AddListener(() =>
                    {
                        StartCoroutine(
                            optionNode.option_player_dialog == "" ?
                            GetNode(optionNode.id, (Node node) => StartCoroutine(LoadNode(node)))
                            :
                            ResponseDialogue("player", optionNode.option_player_dialog, optionNode)
                            );
                    });
                    options.Add(option.gameObject);
                }
            }
        }
    }
Example #4
0
 private void Start()
 {
     gainsController = GainsController.GetInstance();
 }
Example #5
0
 private void Start()
 {
     gainsController = GainsController.GetInstance();
     StartCoroutine(GetToken(API_USERNAME, API_PASS));
 }