Exemple #1
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        string  text     = this.ValueEntry.SmartValue.text;
        int     number   = this.ValueEntry.SmartValue.number;
        Vector3 location = this.ValueEntry.SmartValue.location;

        Rect rect = EditorGUILayout.GetControlRect();

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(75);
        text     = SirenixEditorFields.TextField(rect.Split(0, 2), "Text", text);
        number   = SirenixEditorFields.IntField(rect.Split(1, 2), "Number", number);
        location = SirenixEditorFields.Vector3Field("Location", location);
        GUIHelper.PopLabelWidth();

        this.ValueEntry.SmartValue.text     = text;
        this.ValueEntry.SmartValue.number   = number;
        this.ValueEntry.SmartValue.location = location;
    }
Exemple #2
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <ushort> entry, GUIContent label)
        {
            int value = SirenixEditorFields.IntField(label, entry.SmartValue);

            if (value < ushort.MinValue)
            {
                value = ushort.MinValue;
            }
            else if (value > ushort.MaxValue)
            {
                value = ushort.MaxValue;
            }

            entry.SmartValue = (ushort)value;
        }
Exemple #3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry = this.ValueEntry;
            int value = SirenixEditorFields.IntField(label, entry.SmartValue);

            if (value < byte.MinValue)
            {
                value = byte.MinValue;
            }
            else if (value > byte.MaxValue)
            {
                value = byte.MaxValue;
            }

            entry.SmartValue = (byte)value;
        }
Exemple #4
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        Rect rect = EditorGUILayout.GetControlRect();

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(75);
        text.ValueEntry.WeakSmartValue = SirenixEditorFields.TextField(rect.Split(0, 2),
                                                                       "Text", (string)text.ValueEntry.WeakSmartValue);
        number.ValueEntry.WeakSmartValue = SirenixEditorFields.IntField(rect.Split(1, 2),
                                                                        "Number", (int)number.ValueEntry.WeakSmartValue);
        location.Draw();
        GUIHelper.PopLabelWidth();
    }
        /// <summary>
        /// Handles the Minesweeper game.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            Rect rect = EditorGUILayout.GetControlRect();

            this.ValueEntry.SmartValue = Mathf.Clamp(SirenixEditorFields.IntField(rect.AlignLeft(rect.width - 80 - 4), "Number of Bombs", this.ValueEntry.SmartValue), 1, (BoardSize * BoardSize) / 4);

            // Start game
            if (GUI.Button(rect.AlignRight(80), "Start"))
            {
                this.StartGame(this.ValueEntry.SmartValue);
            }

            // Game
            SirenixEditorGUI.BeginShakeableGroup(this.Key);
            if (this.isRunning)
            {
                this.Game();
            }
            SirenixEditorGUI.EndShakeableGroup(this.Key);
        }
Exemple #6
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var value = this.ValueEntry.SmartValue;

            var YYYYMMDDhhmmssRect = EditorGUILayout.GetControlRect();

            YYYYMMDDhhmmssRect = EditorGUI.IndentedRect(YYYYMMDDhhmmssRect);

            if (label != null)
            {
                YYYYMMDDhhmmssRect = EditorGUI.PrefixLabel(YYYYMMDDhhmmssRect, label);
            }

            var currYear  = value.Year;
            var currMonth = value.Month;
            var currDay   = value.Day;
            var currHour  = value.Hour;
            var currMin   = value.Minute;
            var currSec   = value.Second;

            var newYear  = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(0, 6), currYear);
            var newMonth = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(1, 6), currMonth);
            var newDay   = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(2, 6), currDay);
            var newHour  = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(3, 6), currHour);
            var newMin   = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(4, 6), currMin);
            var newSec   = SirenixEditorFields.IntField(YYYYMMDDhhmmssRect.Split(5, 6), currSec);

            if (currYear != newYear || currMonth != newMonth || currDay != newDay ||
                currHour != newHour || newMin != currMin || newSec != currSec)
            {
                this.ValueEntry.SmartValue = new DateTime(
                    year: newYear,
                    month: newMonth,
                    day: newDay,
                    hour: newHour,
                    minute: newMin,
                    second: newSec);
                this.ValueEntry.ApplyChanges();
            }
        }
