Ejemplo n.º 1
0
 private void Awake()
 {
     ambienceSubmarine = Resources.Load <AudioClip>("Sound/submarineAmbience");
     ambienceRadio     = Resources.Load <AudioClip>("Sound/radioAmbience");
     if (openScreenManager == null)
     {
         openScreenManager = this;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Manages the opening of a new/showing of an existing Instance of a Form.
        /// </summary>
        /// <param name="AForm">Type of the Form to be opened.</param>
        /// <param name="AParentForm">Parent Form (can be null).</param>
        /// <param name="AFormWasAlreadyOpened">False if a new Form was opened, true if a
        /// Singleton Instance of the Form was activated.</param>
        /// <param name="ARunShowMethod">Set to true to run the Forms' Show() Method. (Default=true).</param>
        /// <param name="AContext">Context in which the Form runs (default=""). Can get evaluated for
        /// security purposes.</param>
        /// <returns>An Instance of the Form (either newly created or just activated).</returns>
        public static Form OpenNewOrExistingForm(Type AForm, Form AParentForm, out bool AFormWasAlreadyOpened, bool ARunShowMethod = true,
                                                 string AContext = "")
        {
            Form OpenScreen;
            Form NewScreen;

            if (AForm == null)
            {
                throw new ArgumentNullException("Argument 'AForm' must not be null");
            }

            AFormWasAlreadyOpened = false;

            OpenScreen = TFormsList.GFormsList[AForm.FullName];

            if ((OpenScreen != null) &&
                (OpenScreen.Modal != true))
            {
                if (TFormsList.GSingletonForms.Contains(AForm.Name))
                {
                    OpenScreen.BringToFront();

                    AFormWasAlreadyOpened = true;

                    return(OpenScreen);
                }
            }

            NewScreen = (Form)Activator.CreateInstance(AForm, new object[] { AParentForm, AContext });

            if (ARunShowMethod)
            {
                NewScreen.Show();
            }

            return(NewScreen);
        }