예제 #1
0
        protected MainMenuButton AddButton(string text, string help, int y, Action OnActivate)
        {   // X-centered version
            var b = new MainMenuButton(text, help, pos[1] + y, OnActivate);

            Items.Add(b);
            return(b);
        }
예제 #2
0
        protected MainMenuButton AddButton(string text, string help, int x, int y, Action OnActivate)
        {
            var b = new MainMenuButton(text, help, pos[0] + x, pos[1] + y, OnActivate);

            Items.Add(b);
            return(b);
        }
 void MoveFocusTo( MainMenuButton newFocusedButton )
 {
     if (newFocusedButton != null)
     {
         focusedButton = newFocusedButton;
     }
 }
예제 #4
0
 protected override void Awake()
 {
     Text               = CreateGameObject.CreateChildGameObject <ControlText>(transform).GetComponent <ControlText>();
     MainMenuButton     = CreateGameObject.CreateChildGameObject <MainMenuButton>(transform).GetComponent <MainMenuButton>();
     RestartLevelButton = CreateGameObject.CreateChildGameObject <RestartLevelButton>(transform).GetComponent <RestartLevelButton>();
     base.Awake();
 }
예제 #5
0
    MainMenuButton MakeButton()
    {
        int marginLeft   = 10;
        int marginTop    = 10;
        int buttonWidth  = 420;
        int buttonHeight = 100;

        int y = marginTop;
        int x = marginLeft;

        if (bttns.Count > 0)
        {
            MainMenuButton lastBttn = bttns[bttns.Count - 1];

            int cols = 1;
            int col  = bttns.Count % cols;
            int row  = bttns.Count / cols;

            x = marginLeft + col * buttonWidth;
            y = marginTop + row * buttonHeight;
        }

        MainMenuButton bttn = Instantiate(prefabButton, transform);

        (bttn.transform as RectTransform).anchoredPosition = new Vector2(x, -y);

        return(bttn);
    }
        public void Show()
        {
            try {
                ToolsModifierControl.mainToolbar.CloseEverything();
            } catch (Exception e) {
                Log.Error("Error on Show(): " + e);
            }

            foreach (MenuButton button in GetMenu().Buttons)
            {
                button.UpdateProperties();
            }

            GetMenu().Show();
            LoadingExtension.TranslationDatabase.ReloadTutorialTranslations();
            LoadingExtension.TranslationDatabase.ReloadGuideTranslations();
            TrafficManagerTool.ShowAdvisor("MainMenu");
#if DEBUG
            GetDebugMenu().Show();
#endif
            SetToolMode(TrafficManagerMode.Activated);
            _uiShown = true;
            MainMenuButton.UpdateSprites();
            UIView.SetFocus(MainMenu);
        }
예제 #7
0
 void Die()
 {
     YouWinText.SetActive(true);
     MainMenuButton.SetActive(true);
     gameObject.SetActive(false);
     DefeatBoss.Play();
 }
예제 #8
0
 void Update()
 {
     ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit))
     {
         if (LastObjectHit != hit.collider.gameObject)
         {
             if (LastObjectHit != null)
             {
                 if (LastObjectHit.GetComponent <MainMenuButton>())
                 {
                     LastObjectHit.GetComponent <MainMenuButton>().IsHighlit();
                 }
             }
             if (hit.collider.gameObject.GetComponent <MainMenuButton>())
             {
                 hit.collider.gameObject.GetComponent <MainMenuButton>().IsUnHighlit();
             }
         }
         LastObjectHit = hit.collider.gameObject;
     }
     if (Input.GetMouseButton(0))
     {
         if (LastObjectHit != null)
         {
             MainMenuButton button = LastObjectHit.GetComponent <MainMenuButton>();
             if (button)
             {
                 button.IsPushed();
             }
         }
     }
 }
예제 #9
0
    // Start is called before the first frame update
    void Start()
    {
        // Where the Custom Routine data should be located
        CUSTOM_DATA_PATH = Application.persistentDataPath + "/CustomRoutineData.txt";

        // If we have the main game music destroy it
        GameObject oldMusic = GameObject.Find("KeepMusic");

        if (oldMusic != null)
        {
            Destroy(oldMusic.gameObject);
        }

        // Delete old info about the custom routine
        if (File.Exists(CUSTOM_DATA_PATH) == true)
        {
            File.Delete(CUSTOM_DATA_PATH);
        }

        // The position that the buttons will go to when transitioning
        forwordPos  = new Vector3(-.3f, 1.55f, .861f);
        backPos     = new Vector3(-.3f, 1.55f, 1.2f);
        buttonTimer = float.PositiveInfinity;

        // Active all button sets so we can get their components
        for (int i = 0; i < buttonSet.Length; i++)
        {
            if (buttonSet[i] != null)
            {
                buttonSet[i].SetActive(true);
            }
        }


        // Get control objects
        gymAndSongSelectControl = buttonSet[1].transform.Find("GymSongSelect").GetComponent <GymAndSongSelectControl>();
        gymSongStart            = buttonSet[1].transform.Find("Start").GetChild(0).GetComponent <MainMenuButton>();
        gymSongBack             = buttonSet[1].transform.Find("Back").GetChild(0).GetComponent <MainMenuButton>();

        dailyChallengeControl = buttonSet[2].transform.GetChild(0).GetComponent <DailyChallengeMaster>();
        customRutineControl   = buttonSet[3].transform.GetChild(0).GetComponent <CustomRutineButtonOptionsMaster>();
        gameModeSelector      = buttonSet[4].transform.GetChild(0).GetComponent <WorkOutSelectControl>();

        levelLoader = GameObject.Find("MainMenuLevelLoader").GetComponent <MainMenuLevelLoader>();
        levelToLoad = -1;

        GameObject.Find("MainMenuMusic").GetComponent <MusicVolumeControl>().AudioSetUp();

        // Set up to display the main menu (and deactivate all the others)
        this.ActivateButtonSet("MainMenu");

        // Make sure weight is set properly
        if (PlayerPrefs.GetInt("PlayerWeight") == 0)
        {
            PlayerPrefs.SetInt("PlayerWeight", 160);
        }

        AchivmentAndStatControl.CheckAllAchivments();
    }
