Example #1
0
        private void NavButton_Clicked(SpriteButton sender)
        {
            var navigateTo          = DynamicViewHost.GetNavigateTo(sender);
            var navigationDirection = DynamicViewHost.GetNavigationDirection(sender);

            GetView(navigateTo).SetAsCurrentView(navigationDirection);
        }
Example #2
0
        private void BackgroundWorkerProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            var poke        = e.UserState as PokemonEntry;
            var selected    = _workingConfig.Configuration.DisabledPokemon.All(id => poke.Id != id);
            var legendary   = _config.Value.Configuration.LegendaryPokemon.Any(id => poke.Id == id);
            var special     = _config.Value.Configuration.SpecialPokemon.Any(id => poke.Id == id);
            var forbidden   = _config.Value.Configuration.ForbiddenPokemon.Any(id => poke.Id == id);
            var levelLocked = poke.MinimumLevel > _config.Value.Options.Level;

            // Create Item
            var item = new SpriteButton(_spriteProvider, poke.Id - 1 /* Convert to zero based from pokemon 1-based id */, selected)
            {
                Name = poke.Id.ToString(),
                Text = poke.Identifier.ToUpper(),
                Tint =
                    forbidden ? CustomColors.Forbidden :
                    levelLocked ? CustomColors.Forbidden :
                    legendary ? CustomColors.Legendary :
                    special ? CustomColors.Special :
                    CustomColors.Standard,
                Enabled = !forbidden && !levelLocked
            };

            // Add Item
            LayoutPanelMain.Controls.Add(item);

            // Bind events
            item.ItemSelctedEvent += ItemSelcted;
        }
    public override void OnInspectorGUI()
    {
        if (!EditorApplication.isPlaying)
        {
            SpriteButtonUtils.UpdateSpriteButtonsOnEditor(false);

            SpriteButton button = (SpriteButton)target;

            if (!button.anchor.Equals(SpriteButtonAnchor.NONE))
            {
                button.screenID = EditorGUILayout.IntField("Screen ID", button.screenID);
            }

            button.anchor = (SpriteButtonAnchor)EditorGUILayout.EnumPopup("Anchor", button.anchor);

            if (!button.anchor.Equals(SpriteButtonAnchor.NONE))
            {
                button.marginTop    = EditorGUILayout.FloatField("Margin Top", button.marginTop);
                button.marginBottom = EditorGUILayout.FloatField("Margin Bottom", button.marginBottom);
                button.marginLeft   = EditorGUILayout.FloatField("Margin Left", button.marginLeft);
                button.marginRight  = EditorGUILayout.FloatField("Margin Right", button.marginRight);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }
    }
Example #4
0
 private void DoLogicsMenuBtns(SpriteButton button)
 {
     if ("PlayButton".Equals(button.name))
     {
         GameObject.FindObjectOfType <GUIBehaviour>().SlideOutLeft();
     }
     if ("ReturnMainMenu".Equals(button.name))
     {
         GameObject.FindObjectOfType <GUIBehaviour>().SlideOutRight();
     }
     if ("LeaderBoardBtn".Equals(button.name))
     {
         ConnectionUtils.Instance.ShowLeaderBoard();
     }
     if ("CreditsBtn".Equals(button.name))
     {
         GameObject.FindObjectOfType <GameMenuController>().ShowCredits();
     }
     if ("3Rounds".Equals(button.name))
     {
         GameUtils.Instance.DefineRoundLimit(GameRounds.ROUND_LIMIT_3);
         LoadGamePlayScene();
     }
     if ("5Rounds".Equals(button.name))
     {
         GameUtils.Instance.DefineRoundLimit(GameRounds.ROUND_LIMIT_5);
         LoadGamePlayScene();
     }
     if ("7Rounds".Equals(button.name))
     {
         GameUtils.Instance.DefineRoundLimit(GameRounds.ROUND_LIMIT_7);
         LoadGamePlayScene();
     }
 }
Example #5
0
        public Field(GraphicsDevice device)
            : base(device)
        {
            this.m_sideSize      = Game.Content.GetSizeInDpi(64);
            this.m_scaleStep     = Game.Content.GetSizeInDpi(4);
            this.m_maxScale      = this.m_sideSize;
            this.m_minScale      = m_sideSize / 2;
            this.m_scaleSideSize = this.m_sideSize;

            this.m_area = new Area();
            this.m_area.HorizontalAligin = ContentAligin.Center;
            this.m_area.VerticalAligin   = ContentAligin.Center;
            this.m_area.Padding          = Game.Content.Common.FieldPadding;
            this.m_area.View             = Canvas.View;

            this.m_isUpdateFieldData = true;

            this.m_prevPathCellsSet = new HashSet <Cell>();
            this.m_pathCellsSet     = new HashSet <Cell>();
            this.m_pathCellsQueue   = new Queue <Cell>();

            this.m_fieldStatus = new FieldStatus();

            int menuButtonMargin = Game.Content.GetSizeInDpi(20);

            this.MenuButton = new SpriteButton(ButtonType.FieldButton, Game.Content.Animations.FieldPress10)
            {
                Texture = Game.Content.Textures.MenuIcon, Fixed = true
            };
            this.MenuButton.X = Canvas.View.Width - menuButtonMargin - this.MenuButton.Width / 2;
            this.MenuButton.Y = Canvas.View.Height - menuButtonMargin - this.MenuButton.Height / 2;
        }
Example #6
0
 private void BrushSizeConnect(SpriteButton spriteButton, BrushSize brushSize)
 {
     spriteButton.Button.Connect("pressed", this, nameof(SetBrushSizeInternal),
                                 new Godot.Collections.Array {
         brushSize
     });
 }
Example #7
0
 public override void UnloadContent()
 {
     RemoveComponent(button);
     button = null;
     image  = null;
     base.UnloadContent();
 }
Example #8
0
 public override void initialize()
 {
     gameMap = new GameMap();
     music   = OTRGame.getInstance().Content.Load <Song>("Tobu - Higher");
     MediaPlayer.IsRepeating = true;
     MediaPlayer.Play(music);
     SpriteButton.resetSpeed();
 }
 private void LeaveButtonClicked(SpriteButton arg0)
 {
     if (GameManager.Instance.State != GameState.Game)
     {
         return;
     }
     GameManager.Instance.EndCampaign();
 }
 private void ListenButtonClicked(SpriteButton arg0)
 {
     if (GameManager.Instance.State != GameState.Game)
     {
         return;
     }
     WordManager.Instance.ListenCurrentWord();
 }
Example #11
0
    public void ChooseRun()
    {
        SpriteButton button = eventSystem.currentSelectedGameObject.GetComponent <SpriteButton>();

        SetButtonsInteractable(_mainActionMenu, false);
        button.SpriteRenderer.sprite = button.spriteState.pressedSprite;                // Show pressed sprite
        previousOptions.Clear();
        BattleManager.bm.EndBattle(WinStatus.Escape);
    }
Example #12
0
        public override void Load()
        {
            _progressLabel = new Label
            {
                Text       = "Generating world...",
                Anchor     = Anchor.Center,
                Origine    = Anchor.Center,
                Font       = Ressources.FontRomulus,
                UnitOffset = new Point(0, -24)
            };

            _progressBar = new ProgressBar
            {
                UnitBound  = new Rectangle(0, 0, 320, 8),
                Anchor     = Anchor.Center,
                Origine    = Anchor.Center,
                UnitOffset = new Point(0, 24)
            };

            var _cancelButton = new SpriteButton()
            {
                Sprite    = new Sprite(Ressources.TileGui, new Point(7, 7)),
                UnitBound = new Rectangle(0, 0, 48, 48),
                Anchor    = Anchor.TopRight,
                Origine   = Anchor.Center
            }.RegisterMouseClickEvent((sender) =>
            {
                _job.Cancel();
                Game.GoToMainMenu();
            });

            Container = new Container
            {
                Padding   = new Margins(16),
                Childrens =
                {
                    new WidgetFancyPanel
                    {
                        UnitBound = new Rectangle(0, 0, 840, 256),
                        Anchor    = Anchor.Center,
                        Origine   = Anchor.Center,
                        Dock      = Rise.Platform.Family == Framework.Platform.PlatformFamily.Mobile ? Dock.Fill : Dock.None,
                        Content   = new Container
                        {
                            Childrens =
                            {
                                _progressBar,
                                _progressLabel,
                                _cancelButton
                            }
                        }
                    }
                }
            };

            _job.Start(true);
        }
Example #13
0
        public SOBattleHUD(BattleHUD scene)
        {
            Scene = scene;

            PauseButton            = new SpriteButton(scene.PauseButtonGameObject);
            HelpButton             = new SpriteButton(scene.HelpButtonGameObject);
            HitArea                = new WidgetButton(scene.HideHudHitAreaGameObject);
            AllMenuPanel           = new GOAllMenuPanel(scene.AllMenuPanel);
            BattleInformationPanel = new PanelBattleInformation(scene.BattleDialogGameObject);
            Transitions            = new Transition(scene.TransitionGameObject);
            Fading = new SpriteFading(scene.ScreenFadeGameObject);
        }
Example #14
0
    private void Awake()
    {
        // Convert Array into List
        Mine[] startingMines = GetComponentsInChildren <Mine>();
        for (int i = 0; i < startingMines.Length; i++)
        {
            Mines.Add(startingMines[i]);
            Mines[i].SetMineIndex(i + 1);
        }
        newMineCost = MINE_START_COST;

        newMineButton = GetComponentInChildren <SpriteButton>();
        UpdateNewMineButton(Mines[MineCount - 1].transform.position);
    }
Example #15
0
 void LoadLevel(SpriteButton button)
 {
     SaveData();
     if (gameData.unlocked.Contains(button.data.myName))
     {
         SpriteData myLevel = Resources.Load <SpriteData> ("Sprite Objects/" + button.data.myName);
         GameManager.Instance.level = myLevel as SpriteData;
         UnityEngine.SceneManagement.SceneManager.LoadScene(1, UnityEngine.SceneManagement.LoadSceneMode.Single);
     }
     else
     {
         selectedArt = button;
         OpenDialog();
     }
 }
Example #16
0
        public override void LoadContent()
        {
            base.LoadContent();
            image    = StateManager.Game.Content.Load <Texture2D>("Images/paused");
            imagePos = new Vector2(Bounds.Width / 2 - image.Width / 2, Bounds.Height / 2 - image.Height / 2);

            button = new SpriteButton(StateManager.Content.Load <Texture2D>("Images/unpause"));
            button.InputEventSource = StateManager.Input;
            button.TransitionSource = this;
            button.ButtonClickStyle = ButtonStyle.AnimateOnPress | ButtonStyle.AnimateIdle | ButtonStyle.Highlight;

            button.Position       = new Vector2(Bounds.Width / 2, Bounds.Height / 2 + 80);
            button.ButtonClicked += button_ButtonClicked;
            button.BindKey(Keys.P);
            AddComponent(button);
        }
Example #17
0
        public MenuChest(Entity entity, Entity chest, GameState gameState) : base(gameState)
        {
            PauseGame = true;

            _inventoryA = new WidgetItemContainer(entity.GetComponent <Inventory>().Content)
            {
                Padding = new Margins(4, 4), Dock = Dock.Fill
            };
            _inventoryB = new WidgetItemContainer(chest.GetComponent <Inventory>().Content)
            {
                Padding = new Margins(4, 4), Dock = Dock.Fill
            };

            _inventoryA.MouseClick += Tranfer;
            _inventoryB.MouseClick += Tranfer;

            var closeBtn = new SpriteButton()
            {
                Sprite    = new Sprite(Ressources.TileGui, new Point(7, 7)),
                UnitBound = new Rectangle(0, 0, 48, 48),
                Anchor    = Anchor.TopLeft,
                Origine   = Anchor.Center
            };

            closeBtn.MouseClick += CloseBtnOnMouseClick;

            Content = new WidgetFancyPanel()
            {
                Content = new Container()
                {
                    Childrens =
                    {
                        new Container()
                        {
                            Dock      = Dock.Fill,
                            Childrens ={ closeBtn                 }
                        },
                        GuiFactory.CreateSplitContainer(new Rectangle(0, 0, 64, 64), "Inventory", _inventoryA, "Chest", _inventoryB),
                    }
                }
            };
        }
Example #18
0
    public override void _Ready()
    {
        _pencil = new SpriteButton(this, "Pencil");
        _eraser = new SpriteButton(this, "Eraser");
        _paint  = new SpriteButton(this, "Paint");

        _small  = new SpriteButton(this, "Small");
        _medium = new SpriteButton(this, "Medium");
        _large  = new SpriteButton(this, "Large");
        _huge   = new SpriteButton(this, "Huge");

        BrushModeConnect(_pencil, BrushMode.Pencil);
        BrushModeConnect(_eraser, BrushMode.Eraser);
        BrushModeConnect(_paint, BrushMode.Paint);

        BrushSizeConnect(_small, BrushSize.Small);
        BrushSizeConnect(_medium, BrushSize.Medium);
        BrushSizeConnect(_large, BrushSize.Large);
        BrushSizeConnect(_huge, BrushSize.Huge);
    }
Example #19
0
    /***************************
    *
    *
    * Main Action Menu Options
    *
    *
    ***************************/
    /// <summary>
    ///
    /// </summary>
    public void ChooseBasicAttack()
    {
        if (_attackMenu == null)
        {
            _attackMenu = Instantiate(attackMenuPrefab, BattleManager.battleCanvas.transform, false);
        }
//		Debug.LogFormat("Chose basic attack");
        previousOptions.Push(eventSystem.currentSelectedGameObject);            // Add attack action to previous options
        SpriteButton button = eventSystem.currentSelectedGameObject.GetComponent <SpriteButton>();

//		Debug.LogFormat("enqueing {0}", previousOptions.Peek());
        SetButtonsInteractable(_mainActionMenu, false);
        SetMenuActive(_attackMenu, true);
        SetButtonsInteractable(_attackMenu, true);
        eventSystem.SetSelectedGameObject(_attackMenu.transform.GetChild(0).gameObject);
        button.SpriteRenderer.sprite = button.spriteState.highlightedSprite;            // Show the highlighted sprite of the button
        TmpButton tmpButton = eventSystem.currentSelectedGameObject.GetComponent <TmpButton>();

        tmpButton.SpriteRenderer.sprite = tmpButton.spriteState.highlightedSprite;
//		Debug.Log("current attack " + tmpButton.name);
    }
    private void Start()
    {
        if (this.spriteButtonPrefab == null)
        {
            Debug.LogError("The sprite button prefab has not been assigned.");
        }

        GameObject gameObject = Instantiate(this.spriteButtonPrefab) as GameObject;
        gameObject.transform.parent = this.gameObject.transform;
        this.leftButton = gameObject.GetComponent<SpriteButton>();
        this.leftButton.Background = this.leftButtonBackground;
        this.leftButton.ActiveBackground = this.leftButtonActiveBackground;

        gameObject = Instantiate(this.spriteButtonPrefab) as GameObject;
        gameObject.transform.parent = this.gameObject.transform;
        this.downButton = gameObject.GetComponent<SpriteButton>();
        this.downButton.Background = this.downButtonBackground;
        this.downButton.ActiveBackground = this.downButtonActiveBackground;

        gameObject = Instantiate(this.spriteButtonPrefab) as GameObject;
        gameObject.transform.parent = this.gameObject.transform;
        this.rotateButton = gameObject.GetComponent<SpriteButton>();
        this.rotateButton.Background = this.rotateButtonBackground;
        this.rotateButton.ActiveBackground = this.rotateButtonActiveBackground;

        gameObject = Instantiate(this.spriteButtonPrefab) as GameObject;
        gameObject.transform.parent = this.gameObject.transform;
        this.rightButton = gameObject.GetComponent<SpriteButton>();
        this.rightButton.Background = this.rightButtonBackground;
        this.rightButton.ActiveBackground = this.rightButtonActiveBackground;

        // Inputs
        InputManager.Instance.LeftInputOverride = this.leftButton;
        InputManager.Instance.DownInputOverride = this.downButton;
        InputManager.Instance.RotateInputOverride = this.rotateButton;
        InputManager.Instance.RightInputOverride = this.rightButton;
    }
Example #21
0
    IEnumerator InitializeData()
    {
        yield return(null);

        Object[]            sprites    = Resources.LoadAll("Sprite Objects", typeof(SpriteData));
        List <SpriteButton> allButtons = new List <SpriteButton> ();

        for (int xx = 0; xx < sprites.Length; xx++)
        {
            SpriteButton newButton = Instantiate(spriteButton);
            newButton.data = sprites [xx] as SpriteData;
            allButtons.Add(newButton);
            if (File.Exists(Application.persistentDataPath + "/LevelData/" + newButton.data.myName + ".lev"))
            {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Open(Application.persistentDataPath + "/LevelData/" + newButton.data.myName + ".lev", FileMode.Open);
                ProgressData    dat  = (ProgressData)bf.Deserialize(file);
                file.Close();
                newButton.progress = dat;
            }
            if (File.Exists(Application.persistentDataPath + "/Thumbs/" + newButton.data.myName + ".png"))
            {
                byte[]    imageData = File.ReadAllBytes(Application.persistentDataPath + "/Thumbs/" + newButton.data.myName + ".png");
                Texture2D newTex    = new Texture2D(0, 0);
                newTex.LoadImage(imageData);
                newTex.filterMode = FilterMode.Point;
                newTex.wrapMode   = TextureWrapMode.Clamp;
                newTex.Apply();
                newButton.myCol.sprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 100);
            }
            else
            {
                newButton.myCol.sprite = Sprite.Create(newButton.data.thumb, new Rect(0, 0, newButton.data.thumb.width, newButton.data.thumb.height), Vector2.zero, 100);
            }
            newButton.myButton.onClick.AddListener(delegate {
                LoadLevel(newButton);
            });
        }
        System.Array         typeNums = System.Enum.GetValues(typeof(Globals.Categories));
        Globals.Categories[] types    = new Globals.Categories[typeNums.Length];
        System.Array.Copy(typeNums, types, typeNums.Length);

        for (int xx = 0; xx < types.Length; xx++)
        {
            Globals.CategoryCollection coll = new Globals.CategoryCollection();
            coll.buttons = new List <SpriteButton> ();
            coll.type    = types [xx];
            for (int yy = 0; yy < allButtons.Count; yy++)
            {
                if (coll.type != Globals.Categories.Started && coll.type != Globals.Categories.Completed)
                {
                    if (allButtons [yy].data.type == types [xx])
                    {
                        if (allButtons [yy].progress == null)
                        {
                            coll.buttons.Add(allButtons [yy]);
                        }
                        else if (!allButtons [yy].progress.started && !allButtons [yy].progress.completed)
                        {
                            coll.buttons.Add(allButtons [yy]);
                        }
                    }
                }
                else
                {
                    if (coll.type == Globals.Categories.Completed)
                    {
                        if (allButtons [yy].progress != null)
                        {
                            if (allButtons [yy].progress.completed)
                            {
                                coll.buttons.Add(allButtons [yy]);
                            }
                        }
                    }
                    else if (coll.type == Globals.Categories.Started)
                    {
                        if (allButtons [yy].progress != null)
                        {
                            if (!allButtons [yy].progress.completed)
                            {
                                if (allButtons [yy].progress.started)
                                {
                                    coll.buttons.Add(allButtons [yy]);
                                }
                            }
                        }
                    }
                }
            }
            coll.buttons = SortByDifficulty(true, coll.buttons);
            categories.Add(coll);
        }
        LayoutRebuilder.MarkLayoutForRebuild(spritePanel.GetComponent <RectTransform> ());
        initialized = true;
        state       = Globals.MainLoadState.InitialUnlock;
    }
