Example #1
0
    // Use this for initialization
    void Start()
    {
        SFX.Play("game_instrumental", looping: true);

        if (BuildMockData)
        {
            PartyHelper.InsertMockPlayers();
            PartyHelper.InsertMockHistory();
            PartyHelper.InsertMockQueue();
        }

        // Game has not been initialized, probably starting from the editor with mock data disabled.
        if (GameManager.Instance.RoundQueue == null || GameManager.Instance.RoundHistory == null || GameManager.Instance.PlayerInfos == null)
        {
            Debug.LogWarning("Game has not been initialised.  Probably starting from the editor without mock data enabled.");
            return;
        }

        if (GameManager.Instance.RoundQueue.Count <= 0)
        {
            PseudoSceneManager.ChangeSceneWithoutAnimation("FinalScores");
            // If the round has ended and a new round is about to begin.
        }
        else if (GameManager.Instance.RoundHistory.First != null &&
                 GameManager.Instance.RoundHistory.First.Value.RoundNumber !=
                 GameManager.Instance.RoundQueue.Peek().RoundNumber)
        {
            PseudoSceneManager.ChangeSceneWithoutAnimation("Intermission");
        }
        else
        {
            PseudoSceneManager.ChangeSceneWithoutAnimation("RoundView");
        }
    }
Example #2
0
        public static RestZone.CannotCampReason WhyCannotCamp()
        {
            RestZone.CannotCampReason cannotCampReason = 0;
            if (GameState.s_playerCharacter == null)
            {
                return(RestZone.CannotCampReason.Error);
            }
            if (GameState.InCombat)
            {
                cannotCampReason |= RestZone.CannotCampReason.InCombat;
            }

            if (IEModOptions.MaxCampingSupplies != IEModOptions.MaxCampingSuppliesOptions.Disabled)
            {
                PlayerInventory inventory = GameState.s_playerCharacter.Inventory;
                if (inventory == null || inventory.CampingSuppliesTotal == 0)
                {
                    cannotCampReason |= RestZone.CannotCampReason.NoSupplies;
                }
            }

            if (GameState.Instance.CurrentMap != null && !GameState.Instance.CurrentMap.GetCanCamp())
            {
                cannotCampReason |= RestZone.CannotCampReason.NoCampMap;
            }
            if (PartyHelper.PartyCanSeeEnemy())
            {
                cannotCampReason |= RestZone.CannotCampReason.PartyCanSeeEnemy;
            }
            return(cannotCampReason);
        }
Example #3
0
        public void FinalizeLevelLoadNew()
        {
            if (((this.CurrentMap != null) && !this.CurrentMap.HasBeenVisited) && ((BonusXpManager.Instance != null) && this.CurrentMap.GivesExplorationXp))
            {
                this.CurrentMap.HasBeenVisited = true;
                int xp = 0;
                if (BonusXpManager.Instance != null)
                {
                    xp = BonusXpManager.Instance.MapExplorationXp;
                }
                object[] parameters = new object[] { this.CurrentMap.DisplayName, xp *PartyHelper.NumPartyMembers };
                global::Console.AddMessage("[" + NGUITools.EncodeColor(Color.yellow) + "]" + global::Console.Format(GUIUtils.GetTextWithLinks(0x661), parameters));
                PartyHelper.AssignXPToParty(xp, false);
            }
            if (OnLevelLoaded != null)
            {
                OnLevelLoaded(Application.loadedLevelName, EventArgs.Empty);
            }
            if (NewGame && (this.Difficulty == GameDifficulty.Easy))
            {
                Option.AutoPause.SetSlowEvent(AutoPauseOptions.PauseEvent.CombatStart, true);
            }
            ScriptEvent.BroadcastEvent(ScriptEvent.ScriptEvents.OnLevelLoaded);
            IsLoading = false;
            if (((s_playerCharacter != null) && !LoadedGame) && (!NewGame && (NumSceneLoads > 0)))
            {
                if (!IEModOptions.SaveBeforeTransition)                 // added this line
                {
                    if (FogOfWar.Instance)
                    {
                        FogOfWar.Instance.WaitForFogUpdate();
                    }
                    AutosaveIfAllowed();
                }
            }
            NewGame = false;
            if (((this.CurrentMap != null) && (this.CouldCampOnLastMap != this.CurrentMap.CanCamp)) && !Option.GetOption(GameOption.BoolOption.DONT_RESTRICT_STASH))
            {
                if (this.CurrentMap.CanCamp)
                {
                    UISystemMessager.Instance.PostMessage(GUIUtils.GetText(0x61e), Color.white);
                }
                else
                {
                    UISystemMessager.Instance.PostMessage(GUIUtils.GetText(0x61d), Color.white);
                }
            }
            NumSceneLoads++;
            FatigueCamera.CreateCamera();
            GammaCamera.CreateCamera();
            WinCursor.Clip(true);

            // in here you can place something like if (CurrentMap.SceneName == "AR_0011_Dyrford_Tavern_02") make_an_NPC; or change_NPC's_stats;
            // added this code
            mod_CommandLine.InjectDropInvButton();

            if (PlayerPrefs.GetInt("UseCustomUi", 0) == 1 && PlayerPrefs.GetInt("AppliedCustomUi", 0) == 0)
            {
                Debug.Log("P! start if block");
                mod_CommandLine.CustomUiApplyOnce();
                PlayerPrefs.SetInt("AppliedCustomUi", 1);
                mod_CommandLine.RepositionUi();
            }

            if (IEModOptions.FixBackerNames)
            {
                mod_CommandLine.FixBackerNames(true);
            }
            else
            {
                mod_CommandLine.FixBackerNames(false);
            }
            // end of added code
        }
