Esempio n. 1
0
    public EmailExecutionObj GetEmailExe(int situationId)
    {
        EmailExecutionObj value = null;

        EmailExeList.TryGetValue(situationId, out value);
        return(value);
    }
 public void OnExecute(EmailExecutionObj exeObj)
 {
     if (NotificationController.Instance && exeObj.IsPlayerTalking == false)
     {
         NewEmail_1_NotificationData data = NotificationController.Instance.CreateDataInstance(Utility.App.Mail, "NewEmail") as NewEmail_1_NotificationData;
         data.FromWhom = exeObj.WithWho;
         data.Subject  = exeObj.Subject;
         NotificationController.Instance.PushNotification(data, exeObj.Situation_Id.ToString());
         AudioManager.Instance.Play(AudioEnum.Email_Notifi_A);
     }
     if (exeObj.IsPlayerTalking)
     {
         AudioManager.Instance.Play(AudioEnum.Email_Sent);
     }
     if (m_currentPage == Page.List)
     {
         EmailListView.UpdateView();
     }
     if (m_currentPage == Page.Content)
     {
         EmailContentView.UpdateView();
         EmailContentView.ScrollToBottom();
         if (EmailContentView.CurrentSituationId == exeObj.Situation_Id)
         {
             EmailContentView.OnExecuteObj(exeObj);
         }
     }
 }
Esempio n. 3
0
    private void writeToDatabase(EmailExecutionObj exeObj)
    {
        EmailDataManager.EmailDataDesc dataDesc = new EmailDataManager.EmailDataDesc(-1, exeObj.WithWho, exeObj.IsPlayerTalking, exeObj.Subject, exeObj.Content, exeObj.Situation_Id);
        List <AppDataManager.DataDesc> dataList = new List <AppDataManager.DataDesc>();

        dataList.Add(dataDesc);
        AppDataManager.SetData(AppDataManager.Protocol.EMAIL_WRITE_TO_HISTORY, dataList);
    }
Esempio n. 4
0
    public void OnFinish(int situationId)
    {
        EmailExecutionObj exeObj = GetEmailExe(situationId);

        writeToDatabase(exeObj);
        EmailExeList.Remove(situationId);
        EmailAppController.Instance.RequestLatestEmails();
    }
Esempio n. 5
0
 public bool TryGetEmailExe(int situationId, out EmailExecutionObj emailExe)
 {
     return(EmailExeList.TryGetValue(situationId, out emailExe));
 }
Esempio n. 6
0
 public void AddExeObj(EmailExecutionObj exeObj)
 {
     EmailExeList.Add(exeObj.Situation_Id, exeObj);
 }
    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);
    }