예제 #10
0
 protected override void MouseCore(MouseHandlerParams _params)
 {
     RestartButton.Mouse(_params);
     LevelSelectButton.Mouse(_params);
     MainMenuButton.Mouse(_params);
     ExitButton?.Mouse(_params);
     BackButton.Mouse(_params);
 }
예제 #11
0
 protected override void TouchCore(ref TouchHandlerParams _params)
 {
     RestartButton.Touch(ref _params);
     LevelSelectButton.Touch(ref _params);
     MainMenuButton.Touch(ref _params);
     ExitButton?.Touch(ref _params);
     BackButton.Touch(ref _params);
 }
예제 #12
0
        public override void InitializeEditor()
        {
            base.InitializeEditor();

            _mmBtn = Editor.UI.MainMenu.AddButton("Unit Tests");
            _mmBtn.ContextMenu.AddButton("Run unit tests").Clicked += RunTests;
            FlaxEditor.Scripting.ScriptsBuilder.ScriptsReloadBegin += ScriptsBuilder_ScriptsReloadBegin;
        }
예제 #13
0
 void SetButtons()
 {
     if (activeButton != null)
     {
         activeButton.SetOn(false);
     }
     activeButton = buttons [activeID];
     activeButton.SetOn(true);
 }
예제 #14
0
 public override void Deinitialize()
 {
     base.Deinitialize();
     if (_mmBtn != null)
     {
         _mmBtn.Dispose();
         _mmBtn = null;
     }
 }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this._levelList = new System.Windows.Forms.TableLayoutPanel();
            this.SuspendLayout();

            _levelList = new TableLayoutPanel();
            _levelList.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));

            var i = 0;

            foreach (var name in Enum.GetNames(typeof(Level.Name)))
            {
                var button = new MainMenuButton(name);
                button.Size   = new Size(1000, 150);
                button.Dock   = DockStyle.Fill;
                button.Anchor = AnchorStyles.Left;
                button.Margin = new Padding(150, 20, 0, 0);
                button.Click += (sender, args) =>
                {
                    Enum.TryParse <Level.Name>(name, out var level);
                    _controller.SetGame(level);
                    _controller.ChangeState(Controller.State.GamePlay);
                };
                button.BackColor = Color.FromArgb(red: 20, green: 161, blue: 204);
                _levelList.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                _levelList.Controls.Add(button, 0, i);
                i++;
            }
            var exitButton = new MainMenuButton("Back");

            exitButton.Dock   = DockStyle.Fill;
            exitButton.Anchor = AnchorStyles.Right;
            exitButton.Click += (sender, args) => _controller.ChangeState(Controller.State.MainMenu);
            _levelList.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            _levelList.Controls.Add(exitButton, 0, i);

            _levelList.Size = this.Size;
            //
            // _levelList
            //
            this._levelList.Dock = DockStyle.Fill;
            this._levelList.ColumnStyles.Add(
                new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this._levelList.Location = new System.Drawing.Point(0, 0);
            this._levelList.Name     = "_levelList";
            //
            // LevelSelectControl
            //
            this.Controls.Add(this._levelList);
            this.Margin   = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.Name     = "LevelSelectControl";
            this.Size     = new System.Drawing.Size(150, 188);
            this.AutoSize = true;
            this.Dock     = DockStyle.Fill;
            this.ResumeLayout(false);
            this.PerformLayout();
        }