Exemple #7
0
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(GUIContent label)
 {
     this.ValueEntry.SmartValue = SirenixEditorFields.IntField(label, this.ValueEntry.SmartValue);
 }
 protected override int DrawElement(Rect rect, int value)
 {
     return(SirenixEditorFields.IntField(rect.Padding(2), value));
 }
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(IPropertyValueEntry <int> entry, GUIContent label)
 {
     entry.SmartValue = SirenixEditorFields.IntField(label, entry.SmartValue);
 }
Exemple #10
0
        /// <summary>
        /// Handles the Minesweeper game.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <int> entry, MinesweeperAttribute attribute, GUIContent label)
        {
            PropertyContext <GameContext> context;

            if (entry.Context.Get(this, "GameContext", out context))
            {
                context.Value = new GameContext()
                {
                    IsRunning    = false,
                    GameOver     = false,
                    VisibleTiles = new Tile[BoardSize, BoardSize],
                    Tiles        = new Tile[BoardSize, BoardSize],
                    Key          = new object(),
                };
            }

            GameContext game = context.Value;

            Rect rect = EditorGUILayout.GetControlRect();

            entry.SmartValue = Mathf.Clamp(SirenixEditorFields.IntField(rect.AlignLeft(rect.width - 80 - 4), "Number of Bombs", entry.SmartValue), 1, (BoardSize * BoardSize) / 4);

            // Start game
            if (GUI.Button(rect.AlignRight(80), "Start"))
            {
                game.NumberOfBombs = entry.SmartValue;
                game.FlaggedBombs  = 0;

                for (int x = 0; x < BoardSize; x++)
                {
                    for (int y = 0; y < BoardSize; y++)
                    {
                        game.VisibleTiles[x, y] = Tile.None;
                        game.Tiles[x, y]        = Tile.None;
                    }
                }

                // Spawn bombs.
                for (int count = 0; count < game.NumberOfBombs;)
                {
                    int x = UnityEngine.Random.Range(0, BoardSize);
                    int y = UnityEngine.Random.Range(0, BoardSize);

                    if (game.Tiles[x, y] != Tile.Bomb)
                    {
                        game.Tiles[x, y] = Tile.Bomb;

                        if (x + 1 < BoardSize && game.Tiles[x + 1, y] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y] = (Tile)((int)game.Tiles[x + 1, y] + 1);
                        }
                        if (x + 1 < BoardSize && y + 1 < BoardSize && game.Tiles[x + 1, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y + 1] = (Tile)((int)game.Tiles[x + 1, y + 1] + 1);
                        }
                        if (y + 1 < BoardSize && game.Tiles[x, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x, y + 1] = (Tile)((int)game.Tiles[x, y + 1] + 1);
                        }
                        if (x - 1 >= 0 && y + 1 < BoardSize && game.Tiles[x - 1, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y + 1] = (Tile)((int)game.Tiles[x - 1, y + 1] + 1);
                        }

                        if (x - 1 >= 0 && game.Tiles[x - 1, y] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y] = (Tile)((int)game.Tiles[x - 1, y] + 1);
                        }
                        if (x - 1 >= 0 && y - 1 >= 0 && game.Tiles[x - 1, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y - 1] = (Tile)((int)game.Tiles[x - 1, y - 1] + 1);
                        }
                        if (y - 1 >= 0 && game.Tiles[x, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x, y - 1] = (Tile)((int)game.Tiles[x, y - 1] + 1);
                        }
                        if (x + 1 < BoardSize && y - 1 >= 0 && game.Tiles[x + 1, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y - 1] = (Tile)((int)game.Tiles[x + 1, y - 1] + 1);
                        }

                        count++;
                    }
                }
                game.IsRunning = true;
                game.GameOver  = false;
                game.PrevTime  = EditorApplication.timeSinceStartup;
                game.Time      = 0;
            }

            // Game

            SirenixEditorGUI.BeginShakeableGroup(game.Key);
            if (game.IsRunning)
            {
                this.Game(game);
            }
            SirenixEditorGUI.EndShakeableGroup(game.Key);
        }