Example #22
0
        public MenuInGame(GameState gameState) : base(gameState)
        {
            // On screen button -----------------------------------------------

            btnAttack = new Button
            {
                Anchor     = Anchor.BottomRight,
                Origine    = Anchor.BottomRight,
                Text       = "ATTACK",
                UnitBound  = new Rectangle(0, 0, 128, 128),
                UnitOffset = new Point(-128, 0)
            };

            btnAction = new Button
            {
                Anchor    = Anchor.BottomRight,
                Origine   = Anchor.BottomRight,
                Text      = "ACTION",
                UnitBound = new Rectangle(0, 0, 128, 128)
            };

            btnPickup = new Button
            {
                Anchor     = Anchor.BottomRight,
                Origine    = Anchor.BottomRight,
                Text       = "PICKUP",
                UnitBound  = new Rectangle(0, 0, 128, 128),
                UnitOffset = new Point(0, -128),
            };

            btnDrop = new Button
            {
                Anchor     = Anchor.BottomRight,
                Origine    = Anchor.BottomRight,
                Text       = "DROP",
                UnitBound  = new Rectangle(0, 0, 128, 128),
                UnitOffset = new Point(-128, -128)
            };

            btnMinimap = new SpriteButton
            {
                Anchor     = Anchor.TopRight,
                Enabled    = false,
                Origine    = Anchor.TopRight,
                Sprite     = new Sprite(Ressources.TileIcons, new Point(5, 4)),
                UnitOffset = new Point(-16, 16),
            };

            // Hud ------------------------------------------------------------

            _playerStats = new WidgetPlayerStats(GameState.LocalPlayer.Entity)
            {
                Anchor     = Anchor.TopLeft,
                Origine    = Anchor.TopLeft,
                UnitBound  = new Rectangle(0, 0, 320, 64),
                UnitOffset = new Point(16, 16),
            };

            _minimap = new WidgetFancyPanel()
            {
                Anchor     = Anchor.TopRight,
                Origine    = Anchor.TopRight,
                UnitBound  = new Rectangle(0, 0, 320, 320),
                UnitOffset = new Point(-16, 16),
                Content    = new WidgetMinimap(gameState)
            };

            _hotBar = new WidgetHotBar(GameState.LocalPlayer.Entity.GetComponent <Inventory>().Content)
            {
                Anchor     = Anchor.Bottom,
                Origine    = Anchor.Bottom,
                UnitOffset = new Point(0, -16)
            };

            Content = new Container
            {
                Childrens =
                {
                    _playerStats, _minimap,          btnMinimap,        _hotBar,

                    new Button {
                        Text = "Inventory",Origine = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, UnitOffset = new Point(16, -16)
                    }
                    .RegisterMouseClickEvent((sender) => { GameState.CurrentMenu = new PlayerInventoryMenu(GameState); })
                }
            };

            btnAction.MouseClick  += (sender) => { GameState.LocalPlayer.InputHandler.HandleInput(PlayerInput.Action); };
            btnAttack.MouseHold   += (sender) => { GameState.LocalPlayer.InputHandler.HandleInput(PlayerInput.Attack); };
            btnDrop.MouseClick    += (sender) => { GameState.LocalPlayer.InputHandler.HandleInput(PlayerInput.DropItem); };
            btnPickup.MouseClick  += (sender) => { GameState.LocalPlayer.InputHandler.HandleInput(PlayerInput.Pickup); };
            btnMinimap.MouseClick += (sender) => { _minimap.Toggle(); sender.Disable(); };

            _minimap.MouseClick += (sender) => { sender.Toggle(); btnMinimap.Enable(); };

            if (Rise.Platform.Family == PlatformFamily.Mobile)
            {
                var c = (Container)Content;
                c.AddChilds(btnAttack, btnAction, btnDrop, btnPickup);
            }
        }