예제 #16
0
        public void UpdateMainMenuList()
        {
            //Clear menu buttons

            List <GameObject> thisChildren = new List <GameObject>();

            foreach (Transform child in content.transform)
            {
                if (child.gameObject != null)
                {
                    thisChildren.Add(child.gameObject);
                }
            }

            foreach (GameObject child in thisChildren)
            {
                //print("trydestroy " + child.name);
                if (child.name.Contains("lone"))
                {
                    //print("destroyclone");
                    Object.Destroy(child);
                }
                else
                {
                    //print("no clone");
                }
            }

            print("number of arcades is " + ArcadeManager.arcadesConfigurationList.Count);
            List <Texture2D> textureList = new List <Texture2D>();

            for (int i = 0; i < ArcadeManager.arcadesConfigurationList.Count; i++)
            {
                var arcade = ArcadeManager.arcadesConfigurationList[i];
                var file   = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcade.id + ".jpg");
                if (file == null)
                {
                    file = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcade.id + ".png");
                }
                Texture2D texture = FileManager.LoadImageFromFile(null, null, file);

                GameObject go = Instantiate(Button_Template) as GameObject;
                go.transform.SetParent(content);
                go.SetActive(true);

                MainMenuButton TB = go.GetComponent <MainMenuButton>();
                TB.SetName(arcade.descriptiveName, texture == null ? arcade.descriptiveName : "");
                TB.SetIndex(i);
                if (texture != null)
                {
                    Image image = go.GetComponent <Image>();
                    image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
                }
                //go.transform.SetParent(Button_Template.transform.parent);
                UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(go.gameObject);
            }
        }
예제 #17
0
        public static void ApplyMainButtonColor(UIStyle uiStyle, Color normal, Color pointerOver, Color focused)
        {
            MainMenuButton mainMenuButton = uiStyle.GetComponent <MainMenuButton>();

            if (mainMenuButton != null)
            {
                mainMenuButton.NormalColor      = normal;
                mainMenuButton.PointerOverColor = pointerOver;
                mainMenuButton.FocusedColor     = focused;
            }
        }
예제 #18
0
    //-------------------------------------------



    //-------------------------------------------

    //void

    public void OnPause()
    {
        // Pause funcitionality
        Debug.Log("Pause funcitionality");
        Overlay.SetActive(true);
        PauseMenu.SetActive(true);
        ResumeButton.GetComponent <TweenScale>().ResetAndPlay();
        MainMenuButton.GetComponent <TweenScale>().ResetAndPlay();

        Time.timeScale = 0;
    }
예제 #19
0
 protected override void OnCreate()
 {
     gameModeButton = AddButton("Spielmodus", "Spielmodus beitreten.", 140, GameModeStart);
     freeModeButton = AddButton("Freier Modus", "Dem Freien Modus beitreten.", 180, FFAStart);
     AddButton("Charakter editieren", "Deinen Spielcharakter editieren.", 220, CharCreationMenu.Menu.Open);
     AddButton("Spiel verlassen", "Das Spiel schließen.", 320, ExitMenu.Menu.Open);
     OnEscape = () => { if (!GUCScripts.Ingame)
                        {
                            Open();
                        }
     };
 }
예제 #20
0
    private WidgetButtonBase CreateMainMenuButton(JsonElement definition)
    {
        var button = new MainMenuButton();

        WidgetDocLoader.LoadWidgetBase(definition, button);

        if (definition.TryGetProperty("text", out var textProp))
        {
            button.Text = textProp.GetString() ?? throw new NullReferenceException("text is null");
        }

        return(button);
    }
예제 #21
0
 void AddButtons()
 {
     for (int i = 0; i < itemList.Count; i++)
     {
         ItemList item = itemList[i];
         if (dropdownChoice.value == item.type)
         {
             GameObject newButton = objectPool.GetObject();
             newButton.transform.SetParent(contentPanel);
             MainMenuButton menuButton = newButton.GetComponent <MainMenuButton>();
             menuButton.Setup(item, this);
         }
     }
 }
예제 #22
0
        private void ButtonListGridViewContentChanged(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            Grid gridOfButton = ((Grid)args.ItemContainer.ContentTemplateRoot);
            bool isGridInList = _ListOfGrid.FirstOrDefault(p => p == gridOfButton) != null;

            if (!isGridInList)
            {
                _ListOfGrid.Add(gridOfButton);
            }

            MainMenuButton buttonClass = ((MainMenuButton)args.Item);

            gridOfButton.Background = buttonClass.BackgroundColor;
        }
        public void CloseMainMenu()
        {
            // Before hiding the menu, shut down the active tool
            GetTrafficManagerTool(false)?.SetToolMode(UI.ToolMode.None);

            // Main menu is going invisible
            GetMenu().Hide();
#if DEBUG
            GetDebugMenu().Hide();
#endif

            _uiShown = false;
            SetToolMode(TrafficManagerMode.None);
            MainMenuButton.UpdateButtonImageAndTooltip();
        }
예제 #24
0
        public void Close()
        {
            GetMenu().Hide();
#if DEBUG
            GetDebugMenu().Hide();
#endif
            TrafficManagerTool tmTool = GetTrafficManagerTool(false);
            if (tmTool != null)
            {
                tmTool.SetToolMode(UI.ToolMode.None);
            }

            SetToolMode(TrafficManagerMode.None);
            _uiShown = false;
            MainMenuButton.UpdateSprites();
        }