Example #4
0
        public ActionResult SendEmail(string id)
        {
            try {
                if (string.IsNullOrEmpty(id))
                {
                    throw new Exception("Email send failed due to scale ID not found.");
                }

                ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                Scale        scale    = scaleLib.GetByID(id, new string[] { "Party_ID" });

                if (scale == null || scale.Party_ID == null || scale.Ticket_Type != "Receiving Ticket" || scale.Ticket_Status != "Close")
                {
                    throw new Exception("Email send failed.");
                }

                IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(scale.Party_ID.ID);
                if (contacts.Count() <= 0)
                {
                    throw new Exception("There is no email contact exists.");
                }

                NotificationDefinition notDef = new NotificationDefinition();
                notDef.ToRecipients = new System.Net.Mail.MailAddressCollection();
                foreach (var item in contacts)
                {
                    notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText));
                }

                EmployeeHelper employeeHelper = new EmployeeHelper();
                Employee       employee       = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name);
                if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password))
                {
                    throw new Exception("Sender email and password is required.");
                }


                string xslPath     = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ScaleEmailBody.xslt");
                string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer();

                Dictionary <string, object> parameter = new Dictionary <string, object>();
                parameter.Add("ScaleID", id);

                SSRSReport ssrsHelper = new SSRSReport("ScaleReceiveTicket.rdl", parameter);
                string     attachment = ssrsHelper.ExportReportToPDF();

                if (string.IsNullOrEmpty(attachment))
                {
                    throw new Exception("There is no attachment found.");
                }

                notDef.Attachments = new List <System.Net.Mail.Attachment>();
                notDef.Attachments.Add(new System.Net.Mail.Attachment(attachment));
                notDef.DeliveryType            = EnumNotificationDeliveryType.Email;
                notDef.FormatType              = EnumFormatType.HTML;
                notDef.Sender                  = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name);
                notDef.SMTPServer              = smtpAddress;
                notDef.SMTPServerCredentialID  = employee.Email;
                notDef.SMTPServerCredentialPwd = employee.Email_Password;
                notDef.Subject                 = "Ticket#" + id.ToString();
                NotificationHelper.StartNotificationWF(id, scale.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted);

                //return Display(command, container);
                if (_sendMail == true)
                {
                    return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex) {
                return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Example #5
0
        public void mod_FinalizeLevelLoad()
        {
            try
            {
                if (this.CurrentMap != null && !this.CurrentMap.HasBeenVisited && BonusXpManager.Instance && this.CurrentMap.GivesExplorationXp)
                {
                    this.CurrentMap.HasBeenVisited = true;
                    int mapExplorationXp = 0;
                    if (BonusXpManager.Instance != null)
                    {
                        mapExplorationXp = BonusXpManager.Instance.MapExplorationXp;
                    }
                    Console.AddMessage(string.Concat("[", NGUITools.EncodeColor(Color.yellow), "]", Console.Format(GUIUtils.GetTextWithLinks(1633), new object[] { this.CurrentMap.DisplayName, mapExplorationXp * PartyHelper.NumPartyMembers })));
                    PartyHelper.AssignXPToParty(mapExplorationXp, false);
                }
                if (GameState.OnLevelLoaded != null)
                {
                    GameState.OnLevelLoaded(Application.loadedLevelName, EventArgs.Empty);
                }
                if (GameState.NewGame && this.Difficulty == GameDifficulty.Easy)
                {
                    GameState.Option.AutoPause.SetSlowEvent(AutoPauseOptions.PauseEvent.CombatStart, true);
                }
                ScriptEvent.BroadcastEvent(ScriptEvent.ScriptEvents.OnLevelLoaded);
                GameState.IsLoading = false;
                if (GameState.s_playerCharacter != null && !GameState.LoadedGame && !GameState.NewGame && GameState.NumSceneLoads > 0)
                {
                    if (!IEModOptions.SaveBeforeTransition) // added this line
                    {
                        if (FogOfWar.Instance)
                        {
                            FogOfWar.Instance.WaitForFogUpdate();
                        }
                        AutosaveIfAllowed();
                    }
                }
                GameState.NewGame = false;
                if (this.CurrentMap != null && this.CouldAccessStashOnLastMap != this.CurrentMap.GetCanAccessStash() && !GameState.Option.GetOption(GameOption.BoolOption.DONT_RESTRICT_STASH))
                {
                    if (!this.CurrentMap.GetCanAccessStash())
                    {
                        UISystemMessager.Instance.PostMessage(GUIUtils.GetText(1566), Color.white);
                    }
                    else
                    {
                        UISystemMessager.Instance.PostMessage(GUIUtils.GetText(1565), Color.white);
                    }
                }
                GameState.NumSceneLoads = GameState.NumSceneLoads + 1;
                FatigueCamera.CreateCamera();
                GammaCamera.CreateCamera();
                WinCursor.Clip(true);
                if (this.CurrentMap != null)
                {
                    TutorialManager.TutorialTrigger tutorialTrigger = new TutorialManager.TutorialTrigger(TutorialManager.TriggerType.ENTERED_MAP)
                    {
                        Map = this.CurrentMap.SceneName
                    };
                    TutorialManager.STriggerTutorialsOfType(tutorialTrigger);
                }
                if (this.CurrentMap != null && this.CurrentMap.IsValidOnMap("px1"))
                {
                    GameState.Instance.HasEnteredPX1 = true;
                    if (GameGlobalVariables.HasStartedPX2())
                    {
                        this.HasEnteredPX2 = true;
                    }
                }
                // in here you can place something like if (CurrentMap.SceneName == "AR_0011_Dyrford_Tavern_02") make_an_NPC; or change_NPC's_stats;
                // added this code

                // Addition of autoload custom NPC stats if enabled
                if (IEModOptions.AutoLoadCustomStats)
                {
                    ImportStats();
                }

                DropButton.InjectDropInvButton();
                if (IEModOptions.EnableCustomUi)
                {
                    if (IEModOptions.Layout == null)
                    {
                        UICustomizer.Initialize();
                        IEModOptions.Layout = UICustomizer.DefaultLayout.Clone();
                    }
                    else
                    {
                        UICustomizer.LoadLayout(IEModOptions.Layout);
                    }
                }

                BackerNamesMod.FixBackerNames(IEModOptions.FixBackerNames);
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
                GameState.ReturnToMainMenuFromError();
            }
            if (!this.RetroactiveSpellMasteryChecked)
            {
                for (int i = 0; i < (int)PartyMemberAI.PartyMembers.Length; i++)
                {
                    if (PartyMemberAI.PartyMembers[i] != null)
                    {
                        CharacterStats component = PartyMemberAI.PartyMembers[i].GetComponent <CharacterStats>();
                        if (component)
                        {
                            if (component.MaxMasteredAbilitiesAllowed() > component.GetNumMasteredAbilities())
                            {
                                UIWindowManager.ShowMessageBox(UIMessageBox.ButtonStyle.OK, GUIUtils.GetText(2252), GUIUtils.GetText(2303));
                                break;
                            }
                        }
                    }
                }
                this.RetroactiveSpellMasteryChecked = true;
            }
            if (GameUtilities.HasPX2() && GameState.LoadedGame)
            {
                if (GameGlobalVariables.HasFinishedPX1())
                {
                    QuestManager.Instance.StartPX2Umbrella();
                }
                else if (!this.HasNotifiedPX2Installation)
                {
                    UIWindowManager.ShowMessageBox(UIMessageBox.ButtonStyle.OK, string.Empty, GUIUtils.GetText(2438));
                    this.HasNotifiedPX2Installation = true;
                }
            }
        }
Example #6
0
        public void mod_FinalizeLevelLoad()
        {
            if (this.CurrentMap != null && !this.CurrentMap.HasBeenVisited && BonusXpManager.Instance &&
                this.CurrentMap.GivesExplorationXp)
            {
                this.CurrentMap.HasBeenVisited = true;
                int xp = 0;
                if (BonusXpManager.Instance != null)
                {
                    xp = BonusXpManager.Instance.MapExplorationXp;
                }
                object[] parameters = new object[] {
                    this.CurrentMap.DisplayName,
                    xp *PartyHelper.NumPartyMembers
                };
                global::Console.AddMessage("[" + NGUITools.EncodeColor(Color.yellow) + "]"
                                           + global::Console.Format(GUIUtils.GetTextWithLinks(0x661), parameters));
                PartyHelper.AssignXPToParty(xp, false);
            }
            if (OnLevelLoaded != null)
            {
                OnLevelLoaded(Application.loadedLevelName, EventArgs.Empty);
            }
            if (NewGame && (this.Difficulty == GameDifficulty.Easy))
            {
                Option.AutoPause.SetSlowEvent(AutoPauseOptions.PauseEvent.CombatStart, true);
            }
            ScriptEvent.BroadcastEvent(ScriptEvent.ScriptEvents.OnLevelLoaded);
            GameState.IsLoading = false;
            if (GameState.s_playerCharacter != null && !GameState.LoadedGame && !GameState.NewGame && GameState.NumSceneLoads > 0)
            {
                if (!IEModOptions.SaveBeforeTransition)                 // added this line
                {
                    if (FogOfWar.Instance)
                    {
                        FogOfWar.Instance.WaitForFogUpdate();
                    }
                    AutosaveIfAllowed();
                }
            }
            NewGame = false;
            if (((this.CurrentMap != null) && (this.CouldCampOnLastMap != this.CurrentMap.CanCamp)) &&
                !Option.GetOption(GameOption.BoolOption.DONT_RESTRICT_STASH))
            {
                if (this.CurrentMap.CanCamp)
                {
                    UISystemMessager.Instance.PostMessage(GUIUtils.GetText(0x61e), Color.white);
                }
                else
                {
                    UISystemMessager.Instance.PostMessage(GUIUtils.GetText(0x61d), Color.white);
                }
            }
            NumSceneLoads++;
            FatigueCamera.CreateCamera();
            GammaCamera.CreateCamera();
            WinCursor.Clip(true);
            if (this.CurrentMap != null)
            {
                TutorialManager.TutorialTrigger trigger =
                    new TutorialManager.TutorialTrigger(TutorialManager.TriggerType.ENTERED_MAP);
                trigger.Map = this.CurrentMap.SceneName;
                TutorialManager.STriggerTutorialsOfType(trigger);
            }
            if (this.CurrentMap != null && this.CurrentMap.IsValidOnMap("px1"))
            {
                GameState.Instance.HasEnteredPX1 = true;
            }
            // in here you can place something like if (CurrentMap.SceneName == "AR_0011_Dyrford_Tavern_02") make_an_NPC; or change_NPC's_stats;
            // added this code
            DropButton.InjectDropInvButton();
            if (IEModOptions.EnableCustomUi)
            {
                if (IEModOptions.Layout == null)
                {
                    UICustomizer.Initialize();
                    IEModOptions.Layout = UICustomizer.DefaultLayout.Clone();
                }
                else
                {
                    UICustomizer.LoadLayout(IEModOptions.Layout);
                }
            }



            BackerNamesMod.FixBackerNames(IEModOptions.FixBackerNames);
            // end of added code
        }
        public ActionResult SendEmail(string id)
        {
            string      destinationFilePath = string.Empty;
            FilelHelper fileHelper          = new FilelHelper();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    throw new Exception("Email send failed due to Container# not found.");
                }

                ContainerLibrary containerLib = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                Container        container    = containerLib.GetByID(id, new string[] { "Booking.Sales_Order_No.Party" });

                if (container == null || container.Booking == null || container.Booking.Sales_Order_No == null || container.Booking.Sales_Order_No.Party == null)
                {
                    throw new Exception("Email send failed.");
                }

                IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(container.Booking.Sales_Order_No.Party.ID);
                if (contacts.Count() <= 0)
                {
                    throw new Exception("There is no email contact exists.");
                }

                NotificationDefinition notDef = new NotificationDefinition();
                notDef.ToRecipients = new System.Net.Mail.MailAddressCollection();
                foreach (var item in contacts)
                {
                    notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText));
                }

                EmployeeHelper employeeHelper = new EmployeeHelper();
                Employee       employee       = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name);
                if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password))
                {
                    throw new Exception("Sender email and password is required.");
                }

                ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                Scale        scale    = scaleLib.GetScalesByContainerId(container.ID);

                ScaleAttachmentsLibrary        scaleAttachLib   = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                IEnumerable <ScaleAttachments> scaleAttachments = scaleAttachLib.GetAllByParentID(scale.ID);
                if (scaleAttachments == null || scaleAttachments.Count() <= 0)
                {
                    throw new Exception("There is no attachment found.");
                }

                destinationFilePath = Path.Combine(Path.GetTempPath(), container.ID.ToString());
                fileHelper.CreateDirectory(destinationFilePath);
                fileHelper.DeleteFiles(destinationFilePath);
                string imageFilePath = Path.Combine(destinationFilePath, "Images");
                fileHelper.CreateDirectory(imageFilePath);

                string zipFilePath = Path.Combine(destinationFilePath, container.ID.ToString() + ".zip");

                foreach (var item in scaleAttachments)
                {
                    string sourceFilePath    = fileHelper.GetFilePathByFileRefId(item.Document_RefId.ToString());
                    string imageFileFullPath = Path.Combine(imageFilePath, item.Document_Name);
                    System.IO.File.Copy(sourceFilePath, imageFileFullPath);
                }
                new smART.Common.FilelHelper().CreateZip(imageFilePath, zipFilePath);

                if (!fileHelper.FileExits(zipFilePath))
                {
                    throw new Exception("There is no attachment found.");
                }

                string xslPath     = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ContainerEmailBody.xslt");
                string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer();

                notDef.Attachments = new List <System.Net.Mail.Attachment>();
                notDef.Attachments.Add(new System.Net.Mail.Attachment(zipFilePath));
                notDef.DeliveryType            = EnumNotificationDeliveryType.Email;
                notDef.FormatType              = EnumFormatType.HTML;
                notDef.Sender                  = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name);
                notDef.SMTPServer              = smtpAddress;
                notDef.SMTPServerCredentialID  = employee.Email;
                notDef.SMTPServerCredentialPwd = employee.Email_Password;
                notDef.Subject                 = "Booking#/Container#: " + container.Booking.Booking_Ref_No + "/" + container.Container_No;
                NotificationHelper.StartNotificationWF(id, container.Booking.Sales_Order_No.Party.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted, container.Booking.Booking_Ref_No, container.Booking.Sales_Order_No.ID.ToString());
                //return Display(command, container);
                if (_sendMail == true)
                {
                    return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet));
                }
                //return Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                //var script = @"ShowAlertMessage(""Send mail failed"");";
                //return JavaScript(script);
                return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                //fileHelper.DeleteDirectory(destinationFilePath);
            }
        }