Example #23
0
 public void OnRelease(SpriteButton button)
 {
     DoLogicsMenuBtns(button);
 }
Example #24
0
 public virtual void Activate(SpriteButton button)
 {
 }
Example #25
0
 private void OnEnable()
 {
     _spriteButton         = (SpriteButton)target;
     _interactableProperty = serializedObject.FindProperty("interactable");
 }
Example #26
0
        public LoadingMenu(Job job, GameState gameState) : base(gameState)
        {
            _job = job;

            PauseGame = true;

            _progressLabel = new Label
            {
                Text       = "Loading...",
                Anchor     = Anchor.Center,
                Origine    = Anchor.Center,
                Font       = Ressources.FontRomulus,
                UnitOffset = new Point(0, -24)
            };

            _progressBar = new ProgressBar
            {
                UnitBound  = new Rectangle(0, 0, 320, 8),
                Anchor     = Anchor.Center,
                Origine    = Anchor.Center,
                UnitOffset = new Point(0, 24)
            };

            var _cancelButton = new SpriteButton()
            {
                Sprite    = new Sprite(Ressources.TileGui, new Point(7, 7)),
                UnitBound = new Rectangle(0, 0, 48, 48),
                Anchor    = Anchor.TopRight,
                Origine   = Anchor.Center
            }.RegisterMouseClickEvent((sender) =>
            {
                _job.Cancel();
                Game.GoToMainMenu();
            });

            Content = new Container
            {
                Childrens =
                {
                    new WidgetFancyPanel
                    {
                        UnitBound = new Rectangle(0, 0, 840, 256),
                        Padding   = new Margins(16),
                        Anchor    = Anchor.Center,
                        Origine   = Anchor.Center,
                        Dock      = Rise.Platform.Family == Framework.Platform.PlatformFamily.Mobile ? Dock.Fill : Dock.None,
                        Content   = new Container
                        {
                            Childrens =
                            {
                                _progressBar,
                                _progressLabel,
                                _cancelButton
                            }
                        }
                    }
                }
            };

            _job.Start(true);

            _job.Finish += (sender, e) =>
            {
                gameState.CurrentMenu = new MenuInGame(gameState);
            };
        }
        public override void Load() {
            username = "";
            avatarIndex = 0;
            consent = true;
            
            var avatarButtonStyle = new ButtonStyle(
                textSizeNormal: 14f, textSizeHover: 14f, textSizePressed: 14f,
                textColorNormal: Color.Black, textColorHover: Color.Black, textColorPressed: Color.Black,
                fontLoaderInstance: FontLoader.SourceCodeBold);

            Root.AddChild(new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/login.jpg")));
            Root.AddChild(new TextField(670, 417, 500, 60, "", new TextFieldStyle(placeholderTextSizeNormal: 12f, placeholderTextSizeFocused: 12f), onValueChanged: (oldValue, newValue) => username = newValue));
            var avatarContainer = new Pivot {x = -100000f, y = 582};
            var avatarButton = new SpriteButton(856, 582, 128, 128, "Click\r\nto switch", new game.Sprite("data/sprites/avatars/female_1_128.png", true), avatarButtonStyle);
            avatarButton.OnClick += () => {
                avatarContainer.x = 230f;
                avatarButton.x = -100000f;
                MouseCursor.Instance.PreventMouseEventPropagation = true;
            };
            Root.AddChild(avatarButton);
            Root.AddChild(avatarContainer);
            var female1 = UIFactory.CreateAvatarSelectionEntry(128 * 0, 0, "data/sprites/avatars/female_1_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female1.OnClick += () => avatarIndex = 0;
            var female2 = UIFactory.CreateAvatarSelectionEntry(128 * 1 + 20, 0, "data/sprites/avatars/female_2_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female2.OnClick += () => avatarIndex = 1;
            var female3 = UIFactory.CreateAvatarSelectionEntry(128 * 2 + 20, 0, "data/sprites/avatars/female_3_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female3.OnClick += () => avatarIndex = 2;
            var female4 = UIFactory.CreateAvatarSelectionEntry(128 * 3 + 20, 0, "data/sprites/avatars/female_4_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female4.OnClick += () => avatarIndex = 3;
            var female5 = UIFactory.CreateAvatarSelectionEntry(128 * 4 + 20, 0, "data/sprites/avatars/female_5_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female5.OnClick += () => avatarIndex = 4;
            var male1 = UIFactory.CreateAvatarSelectionEntry(128 * 5 + 20, 0, "data/sprites/avatars/male_1_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male1.OnClick += () => avatarIndex = 5;
            var male2 = UIFactory.CreateAvatarSelectionEntry(128 * 6 + 20, 0, "data/sprites/avatars/male_2_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male2.OnClick += () => avatarIndex = 6;
            var male3 = UIFactory.CreateAvatarSelectionEntry(128 * 7 + 20, 0, "data/sprites/avatars/male_3_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male3.OnClick += () => avatarIndex = 7;
            var male4 = UIFactory.CreateAvatarSelectionEntry(128 * 8 + 20, 0, "data/sprites/avatars/male_4_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male4.OnClick += () => avatarIndex = 8;
            var male5 = UIFactory.CreateAvatarSelectionEntry(128 * 9 + 20, 0, "data/sprites/avatars/male_5_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male5.OnClick += () => avatarIndex = 9;
            avatarContainer.AddChild(female1);
            avatarContainer.AddChild(female2);
            avatarContainer.AddChild(female3);
            avatarContainer.AddChild(female4);
            avatarContainer.AddChild(female5);
            avatarContainer.AddChild(male1);
            avatarContainer.AddChild(male2);
            avatarContainer.AddChild(male3);
            avatarContainer.AddChild(male4);
            avatarContainer.AddChild(male5);
            
            Root.AddChild(new Checkbox(475, 775, 815, 60, "", (oldValue, newValue) => {
                consent = newValue;
            }) {IsChecked = true});
            Root.AddChild(new Button(800, 912, 243, 77, "Submit", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(username)) return;
                NetworkManager.Instance.CreateAccount(username, avatarIndex, consent);
                SceneManager.Instance.LoadScene("Map");
            }));
            IsLoaded = true;
        }
 void Start()
 {
     instance = this;
     spriteButton = GetComponent<SpriteButton>();
     RefreshButtons();
 }
Example #29
0
 public static Transitions GetTransition(SpriteButton sb)
 {
     return((Transitions)sb.GetValue(TransitionProperty));
 }
Example #30
0
        public void InitializeComponents()
        {
            PauseGame = true;

            var r = new List <List <Recipe> >();

            foreach (var e in GameState.LocalPlayer.Entity.Level.GetEntitiesOnArea(GameState.LocalPlayer.Entity.X, GameState.LocalPlayer.Entity.Y, Game.Unit * 3))
            {
                var s = e.GetComponent <CraftingStation>();
                if (s != null)
                {
                    if (!r.Contains(s.Recipies))
                    {
                        r.Add(s.Recipies);
                    }
                }
            }

            var recipies = new List <Recipe>();

            recipies.AddRange(RECIPIES.HandCrafted);
            foreach (var i in r)
            {
                recipies.AddRange(i);
            }

            _inventory = new WidgetItemContainer(GameState.LocalPlayer.Entity.GetComponent <Inventory>().Content);
            _crafting  = new CraftingTab(GameState, recipies);

            _inventory.Dock = Dock.Fill;

            _inventory.MouseClick += (sender) =>
            {
                _inventory.HighlightedItem = _inventory.SelectedItem;
                GameState.LocalPlayer.Entity.HoldingItem = _inventory.SelectedItem;
            };

            var closeBtn = new SpriteButton()
            {
                Sprite     = new Sprite(Ressources.TileGui, new Point(7, 7)),
                UnitBound  = new Rectangle(0, 0, 48, 48),
                Anchor     = Anchor.TopRight,
                Origine    = Anchor.TopRight,
                UnitOffset = new Point(-16, 16)
            };

            closeBtn.MouseClick += CloseBtnOnMouseClick;

            WidgetTabContainer _sideMenu = new WidgetTabContainer
            {
                Anchor     = Anchor.Center,
                Origine    = Anchor.Center,
                UnitBound  = new Rectangle(0, 0, 600, 720),
                Dock       = Rise.Platform.Family == PlatformFamily.Mobile ? Dock.Fill : Dock.None,
                TabAnchore = Rise.Platform.Family == PlatformFamily.Mobile ? TabAnchore.Bottom : TabAnchore.Left,
                Childrens  = { closeBtn },

                Tabs =
                {
                    new EquipmentTab(),
                    _crafting,
                    new Tab()
                    {
                        Icon    = new Sprite(Ressources.TileIcons, new Point(2,        3)),
                        Content = new Container()
                        {
                            Childrens =
                            {
                                new Label {
                                    Text = "Inventory",Font = Ressources.FontAlagard,           Dock = Dock.Top
                                },
                                _inventory,
                            }
                        }
                    },
                    new MinimapTab(GameState),
                    new SaveTab(GameState),
                }
            };

            Content = new Container()
            {
                Childrens = { _sideMenu },
            };
        }
Example #31
0
    public static Vector3 CalculateAnchors(SpriteButton button)
    {
        Vector3 newVector = button.transform.position;

        int id = button.screenID;

        float w = Screen.width;
        float h = Screen.height;

        if (Application.platform.Equals(RuntimePlatform.WindowsEditor) ||
            Application.platform.Equals(RuntimePlatform.OSXEditor))
        {
            w = EditorRes().x;
            h = EditorRes().y;
        }

        Vector3 s = button.gameObject.collider2D.bounds.size * 0.5f;

        Vector3 pw = Camera.main.ScreenToWorldPoint(new Vector3(w, 0, 10));
        Vector3 ph = Camera.main.ScreenToWorldPoint(new Vector3(0, h, 10));

        float wMod = id * (pw.x * 2);

        float wLimit = pw.x;
        float hLimit = ph.y;

        float ml = button.marginLeft / wLimit;
        float mr = button.marginRight / wLimit;
        float mt = button.marginTop / hLimit;
        float mb = button.marginBottom / hLimit;
        float mh = mr - ml;
        float mv = mt - mb;

        float modLeft   = -pw.x + s.x - mh + wMod;
        float modMiddle = 0 + wMod - mh;
        float modRight  = pw.x - s.x - mh + wMod;

        if (!button.anchor.Equals(SpriteButtonAnchor.NONE))
        {
            switch (button.anchor)
            {
            case SpriteButtonAnchor.TOP_LEFT:
                newVector = new Vector3(modLeft, ph.y - s.y + mv, 0);
                break;

            case SpriteButtonAnchor.TOP_CENTER:
                newVector = new Vector3(modMiddle, ph.y - s.y + mv, 0);
                break;

            case SpriteButtonAnchor.TOP_RIGHT:
                newVector = new Vector3(modRight, ph.y - s.y + mv, 0);
                break;

            case SpriteButtonAnchor.MIDDLE_LEFT:
                newVector = new Vector3(modLeft, 0 - mv, 0);
                break;

            case SpriteButtonAnchor.MIDDLE_CENTER:
                newVector = new Vector3(modMiddle, 0 - mv, 0);
                break;

            case SpriteButtonAnchor.MIDDLE_RIGHT:
                newVector = new Vector3(modRight, 0 - mv, 0);
                break;

            case SpriteButtonAnchor.BOTTOM_LEFT:
                newVector = new Vector3(modLeft, -ph.y + s.y - mv, 0);
                break;

            case SpriteButtonAnchor.BOTTOM_CENTER:
                newVector = new Vector3(modMiddle, -ph.y + s.y - mv, 0);
                break;

            case SpriteButtonAnchor.BOTTOM_RIGHT:
                newVector = new Vector3(modRight, -ph.y + s.y - mv, 0);
                break;
            }
        }

        return(newVector);
    }
Example #32
0
 public static void SetTransition(SpriteButton sb, Transitions value)
 {
     sb.SetValue(TransitionProperty, value);
 }