Exemple #1
0
 public void Execute(AppCallback appCallback)
 {
     if (appCallback.AppExecution)
     {
         AppExecutionModule.Instance.Execute(appCallback.AppExecution);
     }
     if (appCallback.CallbackFuntion != null)
     {
         appCallback.CallbackFuntion.Invoke(appCallback.CallbackFuntion.Args);
     }
 }
Exemple #2
0
            public void RequestAppInfo(uint appid, AppCallback callback)
            {
                // Callback for Application Information
                Action <SteamApps.PICSProductInfoCallback> AppCallback = (appinfo) =>
                {
                    var returnData = appinfo.Apps.Where(x => x.Key == appid);
                    if (returnData.Count() == 1)
                    {
                        // Return successful data
                        callback(returnData.First().Value);
                        return;
                    }

                    callback(null);
                };

                // Callback for Token
                Action <SteamApps.PICSTokensCallback> TokenCallback = (apptoken) =>
                {
                    // Check if our token was returned
                    var ourToken = apptoken.AppTokens.Where(x => x.Key == appid);
                    if (ourToken.Count() != 1)
                    {
                        return;
                    }

                    // Use our token to request the app information
                    var Request = new SteamApps.PICSRequest(appid)
                    {
                        AccessToken = ourToken.First().Value,
                        Public      = false
                    };

                    _CManager.Subscribe(_Apps.PICSGetProductInfo(new List <SteamApps.PICSRequest>()
                    {
                        Request
                    }, new List <SteamApps.PICSRequest>()), AppCallback);
                };

                // Fire Token Callback
                _CManager.Subscribe(_Apps.PICSGetAccessTokens(new List <uint>()
                {
                    appid
                }, new List <uint>()), TokenCallback);
            }
    //this function isn't currently being used
    //List<TextMsgObj> ListFutureTexts (TextMsgObj currTextObj)
    //{
    //    List<TextMsgObj> futureTexts = new List<TextMsgObj>();
    //    foreach (AppCallback call in currTextObj.nextText)
    //    {
    //        if (call != null &&
    //            call.AppExecution != null &&
    //            call.AppExecution.GetType() == typeof(TextMsgObj) &&
    //            call.AppExecution.ExecutingApp == Utility.App.Text)
    //            futureTexts.Add(GetText(call));
    //    }

    //    return futureTexts;
    //}

    public void ProcessChoice(int i)
    {
        if (AppCallbackModule.Instance)
        {
            //TextMsgObj currTextObj = GetText(currText);
            string[]      nextMessage;
            AppCallback[] nextCallback;
            if (TextMsgObjManager.TryGetCallback(CurrentSpeaker, out nextMessage, out nextCallback))
            {
                choiceText1.text           = "";
                choiceText2.text           = "";
                choiceButton1.interactable = false;
                choiceButton2.interactable = false;
                justMadeChoice             = true;
                //currText = currTextObj.nextText[i];
                TextMsgObjManager.OnFinish(CurrentSpeaker);
                //currTextObj = GetText(currText);
                AppCallback NextExecution = nextCallback[i];
                //currText = null;
                //textAppController.ExecuteScriptableObject(GetText(currText));
                AppCallbackModule.Instance.Execute(NextExecution);
                //StartCoroutine(ShowText(currTextObj, true));
            }
        }
        else
        {
            //choiceText1.text = "";
            //choiceText2.text = "";
            //choiceButton1.interactable = false;
            //choiceButton2.interactable = false;
            ////SetText(GetText(currText.nextText[i]));
            ////currTextObj = GetText(currText);
            //justMadeChoice = true;
            ////textAppController.ExecuteScriptableObject(currTextObj);
            ////AppCallbackModule.Instance.Execute(currText.nextText[i]);
            //StartToShowText();
        }
        AudioManager.Instance.Play(AudioEnum.Button_Default);
        needDecisionMaking = false;
        StartCoroutine(textVisualizer.CollapsePanel(true));
    }