예제 #25
0
        protected override void OnCreate()
        {
            Back.CreateTextCenterX("Hauptmenü", 70);

            const int offset = 200;
            const int dist   = 38;

            bLogin    = AddButton("Anmelden", "In einen bestehenden Account einloggen.", offset + dist * 0, LoginMenu.Menu.Open);
            bRegister = AddButton("Registrieren", "Einen neuen Account erstellen.", offset + dist * 1, null);
            bContinue = AddButton("Weiterspielen", "Aktuelles Spiel fortführen.", offset + dist * 2, Close); //lol
            AddButton("Spielerliste", "Zeigt die angemeldeten Spieler.", offset + dist * 3, PlayerlistMenu.Menu.Open);
            AddButton("Hilfe", "Kurzhilfe & Einführung in das Rollenspiel.", offset + dist * 4, HelpMenu.Menu.Open);
            AddButton("Beenden", "Die Welt von SumpfkrautOnline verlassen.", offset + dist * 5, ExitMenu.Menu.Open);
            bContinue.Enabled = false;
            //OnEscape = Open;
        }
예제 #26
0
    // Use this for initialization
    void Start()
    {
        fireRate = 2f;
        nextFire = Time.time;

        //for Enemy health
        EnCurrentHealth = EnMaxHealth;

        //You win text
        YouWinText.SetActive(false);
        MainMenuButton.SetActive(false);

        //Enemy Detection
        enemyRB = GetComponent <Rigidbody2D> ();
        StartCoroutine("Patrol");
    }
예제 #27
0
        Grid _Statusbar()
        {
            _header = new HeaderBar {
                Title = Title, ShowCloseButton = true
            };

            this.SetTitlebar(_header);

            _main_bar = new Toolbar();
            _main_bar.ToolbarStyle = ToolbarStyle.Icons;
            _main_bar.IconSize     = IconSize.SmallToolbar;
            _main_bar.Halign       = Align.Start;

            var menu_button = new MainMenuButton();
            var menu_item   = new ToolItem {
                Child = menu_button
            };

            _main_bar.Insert(menu_item, 0);

            _source_bar = (Toolbar)ActionService.UIManager.GetWidget("/SourceToolbar");
            _source_bar.ToolbarStyle = ToolbarStyle.Icons;
            _source_bar.IconSize     = IconSize.SmallToolbar;
            _source_bar.Halign       = Align.End;

            _status_label = new Label();

            var grid = new Grid {
                ColumnHomogeneous = true
            };

            grid.Attach(_status_label, 1, 0, 1, 1);

            _ready.Add(() =>
            {
                menu_button.Show();
                menu_item.Show();

                _main_bar.Show();
                _status_label.Show();
                _source_bar.Show();

                _header.Show();
            });

            return(grid);
        }
        private MainMenuButton GetOrAddButton(string name)
        {
            if (_buttons.ContainsKey(name))
            {
                return(_buttons[name]);
            }

            MainMenuButton btn = _editor.UI.MainMenu.GetButton(name);

            if (btn != null)
            {
                return(btn);
            }

            btn = _editor.UI.MainMenu.AddButton(name);
            _buttons.Add(name, btn);

            return(btn);
        }
예제 #29
0
        public void Show()
        {
            try {
                ToolsModifierControl.mainToolbar.CloseEverything();
            } catch (Exception e) {
                Log.Error("Error on Show(): " + e.ToString());
            }

            foreach (MenuButton button in GetMenu().Buttons)
            {
                button.UpdateProperties();
            }
            GetMenu().Show();
#if DEBUG
            GetDebugMenu().Show();
#endif
            SetToolMode(TrafficManagerMode.Activated);
            _uiShown = true;
            MainMenuButton.UpdateSprites();
        }
예제 #30
0
        private void MainMenuButtonPressed(MainMenuButton obj)
        {
            switch (obj)
            {
            case MainMenuButton.Unknown:
                break;

            case MainMenuButton.Members:
                ContentArea = new MembersViewModel();
                break;

            case MainMenuButton.Activities:
                ContentArea = new ActivitiesViewModel();
                break;

            case MainMenuButton.Finances:
                DialogView dw = new DialogView(new DialogReferentViewModel <MemberCategory>("Šifrarnik: članstvo"));
                dw.Owner = Application.Current.MainWindow;
                dw.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                dw.ShowDialog();
                break;

            case MainMenuButton.Documents:
                DialogView dw2 = new DialogView(new DialogReferentViewModel <MemberFunction>("Šifrarnik: funkcija"));
                dw2.Owner = Application.Current.MainWindow;
                dw2.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                dw2.ShowDialog();
                break;

            case MainMenuButton.Economat:
                break;

            case MainMenuButton.Home:
                ContentArea = new HomeViewModel();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(obj), obj, null);
            }
        }