Exemple #4
0
        public void RequestAppInfo(uint appid, AppCallback callback)
        {
            // Callback for Application Information
            Action<SteamApps.PICSProductInfoCallback> AppCallback = (appinfo) =>
            {
                var returnData = appinfo.Apps.Where( x => x.Key == appid );
                if( returnData.Count() == 1 )
                {
                    // Return successful data
                    callback( returnData.First().Value );
                    return;
                }

                callback(null);
            };

            // Callback for Token
            Action<SteamApps.PICSTokensCallback> TokenCallback = (apptoken) =>
            {
                // Check if our token was returned
                var ourToken = apptoken.AppTokens.Where( x => x.Key == appid );
                if( ourToken.Count() != 1 ) return;

                // Use our token to request the app information
                var Request = new SteamApps.PICSRequest(appid)
                {
                    AccessToken = ourToken.First().Value,
                    Public = false
                };

                _CManager.Subscribe( _Apps.PICSGetProductInfo(new List<SteamApps.PICSRequest>() {Request}, new List<SteamApps.PICSRequest>()), AppCallback);
            };

            // Fire Token Callback
            _CManager.Subscribe(_Apps.PICSGetAccessTokens(new List<uint>() {appid}, new List<uint>()), TokenCallback);
        }
    void AdvanceTexts()
    {
        if (AppCallbackModule.Instance)
        {
            //TextMsgObj currTextObj = GetText(currText);
            //List<TextMsgObj> futureTexts = ListFutureTexts(currTextObj);
            string[]      nextMessage;
            AppCallback[] nextCallback;
            if (TextMsgObjManager.TryGetCallback(CurrentSpeaker, out nextMessage, out nextCallback))
            {
                if (nextCallback == null || nextCallback.Length == 0) //conversation ended
                {
                    //currText = null;
                    justMadeChoice = false;
                    if (NotificationController.Instance)
                    {
                        NotificationController.Instance.HideNotification(Utility.App.Text, CurrentSpeaker);
                    }
                    TextMsgObjManager.OnFinish(CurrentSpeaker);
                    return;
                }

                else if (nextCallback.Length == 1) //linear conversation
                {
                    //currText = GetText(currText.nextText[0]);
                    //currTextObj = GetText(currText);
                    justMadeChoice = false;
                    AppCallback NextExecution = nextCallback[0];
                    //currText = null;
                    //textAppController.ExecuteScriptableObject(GetText(currText));
                    TextMsgObjManager.OnFinish(CurrentSpeaker);
                    AppCallbackModule.Instance.Execute(NextExecution);
                    if (NotificationController.Instance && NextExecution.AppExecution == null)
                    {
                        NotificationController.Instance.HideNotification(Utility.App.Text, CurrentSpeaker);
                    }
                    //StartCoroutine(ShowText(currTextObj, false));
                }

                else if (nextCallback.Length == 2) //player makes a dialogue choice
                {
                    StartCoroutine(textVisualizer.CollapsePanel(false));
                    Invoke("ShowButtons", textVisualizer.panelCollapseTime);
                    needDecisionMaking = true;
                }
            }
        }
        else
        {
            //if (currText.nextText == null || currText.nextText.Length == 0) //conversation ended
            //{
            //    currText = null;
            //    return;
            //}

            //else if (currText.nextText.Length == 1) //linear conversation
            //{
            //    //currTextObj = GetText(currText);
            //    justMadeChoice = false;
            //    //textAppController.ExecuteScriptableObject(GetText(currText));
            //    //AppCallbackModule.Instance.Execute(currText.nextText[0]);
            //    //StartCoroutine(ShowText(currTextObj, false));
            //    //SetText(GetText(currText.nextText[0]));
            //    StartToShowText();
            //}

            //else if (currText.nextText.Length == 2) //player makes a dialogue choice
            //{
            //    StartCoroutine(textVisualizer.CollapsePanel(false));
            //    Invoke("ShowButtons", textVisualizer.panelCollapseTime);
            //    needDecisionMaking = true;
            //}
        }
    }
    public AppExecution FetchSituation(int clusterID, int situationID, string id, string app, LocalDb SitDB)
    {
        System.Data.IDataReader reader;
        switch (app)
        {
        case "Text":
            reader = SitDB.getDataByString(app.ToString(), id);
            TextMsgObj tempTextObj = ScriptableObject.CreateInstance <TextMsgObj>();
            while (reader.Read())
            {
                //Fetch data into entity
                TextEntity entity = new TextEntity(reader[0].ToString(),
                                                   reader[1].ToString(),
                                                   reader[2].ToString(),
                                                   reader[3].ToString(),
                                                   reader[4].ToString(),
                                                   reader[5].ToString(),
                                                   reader[6].ToString(),
                                                   reader[7].ToString(),
                                                   reader[8].ToString(),
                                                   reader[9].ToString(),
                                                   reader[10].ToString());

                //Split message by linebreaker
                var splitted = entity._Content.Split('\n');
                tempTextObj.message = new string[splitted.Length];
                for (int i = 0; i < splitted.Length; i++)
                {
                    tempTextObj.message[i] = splitted[i];
                }

                string[] NextList = entity._Next.Split(',');
                tempTextObj.AppExe_Id     = entity._id;
                tempTextObj.speaker       = entity._Speaker;
                tempTextObj.nextText      = new AppCallback[NextList.Length];
                tempTextObj.nextmessage   = new string[NextList.Length];
                tempTextObj.playerTalking = entity._IsPlayer.Equals("True") ? true : false;
                tempTextObj.bankImpact    = float.Parse(entity._BankImpact);

                tempTextObj.relationshipImpacted = entity._TeamMember;
                tempTextObj.relationshipImpact   = float.Parse(entity._TeamValue);
                tempTextObj.ExecutingApp         = Utility.App.Text;
                tempTextObj.Cluster_Id           = clusterID;
                tempTextObj.Situation_Id         = situationID;



                for (int i = 0; i < NextList.Length; i++)
                {
                    AppCallback tempAppCallBack = new AppCallback();

                    try
                    {
                        tempAppCallBack.CallbackFuntion.AddListener(StateLoadingModule.Instance.FinishCurrentState, tempTextObj);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("ArgumentException");
                    }

                    if (Mathf.Abs(tempTextObj.bankImpact) >= 0.01f)
                    {
                        try
                        {
                            tempAppCallBack.CallbackFuntion.AddListener(BankOperations.Instance.addBankActivity, new string[2] {
                                tempTextObj.bankImpact.ToString(), entity._BankSummary
                            });
                        }catch (Exception e)
                        {
                            Debug.Log("ArgumentException");
                        }
                    }
                    //if(Math.Abs(tempTextObj.relationshipImpact) >= 0.01f)
                    if (entity._TeamMessage != null && entity._TeamMessage != "")
                    {
                        tempTextObj.relationshipImpacted = SitDB.getTeamMemberNameFromIndex(int.Parse(tempTextObj.relationshipImpacted));
                        try
                        {
                            tempAppCallBack.CallbackFuntion.AddListener(TeamOperations.Instance.addTeamActivity, new string[3] {
                                tempTextObj.relationshipImpacted, entity._TeamMessage, entity._TeamValue
                            });
                        }
                        catch (Exception e)
                        {
                            Debug.Log("ArgumentException");
                        }
                    }


                    Debug.Log("Next Debug Before: " + NextList[i]);
                    if (NextList[i] != null && NextList[i] != "" && !NextList[i].StartsWith("End"))
                    {
                        tempAppCallBack.AppExecution = FetchSituation(clusterID, situationID, NextList[i], app, SitDB);

                        tempTextObj.nextText[i]    = tempAppCallBack;
                        tempTextObj.nextmessage[i] = ((TextMsgObj)tempAppCallBack.AppExecution).message[0];
                        Debug.Log("Returned Value: " + tempTextObj.nextmessage[i]);
                    }
                    else if (NextList[0] == "End")
                    {
                        tempTextObj.nextText[0] = tempAppCallBack;

                        tempAppCallBack.CallbackFuntion.AddListener(SituationModule.Instance.SituationOnFinish, new string[2] {
                            situationID.ToString(), clusterID.ToString()
                        });
                        return(tempTextObj);
                    }
                    else
                    {
                        tempTextObj.nextText[0] = tempAppCallBack;
                        return(tempTextObj);
                    }
                }
            }

            /*if(tempTextObj.relationshipImpacted != "")
             * {
             *  tempTextObj.relationshipImpacted = SitDB.getTeamMemberNameFromIndex(int.Parse(tempTextObj.relationshipImpacted));
             * }*/

            return(tempTextObj);

        case "Bank":

            return(new AppExecution());

        case "Mail":
            reader = SitDB.getDataByString(app.ToString(), id);
            EmailExecutionObj emailObj       = ScriptableObject.CreateInstance <EmailExecutionObj>();
            string            teamMemberTemp = "";
            while (reader.Read())
            {
                //Fetch data into entity
                MailEntity entity = new MailEntity(reader[0].ToString(),
                                                   reader[1].ToString(),
                                                   reader[2].ToString(),
                                                   reader[3].ToString(),
                                                   reader[4].ToString(),
                                                   reader[5].ToString(),
                                                   reader[6].ToString(),
                                                   reader[7].ToString(),
                                                   reader[8].ToString(),
                                                   reader[9].ToString(),
                                                   reader[10].ToString(),
                                                   reader[11].ToString(),
                                                   reader[12].ToString());

                string[] NextList = entity._next.Split(',');
                emailObj.AppExe_Id         = entity._id;
                emailObj.WithWho           = entity._speaker;
                emailObj.IsPlayerTalking   = entity._isPlayer.Equals("True") ? true : false;
                emailObj.Subject           = entity._subject;
                emailObj.Content           = entity._content;
                emailObj.NextEmail         = new string[NextList.Length];
                emailObj.NextEmailCallback = new AppCallback[NextList.Length];
                emailObj.OptionDescription = entity._option.Split(',');
                emailObj.ExecutingApp      = Utility.App.Mail;
                emailObj.Cluster_Id        = clusterID;
                emailObj.Situation_Id      = situationID;
                teamMemberTemp             = entity._teamMember;


                for (int i = 0; i < NextList.Length; i++)
                {
                    AppCallback tempAppCallBack = new AppCallback();
                    try
                    {
                        tempAppCallBack.CallbackFuntion.AddListener(StateLoadingModule.Instance.FinishCurrentState, emailObj);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("ArgumentException");
                    }
                    if (Mathf.Abs(float.Parse(entity._bankImpact)) >= 0.01f)
                    {
                        try
                        {
                            tempAppCallBack.CallbackFuntion.AddListener(BankOperations.Instance.addBankActivity, new string[2] {
                                entity._bankImpact, entity._bankSummary
                            });
                        }
                        catch (Exception e)
                        {
                            Debug.Log("ArgumentException");
                        }
                    }

                    //if (Math.Abs(float.Parse(entity._teamValue)) >= 0.01f)
                    if (entity._teamMessage != null && entity._teamMessage != "")
                    {
                        entity._teamMember = SitDB.getTeamMemberNameFromIndex(int.Parse(entity._teamMember));

                        try
                        {
                            tempAppCallBack.CallbackFuntion.AddListener(TeamOperations.Instance.addTeamActivity, new string[3] {
                                entity._teamMember, entity._teamMessage, entity._teamValue
                            });
                        }
                        catch (Exception e)
                        {
                            Debug.Log("ArgumentException");
                        }
                    }


                    if (NextList[i] != null && NextList[i] != "" && !NextList[i].StartsWith("End"))
                    {
                        tempAppCallBack.AppExecution = FetchSituation(clusterID, situationID, NextList[i], app, SitDB);

                        emailObj.NextEmailCallback[i] = tempAppCallBack;
                        emailObj.NextEmail[i]         = ((EmailExecutionObj)tempAppCallBack.AppExecution).Content;
                    }
                    else if (NextList[0] == "End")
                    {
                        emailObj.NextEmailCallback[0] = tempAppCallBack;
                        tempAppCallBack.CallbackFuntion.AddListener(SituationModule.Instance.SituationOnFinish, new string[2] {
                            situationID.ToString(), clusterID.ToString()
                        });

                        return(emailObj);
                    }
                    else
                    {
                        emailObj.NextEmailCallback[0] = tempAppCallBack;
                        return(emailObj);
                    }
                }
            }

            return(emailObj);

        case "News":
            reader = SitDB.getDataByString(app.ToString(), id);
            NewsExec newsObj = ScriptableObject.CreateInstance <NewsExec>();

            while (reader.Read())
            {
                //Fetch data into entity
                NewsEntity entity = new NewsEntity(reader[0].ToString(),
                                                   reader[1].ToString(),
                                                   reader[2].ToString(),
                                                   reader[3].ToString(),
                                                   reader[4].ToString(),
                                                   reader[5].ToString());

                newsObj.AppExe_Id   = entity._Id;
                newsObj.title       = entity._title;
                newsObj.description = entity._content;
                newsObj.iconPath    = entity._icon;

                newsObj.ExecutingApp = Utility.App.News;
                newsObj.Cluster_Id   = clusterID;
                newsObj.Situation_Id = situationID;

                AppCallback tempAppCallBack = new AppCallback();

                try
                {
                    tempAppCallBack.CallbackFuntion.AddListener(StateLoadingModule.Instance.FinishCurrentState, newsObj);
                    tempAppCallBack.CallbackFuntion.AddListener(SituationModule.Instance.SituationOnFinish, new string[2] {
                        situationID.ToString(), clusterID.ToString()
                    });
                }
                catch (Exception e) { }

                newsObj.appCallback = tempAppCallBack;

                if (Mathf.Abs(float.Parse(entity._bankImpact)) >= 0.01f)
                {
                    try
                    {
                        tempAppCallBack.CallbackFuntion.AddListener(BankOperations.Instance.addBankActivity, new string[2] {
                            entity._bankImpact, entity._bankSummary
                        });
                    }
                    catch (Exception e)
                    {
                        Debug.Log("ArgumentException");
                    }
                }
            }

            return(newsObj);
        }
        return(null);
    }
Exemple #7
0
        static void Main(string[] args)
        {
            // Load Workflows
            if (!args.ToList().Any(d => d == WorkflowsPathArg))
            {
                throw new ArgumentNullException($"missing {WorkflowsPathArg} argument");
            }
            var workflowPath = args[args.ToList().IndexOf(WorkflowsPathArg) + 1];

            if (string.IsNullOrEmpty(workflowPath))
            {
                throw new Exception($"{WorkflowsPathArg} cannot be empty");
            }

            // Get Azure Storage credentials
            var envVars = Environment.GetEnvironmentVariables();

            if (!envVars.Contains(StorageAccountKey))
            {
                throw new Exception($"{StorageAccountKey} environment variable not set");
            }

            if (!envVars.Contains(StorageAccountName))
            {
                throw new Exception($"{StorageAccountName} environment variable not set");
            }

            var storageAccountName = envVars[StorageAccountName].ToString();
            var storageAccountKey  = envVars[StorageAccountKey].ToString();

            if (string.IsNullOrEmpty(storageAccountName))
            {
                throw new Exception($"{StorageAccountName} environment variablec cannot be empty");
            }

            if (string.IsNullOrEmpty(storageAccountKey))
            {
                throw new Exception($"{StorageAccountKey} environment variablec cannot be empty");
            }

            // Create engine
            var credentials    = new Credentials(storageAccountName, storageAccountKey);
            var workflowEngine = WorkflowCreator.CreateEngine(credentials);

            // Load and register workflows
            var workflows = WorkflowCreator.LoadWorkflows(workflowPath, workflowEngine.Engine);

            // Start and register Dapr gRPC app
            var server = new Server
            {
                Services = { AppCallback.BindService(new DaprWorkflowExecutor(workflows, workflowEngine)) },
                Ports    = { new ServerPort("localhost", ServerPort, ServerCredentials.Insecure) }
            };

            Task.Run(() =>
            {
                server.Start();
            });

            Console.WriteLine("Dapr LogicApps Server listening on port " + ServerPort);
            System.Threading.Thread.Sleep(Timeout.Infinite);
            server.ShutdownAsync().Wait();
        }