예제 #31
0
    public override void OnInspectorGUI()
    {
        MainMenuButton main = (MainMenuButton)target;

        base.OnInspectorGUI();

        //Editor修改过的东西要SetDirty,不然不会保存

        if (main.textComponent.text != main.text)
        {
            main.textComponent.text = main.text;
            EditorUtility.SetDirty(main.textComponent);
        }

        if (main.bgImage.sprite != main.bg)
        {
            main.bgImage.sprite = main.bg;
            EditorUtility.SetDirty(main.bgImage);
        }

        if (main.bgOutline.sprite != main.bg)
        {
            main.bgOutline.sprite = main.bg;
            EditorUtility.SetDirty(main.bgOutline);
        }

        if (main.bgOutline.rectTransform.localScale != main.bgImage.rectTransform.localScale)
        {
            main.bgOutline.rectTransform.localScale = main.bgImage.rectTransform.localScale;
        }

        if (main.bgOutline.rectTransform.position != main.bgImage.rectTransform.position)
        {
            main.bgOutline.rectTransform.position = main.bgImage.rectTransform.position;
        }

        EditorUtility.SetDirty(main.bgOutline.rectTransform);

        serializedObject.ApplyModifiedProperties();
    }
예제 #32
0
        void InitialState()
        {
            //if unspecified, for Sprites, X and Y coordinates are 0 by default
            ImagineStatica = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ImagineStatica")].Frames);
            ImagineStatica.DrawOrder = drawOrder_ImagineStatica;

            AnimatieVentilatoare = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieVentilatoare")].Frames);
            AnimatieVentilatoare.AnimationSpeed = speed_AnimatieVentilatoare;
            AnimatieVentilatoare.GenerateEvents = false; //preloaderSprite will run continuously
            AnimatieVentilatoare.X = 233;
            AnimatieVentilatoare.Y = 163;
            AnimatieVentilatoare.DrawOrder = drawOrder_AnimatieVentilatoare;
            SoundManager.PlaySound(Sounds.MainMenuVents);

            AnimatieStalpDreapta = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieStalpDreapta")].Frames);
            AnimatieStalpDreapta.FrameNumber = 5;
            AnimatieStalpDreapta.X = 593;
            AnimatieStalpDreapta.Y = 179;
            AnimatieStalpDreapta.DrawOrder = drawOrder_AnimatieStalpDreapta;

            Portal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Portal")].Frames);
            Portal.FrameNumber = 0;
            Portal.X = 240;
            Portal.Y = 93;
            Portal.DrawOrder = drawOrder_Portal;

            AnimatieStalpStanga = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieStalpStanga")].Frames);
            AnimatieStalpStanga.FrameNumber = 5;
            AnimatieStalpStanga.X = 43;
            AnimatieStalpStanga.Y = 187;
            AnimatieStalpStanga.DrawOrder = drawOrder_AnimatieStalpStanga;

            AnimatieBrateRobotice = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieBrateRobotice")].Frames);
            AnimatieBrateRobotice.FrameNumber = 25;
            AnimatieBrateRobotice.FrameOfInterest = 5;
            AnimatieBrateRobotice.GenerateFrameOfInterestEvent = true;//will generate Event on frame 5
            AnimatieBrateRobotice.X = 175;
            AnimatieBrateRobotice.Y = 0;
            AnimatieBrateRobotice.DrawOrder = drawOrder_AnimatieBrateRobotice;

            AnimatieScari = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieScari")].Frames);
            AnimatieScari.FrameNumber = 0;
            AnimatieScari.X = 410;
            AnimatieScari.Y = 420;
            AnimatieScari.DrawOrder = drawOrder_AnimatieScari;

            AnimatieMonitoareSecundare = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieMonitoareSecundare")].Frames);
            AnimatieMonitoareSecundare.FrameNumber = 0;
            AnimatieMonitoareSecundare.X = 185;
            AnimatieMonitoareSecundare.Y = 511;
            AnimatieMonitoareSecundare.DrawOrder = drawOrder_AnimatieMonitoareSecundare;

            monitor_4 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_4")].Frames);
            monitor_4.FrameNumber = 0;
            monitor_4.X = 285;
            monitor_4.Y = 571;
            monitor_4.DrawOrder = drawOrder_monitors;

            MonitorPrincipal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MonitorPrincipal")].Frames);
            MonitorPrincipal.X = 583;
            MonitorPrincipal.Y = 498;
            MonitorPrincipal.DrawOrder = drawOrder_MonitorPrincipal;

            Slot_1 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_1")].Frames);
            Slot_1.DrawOrder = drawOrder_Slots;
            Slot_1.X = 478;
            Slot_1.Y = 560;
            Slot_2 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_2")].Frames);
            Slot_2.DrawOrder = drawOrder_Slots;
            Slot_2.X = 481;
            Slot_2.Y = 615;
            Slot_3 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_3")].Frames);
            Slot_3.DrawOrder = drawOrder_Slots;
            Slot_3.X = 483;
            Slot_3.Y = 668;

            int[] positions = new int[6] { 681, 560, 645, 565, 873, 560 };
            btnNewGame = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("NewGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnNewGame.OnMouseOver += new EventHandler(Do_NewGameMouseOver);
            btnNewGame.OnMouseLeave += new EventHandler(Do_NewGameMouseLeave);
            btnNewGame.OnMouseClick += new EventHandler(Do_NewGameMouseClick);

            positions = new int[6] { 672, 598, 646, 603, 872, 598 };
            btnLoadGame = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnLoadGame.OnMouseOver += new EventHandler(Do_LoadGameMouseOver);
            btnLoadGame.OnMouseLeave += new EventHandler(Do_LoadGameMouseLeave);
            btnLoadGame.OnMouseClick += new EventHandler(Do_LoadGameMouseClick);

            positions = new int[6] { 695, 636, 647, 641, 871, 636 };
            btnCredits = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Credits")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnCredits.OnMouseOver += new EventHandler(Do_CreditsMouseOver);
            btnCredits.OnMouseLeave += new EventHandler(Do_CreditsMouseLeave);
            btnCredits.OnMouseClick += new EventHandler(Launch_CreditsEvent);

            positions = new int[6] { 730, 674, 648, 679, 870, 674 };
            btnExit = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Exit")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnExit.OnMouseOver += new EventHandler(Do_ExitMouseOver);
            btnExit.OnMouseLeave += new EventHandler(Do_ExitMouseLeave);
            btnExit.OnMouseClick += new EventHandler(Do_ExitMouseClick);

            //ActivareEfectPortal frame 0 is completely transparent
            ActivareEfectPortal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ActivareEfectPortal")].Frames);
            ActivareEfectPortal.X = 350;
            ActivareEfectPortal.Y = 200;
            ActivareEfectPortal.DrawOrder = drawOrder_ActivareEfectPortal;

            //hidden
            AnimatieEfectPortal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieEfectPortal")].Frames);
            AnimatieEfectPortal.X = 350;
            AnimatieEfectPortal.Y = 200;
            AnimatieEfectPortal.DrawOrder = 0;

            //hidden
            monitor_1 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_1")].Frames);
            monitor_1.DrawOrder = 0;
            monitor_1.X = 201;
            monitor_1.Y = 608;
            monitor_1.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            //hidden
            monitor_2 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_2")].Frames);
            monitor_2.DrawOrder = 0;
            monitor_2.X = 395;
            monitor_2.Y = 556;
            monitor_2.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            //hidden
            monitor_3 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_3")].Frames);
            monitor_3.DrawOrder = 0;
            monitor_3.X = 302;
            monitor_3.Y = 518;
            monitor_3.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            ExitTimer = new Timer(Game);
            ExitTimer.Interval = 1;//x seconds


            //LoadSettings Screen Section
            positions = new int[4] { 650, 689, 703, 691 };
            btnLoadScreenLoad = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenLoad")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnLoadScreenLoad.OnMouseClick += new EventHandler(Do_LoadScreenLoadClick);

            positions = new int[4] { 727, 687, 802, 689 };
            btnLoadScreenDelete = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenDelete")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnLoadScreenDelete.OnMouseClick += new EventHandler(Do_LoadScreenDeleteClick);

            LoadScreenFrame = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenFrame")].Frames);
            LoadScreenFrame.DrawOrder = drawOrder_Buttons;
            LoadScreenFrame.X = 647;
            LoadScreenFrame.Y = 560;

            positions = new int[6] { 868, 586, 857, 565, 858, 647 };
            LoadScreenScrollbar = new MainMenuScrollbar(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarBar")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarUp")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarDown")].Frames), drawOrder_Buttons, positions);
            LoadScreenScrollbar.OnScrollUp += new EventHandler(Do_ScrollUp);
            LoadScreenScrollbar.OnScrollDown += new EventHandler(Do_ScrollDown);

            User1 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 580);
            User1.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            User2 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 610);
            User2.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            User3 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 640);
            User3.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            //NewGame Screen Section
            NewGameScreenUserName = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("NewGameScreenUserName")].Frames[0]);
            NewGameScreenUserName.X = 650;
            NewGameScreenUserName.Y = 570;
            NewGameScreenUserName.DrawOrder = drawOrder_Buttons;

            positions = new int[4] { 648, 689, 718, 690 };
            btnNewGameScreenStart = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("StartNewGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnNewGameScreenStart.OnMouseClick += new EventHandler(Launch_NewGameStartEvent);

            positions = new int[3] { 660, 620, 170 }; //X,Y,Width
            inputNewGameUserName = new MainMenuInputBox(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("pixel")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("pixel")].Frames), drawOrder_Buttons, positions);

            //NewGame/LoadGame/Credits Back Button
            positions = new int[4] { 827, 685, 882, 687 };
            btnBack = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Back")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);


            //Credits Screen Section
            txtCreditsCronosTeam = new SpriteText(Game,((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font); 
            txtCreditsCronosTeam.X = 660;
            txtCreditsCronosTeam.Y = 560;
            txtCreditsCronosTeam.DrawOrder = drawOrder_Buttons;
            txtCreditsCronosTeam.Tint = Color.Chartreuse;
            txtCreditsCronosTeam.Text = "Cronos Team:";
            txtCreditsCronosTeam.MaxLength = 15;

            txtCreditsMembers = new SpriteText(Game,((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font); 
            txtCreditsMembers.X = 660;
            txtCreditsMembers.Y = 590;
            txtCreditsMembers.DrawOrder = drawOrder_Buttons;
            txtCreditsMembers.Tint = Color.MediumSeaGreen;
            txtCreditsMembers.Text = "Corneliu  Dascalu\nAlexandru Girigan\nAdriana  Dumitras\nGabriel  Tironeac";
            txtCreditsMembers.MaxLength = 100;


            LoadScreenHide();
            CreditsScreenHide();
            NewGameScreenHide();
            txtCreditsCronosTeam.Visible = false;
            txtCreditsMembers.Visible = false;
        }
예제 #33
0
    //THE GRAPHICS SETTINGS < OH MY GOD WHY!!! > *ALL UPDATED BY PLAYERPREF*
    void Awake()
    {
        //Get the native width and height
        nativeWidth = Screen.width;
        nativeHeight = Screen.height;

        //Get Main Menu Button component
        mainMenuButton = GetComponent <MainMenuButton>();
        //If the main menu button compnent was not found find the pause menu script
        if(!mainMenuButton)
        {
            pauseMenuButton = GetComponent <PauseMenuButton>();
        }
        menuText = GetComponent <MenuText>();

        //Gameplay Options Initialise
        //Difficulty
        if(!PlayerPrefs.HasKey ("Difficulty"))
        {
            PlayerPrefs.SetInt ("Difficulty", defaultDifficulty);
            difficulty = defaultDifficulty;
        }
        else
        {
            difficulty = PlayerPrefs.GetInt ("Difficulty");
        }

        //Damage Text
        if(!PlayerPrefs.HasKey ("DamageText"))
        {
            PlayerPrefs.SetInt ("DamageText", defaultDamageText);
            if(damageTextToggle)
            {
                damageTextToggle.isOn = true;
            }
        }
        else
        {
            if(damageTextToggle)
            {
                int currentDamageText = PlayerPrefs.GetInt ("DamageText");

                if(currentDamageText == 0)
                {
                    damageTextToggle.isOn = false;
                }
                else
                {
                    damageTextToggle.isOn = true;
                }
            }
        }

        //Invert X
        if(!PlayerPrefs.HasKey ("InvertX"))
        {
            PlayerPrefs.SetInt ("InvertX", defaultInvertX);
            if(invertXToggle)
            {
                invertXToggle.isOn = false;
            }
        }
        else
        {
            if(invertXToggle)
            {
                int currentInvertX = PlayerPrefs.GetInt ("InvertX");

                if(currentInvertX == 0)
                {
                    invertXToggle.isOn = false;
                }
                else
                {
                    invertXToggle.isOn = true;
                }
            }
        }

        //Invert Y
        if(!PlayerPrefs.HasKey ("InvertY"))
        {
            PlayerPrefs.SetInt ("InvertY", defaultInvertY);
            if(invertYToggle)
            {
                invertYToggle.isOn = false;
            }
        }
        else
        {
            if(invertYToggle)
            {
                int currentInvertY = PlayerPrefs.GetInt ("InvertY");

                if(currentInvertY == 0)
                {
                    invertYToggle.isOn = false;
                }
                else
                {
                    invertYToggle.isOn = true;
                }
            }
        }

        //Mouse Swap Toggle
        if(!PlayerPrefs.HasKey ("MouseSwap"))
        {
            PlayerPrefs.SetInt ("MouseSwap", defaultSwapMouseButton);
            if(mouseSwapToggle)
            {
                mouseSwapToggle.isOn = false;
            }
        }
        else
        {
            if(mouseSwapToggle)
            {
                int currentMouseSwap = PlayerPrefs.GetInt ("MouseSwap");

                if(currentMouseSwap == 0)
                {
                    mouseSwapToggle.isOn = false;
                }
                else
                {
                    mouseSwapToggle.isOn = true;
                }
            }
        }

        //Mouse Sensitivity
        if(mouseSensitivityScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MouseSensitivity"))
            {
                PlayerPrefs.SetFloat ("MouseSensitivity", defaultMouseSensitivity);

                mouseSensitivityScrollbar.value = defaultMouseSensitivity / 10f;
            }
            else
            {
                mouseSensitivityScrollbar.value = PlayerPrefs.GetFloat ("MouseSensitivity") / 10f;
            }
        }

        //Mouse Smooth X
        if(mouseSmoothXScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MouseSmoothX"))
            {
                PlayerPrefs.SetFloat ("MouseSmoothX", defaultMouseSmoothX);

                mouseSmoothXScrollbar.value = defaultMouseSmoothX;
            }
            else
            {
                mouseSmoothXScrollbar.value = PlayerPrefs.GetFloat ("MouseSmoothX");
            }
        }

        //Mouse Smooth Y
        if(mouseSmoothYScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MouseSmoothY"))
            {
                PlayerPrefs.SetFloat ("MouseSmoothY", defaultMouseSmoothY);

                mouseSmoothYScrollbar.value = defaultMouseSmoothY;
            }
            else
            {
                mouseSmoothYScrollbar.value = PlayerPrefs.GetFloat ("MouseSmoothY");
            }
        }

        //Master Volume
        if(masterVolumeScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MasterVolume"))
            {
                PlayerPrefs.SetFloat ("MasterVolume", defaultMasterVolume);
                masterVolumeScrollbar.value = defaultMasterVolume;
                masterVolume = defaultMasterVolume;
                AudioListener.volume = defaultMasterVolume;
            }
            else
            {
                float currentMasterVolume = PlayerPrefs.GetFloat ("MasterVolume");
                masterVolumeScrollbar.value = currentMasterVolume;
                masterVolume = currentMasterVolume;
                AudioListener.volume = currentMasterVolume;
            }
        }

        //SFX Volume
        if(sfxVolumeScrollbar)
        {
            if(!PlayerPrefs.HasKey ("SFXVolume"))
            {
                PlayerPrefs.SetFloat ("SFXVolume", defaultSFXVolume);

                sfxVolumeScrollbar.value = defaultSFXVolume;

                sfxVolume = defaultSFXVolume * masterVolume;
            }
            else
            {
                float currentSFXVolume = PlayerPrefs.GetFloat ("SFXVolume");
                sfxVolumeScrollbar.value = currentSFXVolume;
                sfxVolume = currentSFXVolume * masterVolume;
            }
        }

        //Music Volume
        if(musicVolumeScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MusicVolume"))
            {
                PlayerPrefs.SetFloat ("MusicVolume", defaultMusicVolume);

                musicVolumeScrollbar.value = defaultMusicVolume;

                musicVolume = defaultMusicVolume * masterVolume;
            }
            else
            {
                float currentMusicVolume = PlayerPrefs.GetFloat ("MusicVolume");
                musicVolumeScrollbar.value = currentMusicVolume;
                musicVolume = currentMusicVolume * masterVolume;
            }
        }

        //Speaker Mode
        if(!PlayerPrefs.HasKey ("SpeakerMode"))
        {
            PlayerPrefs.SetInt ("SpeakerMode", defaultSpeakerMode);
        }

        //Resolution
        if(width)
        {
            width.text = Screen.width.ToString();
        }
        if(height)
        {
            height.text = Screen.height.ToString();
        }

        //V Sync
        if(!PlayerPrefs.HasKey ("VSync"))
        {
            PlayerPrefs.SetInt ("VSync", defaultVSync);
            QualitySettings.vSyncCount = defaultVSync;
        }
        else
        {
            QualitySettings.vSyncCount = PlayerPrefs.GetInt ("VSync");
        }

        //Brightness
        if(brightnessScrollbar)
        {
            if(!PlayerPrefs.HasKey ("Brightness"))
            {
                PlayerPrefs.SetFloat ("Brightness", defaultBrightness);

                brightnessScrollbar.value = defaultBrightness;
            }
            else
            {
                brightnessScrollbar.value = PlayerPrefs.GetFloat ("Brightness");
            }
        }

        //Contrast
        if(contrastScrollbar)
        {
            if(!PlayerPrefs.HasKey ("Contrast"))
            {
                PlayerPrefs.SetFloat ("Contrast", defaultContrast);

                contrastScrollbar.value = defaultContrast;
            }
            else
            {
                contrastScrollbar.value = PlayerPrefs.GetFloat ("Contrast");
            }
        }

        //Mouse Cursor Size
        if(mouseCursorSizeScrollbar)
        {
            if(!PlayerPrefs.HasKey ("MouseCursorSize"))
            {
                PlayerPrefs.SetFloat ("MouseCursorSize", defaultMouseCursorSize);

                mouseCursorSizeScrollbar.value = defaultMouseCursorSize;
            }
            else
            {
                mouseCursorSizeScrollbar.value = PlayerPrefs.GetFloat ("MouseCursorSize");
            }
        }

        //Graphics

        //Motion Blur
        if(!PlayerPrefs.HasKey ("MotionBlur"))
        {
            PlayerPrefs.SetFloat ("MotionBlur", defaultMotionBlur);
        }

        //Bloom
        if(!PlayerPrefs.HasKey ("Bloom"))
        {
            PlayerPrefs.SetFloat ("Bloom", defaultBloom);
        }

        //Sun Shafts
        if(!PlayerPrefs.HasKey ("SunShaft"))
        {
            PlayerPrefs.SetFloat ("SunShaft", defaultSunShaft);
        }

        //Graphics Quality: 0 = Low, 1 = Medium, 2 = High, 3 = Ultra, 4 = Custom
        if(!PlayerPrefs.HasKey ("GraphicsQuality"))
        {
            GraphicsMediumQuality (); //Set Everything to Medium Quality on default
        }
        else
        {
            int currentGraphics = PlayerPrefs.GetInt ("GraphicsQuality");

            switch (currentGraphics)
            {
            case 0:
                GraphicsLowQuality ();
                break;
            case 1:
                GraphicsMediumQuality ();
                break;
            case 2:
                GraphicsHighQuality ();
                break;
            case 3:
                GraphicsUltraQuality ();
                break;
            case 4:
                menuText.UpdateAllGraphicsText ();
                break;
            }
        }
    }