コード例 #1
0
        public GameMap(LevelItem level, Size size)
        {
            Level          = level;
            SizeScreen     = size;
            Figures        = new Dictionary <int, Figure>();
            SuccsessionsID = new SortedDictionary <int, int>();

            string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var    levelData  = File.ReadAllText(Path.Combine(folderPath, level.Source));
            var    map        = Parser.Parser.FromJson(levelData);
            var    sizeMap    = new Size(map.Width, map.Height);

            float _cW = (float)((float)(size.Width / sizeMap.Width) / 1.5);
            float _cH = (float)((float)(size.Height / sizeMap.Height) / 1.2);

            var _c = _cW < _cH ? _cW : _cH;


            sizeMap.Width  *= _c;
            sizeMap.Height *= _c;

            foreach (var item in map.FiguresData)
            {
                Figure figure = Figure.FromData(item, _c);
                Figures[figure.Id]            = figure;
                SuccsessionsID[figure.ZIndex] = figure.Id;
            }

            Move(new Point(-map.DrawPoint.X * _c, -map.DrawPoint.Y * _c));
            Move(new Point(size.Width / 2 - sizeMap.Width / 2, size.Height / 2 - sizeMap.Height / 2));
        }
コード例 #2
0
        public void Show(int index, LevelItem level)
        {
            _index = index;

            var text = textGo.GetComponent <Text>();

            text.text = level.Name;

            var levelStarsManager = starsGo.GetComponent <LevelStarsManager>();

            levelStarsManager.ShowStars(level.Stars);

            if (!level.Available)
            {
                var button = GetComponent <Button>();
                button.interactable = false;

                var image = GetComponent <Image>();
                image.color += Color.black * -0.2f;

                text.color += Color.black * -0.5f;

                levelStarsManager.ShowStarsAsDisabled();
                Destroy(playButtonGo);
            }
        }
コード例 #3
0
ファイル: EconomyWindow.cs プロジェクト: Peteys93/MCGalaxy
        private void buttonRemove_Click(object sender, EventArgs e) {
			LevelItem item = Economy.Levels;
            item.Presets.Remove(item.FindPreset(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()));
            dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
            buttonRemove.Enabled = checkBoxLevel.Checked && dataGridView1.SelectedRows.Count > 0;
            buttonEdit.Enabled = checkBoxLevel.Checked && dataGridView1.SelectedRows.Count > 0;
        }
コード例 #4
0
    private void LoadObjectsWithOverride(Level.ItemSave[] levelParts)
    {
        DestroyObjects();

        for (int i = 0; i < levelParts.Length; i++)
        {
            LevelItem item = itemsDatabase.GetItem(levelParts[i].Item);

            if (item != null)
            {
                GameObject prefab = Instantiate(item.Prefab);
                prefab.transform.position    = levelParts[i].Position;
                prefab.transform.eulerAngles = levelParts[i].Rotation;

                LevelItemBehaviour itemBehaviour = prefab.GetComponent <LevelItemBehaviour>();
                itemBehaviour.transform.localScale = levelParts[i].Scale;
                itemBehaviour.Init(levelParts[i].Type);

                prefab.transform.SetParent(objectsContainer.transform);

                prefab.isStatic = levelParts[i].IsStatic;
            }
            else
            {
                Debug.LogError("[LevelEditor] Can't find item: \"" + levelParts[i].Item + "\"");
            }
        }
    }
    /// <summary>
    /// Adds a level with id = levelId to list of completed levels and updates game data
    /// </summary>
    /// <param name="levelId">id of the completed level</param>
    /// <param name="xpEarned">amount of xp earned</param>
    /// <param name="goldEarned">gold earned by the player</param>
    /// <param name="gemsEarned">gems earned by the player</param>
    /// <param name="stonesCollected">stones collected during gameplay</param>
    /// <param name="time">time spent playing level</param>
    /// <param name="damageDone">damage done by player</param>
    /// <param name="damageTaken">damage taken by player from enemies</param>
    /// <param name="kills">total number of enemies killed by player</param>
    /// <param name="hits">total hits done during game session</param>
    /// <param name="playerLevel">the level the player is currently at</param>
    public bool CompleteLevel(string levelId, LevelList levelList, int xpEarned, int goldEarned, int gemsEarned,
                              int stonesCollected, float time, float damageDone, float damageTaken,
                              int kills, float hits, int playerLevel, int xpToNext, float shotAccuracy, int score)
    {
        foreach (LevelSaveData level in completedLevels)
        {
            if (level.id == levelId)
            {
                Debug.Log("[Completing level....1]");
                level.time = Mathf.Min(level.time, time);
                return(false);
            }
        }
        Debug.Log("[Completing level.....2]woaaah!!!");
        completedLevels.Add(new LevelSaveData(levelId, xpEarned, goldEarned, gemsEarned,
                                              kills, damageDone, damageTaken, time, stonesCollected, hits, shotAccuracy, score));

        LevelItem completedLevel = levelList[levelId];

        if (completedLevel != null)
        {
            int index = levelList.IndexOf(completedLevel);
            int next  = index + 1;
            if (levelList[next] != null)
            {
                // PROBLEM = the locked state of a level is not saved
                // FIGURE OUT WHY AND FIX IT
                levelList[next].Locked = false;
            }
        }

        return(true);
    }
コード例 #6
0
        /// <summary>
        /// Safely unsubscribes from <see cref="LevelManager" /> events.
        /// Goes to the next scene if valid
        /// </summary>
        public void GoToNextLevel()
        {
            SafelyUnsubscribe();
            if (!GameManager.instanceExists)
            {
                return;
            }
            GameManager gm         = GameManager.instance;
            LevelItem   item       = gm.GetLevelForCurrentScene();
            LevelList   list       = gm.levelList;
            int         levelCount = list.Count;
            int         index      = -1;

            for (int i = 0; i < levelCount; i++)
            {
                if (item == list[i])
                {
                    index = i + 1;
                    break;
                }
            }
            if (index < 0 || index >= levelCount)
            {
                return;
            }
            LevelItem nextLevel = gm.levelList[index];

            SceneManager.LoadScene(nextLevel.sceneName);
        }
 private void Awake()
 {
     elapsedMinutes = 0;
     elapsedSeconds = 0;
     seconds        = null;
     level          = GameManager.instance.GetLevelForCurrentScene();
 }
コード例 #8
0
ファイル: LevelSelectMenu.cs プロジェクト: dqtoy/GGJ2020
        public void PlayLevel()
        {
            // update level state with random number
            selectedLevelItem.Score      = UnityEngine.Random.Range(1000, 9999);
            selectedLevelItem.StarNumber = (LevelStarNumber)UnityEngine.Random.Range(1, 4);

            LogInfo(String.Format("Level {0} finished. score={1}, starNumber={2}", selectedLevelItem.LevelID, selectedLevelItem.Score, selectedLevelItem.StarNumber));

            // unlock next level
            int nextLevelID = selectedLevelItem.LevelData.levelID + 1;

            if (levelItemDictionary.ContainsKey(nextLevelID))
            {
                // get next level
                var nextLevel = levelItemDictionary[nextLevelID];

                if (nextLevel.IsLocked)
                {
                    // unlock level
                    nextLevel.IsLocked = false;

                    LogInfo(String.Format("Unlock level {0}", nextLevel.LevelID));
                }
            }

            // close level info
            ShowLevelInfo = false;

            // reset selected
            selectedLevelItem = null;
        }
コード例 #9
0
ファイル: LevelRepository.cs プロジェクト: 9PK4U/Tangram
        public void UpdateDataBase()
        {
            IMongoDatabase database = client.GetDatabase("GameData");

            IMongoCollection <BsonDocument> collection = database.GetCollection <BsonDocument>("Maps");

            var documents = collection.Find(new BsonDocument())
                            .Project(Builders <BsonDocument> .Projection.Exclude("_id"))
                            .ToList();

            foreach (var item in documents)
            {
                if (!db.FindItem(item["Title"].AsString))
                {
                    AddLevel(LevelItem.FromBson(item), item.ToJson());
                }
            }

            //МАКСУ
            //collection.UpdateOneAsync(
            //new BsonDocument("Update", "Levels"),
            //new BsonDocument("$set", new BsonDocument("DataLevelUpdate", DateTime.Now.ToString())));


            IMongoCollection <BsonDocument> collectionConf = database.GetCollection <BsonDocument>("Configurations");
            var document     = collectionConf.Find(new BsonDocument()).FirstOrDefault();
            var dateUpdateDB = document.GetValue("DataLevelUpdate", null);

            Preferences.Set("DATE_UPDATE_LEVEL", dateUpdateDB.ToString());
        }
コード例 #10
0
        ObservableCollection <LevelItem> CreateLevels(string key, int enabledLevels)
        {
            var levels = new ObservableCollection <LevelItem>();

            for (var i = 0; i < MaxLevels; i++)
            {
                var level = new LevelItem(i);
                level.Name    = GetLevelNameFromLevelId(i);
                level.Enabled = (enabledLevels & (1 << i)) > 0;

                level.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName != "Enabled")
                    {
                        return;
                    }

                    var levelItem = (LevelItem)sender;
                    var e         = new LevelItemChangedEventArgs(key, levelItem.LevelId, levelItem.Enabled);
                    OnLevelItemChanged(e);
                };

                levels.Add(level);
            }

            return(levels);
        }
コード例 #11
0
        /// <summary>
        /// Shows the end game screen
        /// </summary>
        protected void OpenEndGameScreen(string endResultText)
        {
            LevelItem level = GameManager.instance.GetLevelForCurrentScene();

            endGameCanvas.enabled = true;

            int score = CalculateFinalScore();

            scorePanel.SetStars(score);
            if (level != null)
            {
                endGameMessageText.text = string.Format(endResultText, level.name.ToUpper());
                GameManager.instance.CompleteLevel(level.id, score);
            }
            else
            {
                // If the level is not in LevelList, we should just use the name of the scene. This will not store the level's score.
                string levelName = SceneManager.GetActiveScene().name;
                endGameMessageText.text = string.Format(endResultText, levelName.ToUpper());
            }


            if (!HUD.GameUI.instanceExists)
            {
                return;
            }
            if (HUD.GameUI.instance.state == HUD.GameUI.State.Building)
            {
                HUD.GameUI.instance.CancelGhostPlacement();
            }
            HUD.GameUI.instance.GameOver();
        }
コード例 #12
0
        private void LoadLevels()
        {
            comboBoxLevels.DisplayMember = "Name";
            comboBoxLevels.ValueMember   = "Value";
            comboBoxLevels.Items.Clear();

            comboBoxLevels.Items.Add(new LevelItem("Native\tNone\t0", EtwTraceLevel.None));
            comboBoxLevels.Items.Add(new LevelItem("Native\tFatal\t1", EtwTraceLevel.Fatal));
            comboBoxLevels.Items.Add(new LevelItem("Native\tError\t2", EtwTraceLevel.Error));
            comboBoxLevels.Items.Add(new LevelItem("Native\tWarning\t3", EtwTraceLevel.Warning));
            comboBoxLevels.Items.Add(new LevelItem("Native\tInformation\t4", EtwTraceLevel.Information));
            comboBoxLevels.Items.Add(new LevelItem("Native\tVerbose\t5", EtwTraceLevel.Verbose));
            comboBoxLevels.Items.Add(string.Empty);
            comboBoxLevels.Items.Add(new LevelItem(".NET\tCritical\t1", TraceEventType.Critical));
            comboBoxLevels.Items.Add(new LevelItem(".NET\tError\t2", TraceEventType.Error));
            comboBoxLevels.Items.Add(new LevelItem(".NET\tWarning\t4", TraceEventType.Warning));
            comboBoxLevels.Items.Add(new LevelItem(".NET\tInformation\t8", TraceEventType.Information));
            comboBoxLevels.Items.Add(new LevelItem(".NET\tVerbose\t16", TraceEventType.Verbose));

            foreach (object o in comboBoxLevels.Items)
            {
                LevelItem item = o as LevelItem;
                if (item != null && item.Name == ((byte)EtwProvider.TraceLevel).ToString())
                {
                    comboBoxLevels.SelectedItem = item;
                    return;
                }
            }
        }
    /// <summary>
    /// Create and instantiate a level select button base on item
    /// </summary>
    /// <param name="item">The level data</param>
    /// <returns>The created button</returns>
    protected LevelSelectButton CreateButton(LevelItem item)
    {
        LevelSelectButton button = Instantiate(SelectionPrefab);

        button.Initialize(item);
        return(button);
    }
コード例 #14
0
        //Helper functions? Here? :O
        public static List <LevelItem> ObjToList(LevelItem obj)
        {
            List <LevelItem> l = new List <LevelItem>();

            l.Add(obj);
            return(l);
        }
コード例 #15
0
    /// <summary>
    /// Assigns data from item to button
    /// </summary>
    /// <param name="item"></param>
    public void Initialize(LevelItem item)
    {
        LazyLoad();
        if (TitleDisplay == null)
        {
            return;
        }
        m_Item            = item;
        TitleDisplay.text = item.name;
        CheckLevelAvailability();

        /**if (item.Locked)
         * {
         *  // Check if the previous level has been completed
         *  // TODO : FIX THIS STUFF LATER
         *
         *  Time.gameObject.SetActive(false);
         *  Description.text = "Complete previous level to unlock";
         *  PlayButton.interactable = false;
         *  PlayButton.image.color = new Color(145, 145, 145);
         *  PlayButtonText.text = "LOCKED";
         *  LockImage.gameObject.SetActive(true);
         * }
         * else
         * {
         *  Time.gameObject.SetActive(true);
         *  Description.text = item.description;
         *  PlayButton.interactable = true;
         *  PlayButton.image.color = new Color(255, 255, 0);
         *  PlayButtonText.text = "PLAY!";
         *  LockImage.gameObject.SetActive(false);
         * }**/
        HasPlayedState();
    }
コード例 #16
0
ファイル: TransformGizmo.cs プロジェクト: SkyNinja/sa_tools
        public void TransformGizmoMove(System.Drawing.Point mouseDelta, EditorCamera cam, EditorItemSelection selectedItems)
        {
            if (Enabled)
            {
                Vector2 gizmoMouseInput = new Vector2(mouseDelta.X / 2 * cam.MoveSpeed, mouseDelta.Y / 2 * cam.MoveSpeed);

                switch (Mode)
                {
                case TransformMode.NONE:
                    break;

                case TransformMode.TRANFORM_MOVE:
                    // move all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        item.Position = Move(gizmoMouseInput,
                                             item.Position.ToVector3(), cam).ToVertex();

                        if (item is LevelItem)
                        {
                            LevelItem levelItem = item as LevelItem;                         // recalculating the entire bounds could be slow
                            levelItem.CalculateBounds();                                     // what if we just moved the bounds position instead?
                        }
                    }

                    Item firstItem = selectedItems.Get(0);
                    //transformGizmo.SetGizmo(transformGizmo.Position, firstItem.TransformMatrix);
                    SetGizmo(
                        ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                        firstItem.TransformMatrix);
                    break;

                case TransformMode.TRANSFORM_ROTATE:
                    // rotate all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        item.Rotation = Rotate(gizmoMouseInput, cam, item.Rotation);
                    }

                    firstItem = selectedItems.Get(0);
                    SetGizmo(Position, firstItem.TransformMatrix);
                    break;

                case TransformMode.TRANSFORM_SCALE:
                    // scale all of our editor selected items
                    foreach (Item item in selectedItems.Items)
                    {
                        if (item is IScaleable scalableItem)
                        {
                            scalableItem.SetScale(Scale(gizmoMouseInput, scalableItem.GetScale(), cam, true, 0));
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
コード例 #17
0
ファイル: LevelSelectMenu.cs プロジェクト: dqtoy/GGJ2020
        public void CloseLevelInfo()
        {
            // close level info
            ShowLevelInfo = false;

            // reset selected
            selectedLevelItem = null;
        }
コード例 #18
0
    LevelItem AddLevel()
    {
        MadUndo.RecordObject2(configuration, "Add Level");

        var levelItem = new LevelItem(configuration);

        levelItem.level.group = currentGroup;

        LevelItem template = null;

        if (list.selectedItem != null)
        {
            template = list.selectedItem;
        }
        else if (items.Count > 0)
        {
            template = items.Last();
        }

        if (template != null)
        {
            levelItem.level.order = template.level.order + 1;

            levelItem.level.name        = UniqueLevelName(template.level.name);
            levelItem.level.sceneObject = template.level.sceneObject;
            levelItem.level.type        = template.level.type;

            levelItem.level.extension = template.level.extension;
        }
        else
        {
            levelItem.level.order = 0;

            levelItem.level.name = "New Level";
            levelItem.level.type = MadLevel.Type.Level;
        }

        // check if there is a level that is not locked by default
        // if there isn't one, then set this one to be
        bool hasLockedByDefault = items.Find((item) => item.level.type == MadLevel.Type.Level && !item.level.lockedByDefault) != null;

        if (!hasLockedByDefault)
        {
            levelItem.level.lockedByDefault = false;
        }

        items.Add(levelItem);
        configuration.levels.Add(levelItem.level);

        Reorder();

        configuration.SetDirty();

        list.selectedItem = levelItem;
        list.ScrollToItem(levelItem);

        return(levelItem);
    }
 /// <summary>
 /// Clears all level data and progress
 /// </summary>
 public void ClearLevelData()
 {
     for (int i = 1; i < LevelList.Count; i++)
     {
         LevelItem level = LevelList[i];
         level.Locked = true;
         level.time   = 0;
     }
 }
コード例 #20
0
        public void SetData(LevelItem data, int starts, Action <string> clickCallback)
        {
            _titleDisplay.text = data.Name;
            _description.text  = data.Description;
            for (var i = 0; i < starts; i++)
            {
                _stars[i].overrideSprite = _starAchieved;
            }

            _enterBtn.onClick.AddListener(() => clickCallback?.Invoke(data.Id));
        }
コード例 #21
0
    void ItemSelected(LevelItem item)
    {
        Repaint();
        var focusedControl = GUI.GetNameOfFocusedControl();

        if (!string.IsNullOrEmpty(focusedControl))
        {
            GUI.SetNextControlName("");
            GUI.FocusControl("");
        }
    }
コード例 #22
0
ファイル: GameManager.cs プロジェクト: moto2002/DefenseGame
        public PlayInfoSaveData GetPlayerInfo()
        {
            //测试 给了默认的数据
            LevelItem level = GameManager.instance.GetLevelForCurrentScene();

            CompleteLevel(level.id, 3);
            SetPlayerInfo(new PlayInfoSaveData(10086, "Ditto1", 1, m_DataStore.completedLevels));
            PlayInfoSaveData playInfoSaveData = m_DataStore.GetPlayerInfo();

            Debug.Log("playInfoSaveData:" + playInfoSaveData.playerName);
            return(playInfoSaveData);
        }
コード例 #23
0
 private void OpenScene(LevelItem item)
 {
     if (item.level.sceneObject != null)
     {
         EditorApplication.delayCall += () => {
             if (EditorApplication.SaveCurrentSceneIfUserWantsTo())
             {
                 EditorApplication.OpenScene(item.level.scenePath);
             }
         };
     }
 }
コード例 #24
0
 public string GetParentId(LevelTreeDefinition def, int level, string value)
 {
     if (level == 0)
     {
         return("#");
     }
     else
     {
         LevelItem item = def.GetLevelItem(level - 1);
         return(value.Substring(0, item.End).PadRight(def.TotalCount, '0'));
     }
 }
コード例 #25
0
ファイル: NSMBLevel.cs プロジェクト: poudink/NSMB-Editor
        public int RemoveZIndex(LevelItem obj)
        {
            int idx = -1;

            if (obj is NSMBObject)
            {
                idx = Objects.IndexOf(obj as NSMBObject);
                Objects.Remove(obj as NSMBObject);
            }
            if (obj is NSMBSprite)
            {
                idx = Sprites.IndexOf(obj as NSMBSprite);
                Sprites.Remove(obj as NSMBSprite);
            }
            if (obj is NSMBEntrance)
            {
                idx = Entrances.IndexOf(obj as NSMBEntrance);
                Entrances.Remove(obj as NSMBEntrance);
            }
            if (obj is NSMBView)
            {
                NSMBView v = obj as NSMBView;
                if (v.isZone)
                {
                    idx = Zones.IndexOf(v);
                    Zones.Remove(v);
                }
                else
                {
                    idx = Views.IndexOf(v);
                    Views.Remove(v);
                }
            }
            if (obj is NSMBPathPoint)
            {
                NSMBPathPoint pp = obj as NSMBPathPoint;
                idx = pp.parent.points.IndexOf(pp);
                pp.parent.points.Remove(pp);
                if (pp.parent.points.Count == 0)
                {
                    if (pp.parent.isProgressPath)
                    {
                        ProgressPaths.Remove(pp.parent);
                    }
                    else
                    {
                        Paths.Remove(pp.parent);
                    }
                }
            }
            return(idx == -1 ? 0 : idx);
        }
コード例 #26
0
    private LevelItem GetLevelItem(Sprite sprite, int xPos, int yPos)
    {
        Vector2Int position = new Vector2Int(xPos, yPos);
        GameObject go       = new GameObject("LevelItemSprite");

        go.transform.SetParent(transform);
        go.transform.position = new Vector3((LevelBoundary.x / 2f) - xPos, (LevelBoundary.y / 2f) - yPos);
        go.AddComponent <SpriteRenderer>().sprite = sprite;

        LevelItem item = new LevelItem(position, go);

        return(item);
    }
コード例 #27
0
 /// <summary>
 /// A method for assigning the data from item to the button
 /// </summary>
 /// <param name="item">
 /// The data with the information concerning the level
 /// </param>
 public void Initialize(LevelItem item, MouseScroll mouseScroll)
 {
     LazyLoad();
     if (titleDisplay == null)
     {
         return;
     }
     m_Item            = item;
     titleDisplay.text = item.name;
     description.text  = item.description;
     HasPlayedState();
     m_MouseScroll = mouseScroll;
 }
コード例 #28
0
ファイル: LevelRepository.cs プロジェクト: 9PK4U/Tangram
        public void AddLevel(LevelItem level, string lvldata)
        {
            string filename = $"{level.Name}.lvldt";

            level.Source = filename;
            if (String.IsNullOrEmpty(filename))
            {
                return;
            }

            File.WriteAllText(Path.Combine(folderPath, filename), lvldata);
            db.AddItem(level);
        }
コード例 #29
0
 void InitLevel()
 {
     for (int i = 0; i < LevelSelectBtn.Length; i++)
     {
         IsLook[i]     = LevelSelectBtn[CulPos(i)].transform.Find("Lock").gameObject.GetComponent <Image>();
         LeftStar[i]   = LevelSelectBtn[CulPos(i)].transform.Find("StarLeft").gameObject.GetComponent <Image>();
         RightStar[i]  = LevelSelectBtn[CulPos(i)].transform.Find("StarRight").gameObject.GetComponent <Image>();
         CenterStar[i] = LevelSelectBtn[CulPos(i)].transform.Find("StarCenter").gameObject.GetComponent <Image>();
         LevelNum[i]   = LevelSelectBtn[CulPos(i)].transform.Find("Text").gameObject.GetComponent <Text>();
     }
     for (int i = 0; i < GameDataManage.Instance.LevelListDatas.Count; i++)
     {
         LevelItem levelItem = GameDataManage.Instance.GetLevelItemData(10001 + i);
         if (levelItem.isopen)
         {
             IsLook[i].gameObject.SetActive(false);
             LevelNum[i].gameObject.SetActive(true);
             LevelNum[i].text = (i + 1).ToString();
         }
         else
         {
             IsLook[i].gameObject.SetActive(true);
             LevelNum[i].text = (i + 1).ToString();
             LevelNum[i].gameObject.SetActive(false);
         }
         if (levelItem.star == 1)
         {
             LeftStar[i].gameObject.SetActive(true);
             CenterStar[i].gameObject.SetActive(false);
             RightStar[i].gameObject.SetActive(false);
         }
         else if (levelItem.star == 2)
         {
             LeftStar[i].gameObject.SetActive(true);
             CenterStar[i].gameObject.SetActive(true);
             RightStar[i].gameObject.SetActive(false);
         }
         else if (levelItem.star == 3)
         {
             LeftStar[i].gameObject.SetActive(true);
             CenterStar[i].gameObject.SetActive(true);
             RightStar[i].gameObject.SetActive(true);
         }
         else
         {
             LeftStar[i].gameObject.SetActive(false);
             CenterStar[i].gameObject.SetActive(false);
             RightStar[i].gameObject.SetActive(false);
         }
     }
 }
コード例 #30
0
        private Rectangle GetViewTextRect(LevelItem view)
        {
            Rectangle visible = EdControl.ViewablePixels;

            visible = new Rectangle(visible.X, visible.Y, visible.Width, visible.Height);
            if (!visible.IntersectsWith(new Rectangle(view.x, view.y, view.width, view.height)))
            {
                return(Rectangle.Empty);
            }
            NSMBView  v        = view as NSMBView;
            Rectangle viewText = new Rectangle(new Point(Math.Max(v.x, visible.X), Math.Max(v.y, visible.Y) + (v.isZone ? 16 : 0)), TextRenderer.MeasureText(v.GetDisplayString(), NSMBGraphics.SmallInfoFont));

            return(viewText);
        }
コード例 #31
0
        public void setLevelItem(LevelItem it)
        {
            this.it = it;
            updating = true;

            if (it == null)
            {
                Enabled = false;
            }
            else
            {
                Enabled = true;

                xUpDown.Value = Math.Min(xUpDown.Maximum, Math.Max(xUpDown.Minimum, it.rx / it.snap));
                yUpDown.Value = Math.Min(yUpDown.Maximum, Math.Max(yUpDown.Minimum, it.ry / it.snap));

                widthUpDown.Enabled = it.isResizable;
                heightUpDown.Enabled = it.isResizable;
                widthUpDown.Value = it.rwidth / it.snap;
                heightUpDown.Value = it.rheight / it.snap;
            }

            updating = false;
        }
コード例 #32
0
 void LoadItems() {
     var configurationLevels = currentGroup.GetLevels();
     if (items.Count != configurationLevels.Count) {
     
         items.Clear();
         foreach (var level in configurationLevels) {
             var item = new LevelItem(level);
             items.Add(item);
         }
         
     }
     
     Reorder();
 }
コード例 #33
0
    LevelItem AddLevel() {
        MadUndo.RecordObject2(configuration, "Add Level");
        
        var levelItem = new LevelItem(configuration);
        levelItem.level.group = currentGroup;
        
        LevelItem template = null;
        
        if (list.selectedItem != null) {
            template = list.selectedItem;
        } else if (items.Count > 0) {
            template = items.Last();
        }
        
        if (template != null) {
            levelItem.level.order = template.level.order + 1;
            
            levelItem.level.name = UniqueLevelName(template.level.name);
            levelItem.level.sceneObject = template.level.sceneObject;
            levelItem.level.type = template.level.type;

            levelItem.level.extension = template.level.extension;
        } else {
            levelItem.level.order = 0;
            
            levelItem.level.name = "New Level";
            levelItem.level.type = MadLevel.Type.Level;
        }

        // check if there is a level that is not locked by default
        // if there isn't one, then set this one to be
        bool hasLockedByDefault = items.Find((item) => item.level.type == MadLevel.Type.Level && !item.level.lockedByDefault) != null;
        if (!hasLockedByDefault) {
            levelItem.level.lockedByDefault = false;
        }
        
        items.Add(levelItem);
        configuration.levels.Add(levelItem.level);
        
        Reorder();
        
        configuration.SetDirty();
        
        list.selectedItem = levelItem;
        list.ScrollToItem(levelItem);

        return levelItem;
    }
コード例 #34
0
    public override void OnInspectorGUI() {
        if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) {
            MadTrialEditor.OnEditorGUIExpired("Mad Level Manager");
            return;
        }

        LoadTextures(); // loading textures with delay to prevent editor errors
        CheckAssetLocation();
        ActiveInfo();
        
        GUIGroupPopup();

        LoadItems();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical(GUILayout.Width(1));
        GUILayout.Space(200);
        EditorGUILayout.EndVertical();
        list.Draw();
        EditorGUILayout.EndHorizontal();
        
        EditorGUILayout.BeginHorizontal();
        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Add")) {
            AddLevel();
        }
        GUI.backgroundColor = Color.white;
        
        GUI.enabled = list.selectedItem != null;
        GUI.backgroundColor = Color.red;
        if (GUILayout.Button("Remove") || GUI.enabled && Event.current.keyCode == KeyCode.Delete) {
            RemoveLevel();
        }
        GUI.backgroundColor = Color.white;
        
        GUILayout.FlexibleSpace();

        GUILayout.Label("Move");
        
        if (GUILayout.Button("Down")) {
            MoveDown();
            configuration.SetDirty();
        }
        
        if (GUILayout.Button("Up")) {
            MoveUp();
            configuration.SetDirty();
        }

        GUILayout.Space(10);

        if (GUILayout.Button("Bottom")) {
            MoveToBottom();
            configuration.SetDirty();
        }

        if (GUILayout.Button("Top")) {
            MoveToTop();
            configuration.SetDirty();
        }
        
        GUI.enabled = true;
        
        EditorGUILayout.EndHorizontal();
        
        MadGUI.IndentBox("Level Properties", () => {
            var item = list.selectedItem;
            
            if (item == null) {
                item = new LevelItem(configuration);
                GUI.enabled = false;
            }
            
            MadUndo.RecordObject(configuration, "Edit '" + item.level.name + "'");
            EditorGUI.BeginChangeCheck();
            
            EditorGUILayout.BeginHorizontal();
            MadGUI.Validate(() => item.level.sceneObject != null, () => {
                item.level.sceneObject =
                    EditorGUILayout.ObjectField("Scene", item.level.sceneObject, typeof(UnityEngine.Object), false);
            });
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("Set Current", GUILayout.Width(85))) {
                MadUndo.RecordObject2(target, "Change Scene");
                var obj = AssetDatabase.LoadAssetAtPath(EditorApplication.currentScene, typeof(UnityEngine.Object));
                if (obj != null) {
                    item.level.sceneObject = obj;
                } else {
                    EditorUtility.DisplayDialog("Scene not saved", "Current scene is not saved. Please save it first (CTRL+S).", "OK");
                }
            }
            GUI.backgroundColor = Color.white;
            
            EditorGUILayout.EndHorizontal();
            if (!CheckAssetIsScene(item.level.sceneObject)) {
                item.level.sceneObject = null;
            }
            
            MadGUI.Validate(() => !string.IsNullOrEmpty(item.level.name), () => {
                GUI.SetNextControlName("level name"); // needs names to unfocus
                item.level.name = EditorGUILayout.TextField("Level Name", item.level.name);
            });
            
            item.level.type = (MadLevel.Type) EditorGUILayout.EnumPopup("Type", item.level.type);
            
            GUI.SetNextControlName("arguments"); // needs names to unfocus
            item.level.arguments = EditorGUILayout.TextField("Arguments", item.level.arguments);

            GUI.SetNextControlName("locked by default"); // needs names to unfocus
            item.level.lockedByDefault = EditorGUILayout.Toggle("Locked By Default", item.level.lockedByDefault);

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            extensionIndex = configuration.extensions.FindIndex((e) => e == item.level.extension) + 1;
            extensionIndex = MadGUI.DynamicPopup(extensionIndex, "Extension", configuration.extensions.Count + 1, (index) => {
                if (index == 0) {
                    return "(none)";
                } else {
                    return configuration.extensions[index - 1].name;
                }
            });
            if (EditorGUI.EndChangeCheck()) {
                if (extensionIndex == 0) {
                    item.level.extension = null;
                } else {
                    item.level.extension = configuration.extensions[extensionIndex - 1];
                    configuration.SetDirty();
                }
            }

            bool enabledState = GUI.enabled;
            GUI.enabled = true;
            if (MadGUI.Button("Open Extension Editor", Color.magenta)) {
                MadLevelExtensionEditor.Show(configuration);
            }
            GUI.enabled = enabledState;

            EditorGUILayout.Space();

            int groupIndex = GroupToIndex(item.level.group);
            groupIndex = EditorGUILayout.Popup("Move To Group:", groupIndex, GroupNames());
            item.level.group = IndexToGroup(groupIndex);
            
            if (EditorGUI.EndChangeCheck()) {
                configuration.SetDirty();
            }
            
            GUI.enabled = true;
            
        });
        
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Help")) {
            Help.BrowseURL(MadLevelHelp.LevelConfigurationHelp);
        }
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        
        if (!configuration.IsValid()) {
            MadGUI.Error("Configuration is invalid. Please make sure that:\n"
                + "- There's no levels with \"!!!\" icon. These levels may have duplicated name or missing scene.\n"
                + "- All your extensions have no missing scenes (in Extension Editor)"
            );
        }

        if (configuration.active && !MadLevelConfigurationEditor.CheckBuildSynchronized(configuration)) {
            if (MadGUI.ErrorFix(
                "Build configuration is not in synch with level configuration.",
                "Synchronize Now")) {
                    MadLevelConfigurationEditor.SynchronizeBuild(configuration);
            }
        }

        foreach (var ex in executionQueue) {
            ex();
        }

        executionQueue.Clear();
    }
コード例 #35
0
 void ItemSelected(LevelItem item) {
     Repaint();
     var focusedControl = GUI.GetNameOfFocusedControl();
     if (!string.IsNullOrEmpty(focusedControl)) {
         GUI.SetNextControlName("");
         GUI.FocusControl("");
     }
 }
コード例 #36
0
ファイル: NSMBLevel.cs プロジェクト: Fr33ze/NSMB-Editor
 public void Remove(LevelItem obj)
 {
     if (obj is NSMBObject)
         Objects.Remove(obj as NSMBObject);
     if (obj is NSMBSprite)
         Sprites.Remove(obj as NSMBSprite);
     if (obj is NSMBEntrance)
         Entrances.Remove(obj as NSMBEntrance);
     if (obj is NSMBView) {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
             Zones.Remove(v);
         else
             Views.Remove(v);
     }
     if (obj is NSMBPathPoint) {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Remove(pp);
         if (pp.parent.points.Count == 0) {
             if (pp.parent.isProgressPath)
                 ProgressPaths.Remove(pp.parent);
             else
                 Paths.Remove(pp.parent);
         }
     }
 }
コード例 #37
0
ファイル: NSMBLevel.cs プロジェクト: Fr33ze/NSMB-Editor
 public void Add(LevelItem obj)
 {
     if (obj is NSMBObject)
         Objects.Add(obj as NSMBObject);
     if (obj is NSMBSprite)
         Sprites.Add(obj as NSMBSprite);
     if (obj is NSMBEntrance)
         Entrances.Add(obj as NSMBEntrance);
     if (obj is NSMBView)  {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
             Zones.Add(v);
         else
             Views.Add(v);
     }
     if (obj is NSMBPathPoint) {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Add(pp);
         if (pp.parent.isProgressPath) {
             if (!ProgressPaths.Contains(pp.parent))
                 ProgressPaths.Add(pp.parent);
         } else {
             if (!Paths.Contains(pp.parent))
                 Paths.Add(pp.parent);
         }
     }
 }
コード例 #38
0
ファイル: NSMBLevel.cs プロジェクト: elfinlazz/NSMB-Editor
 public int RemoveZIndex(LevelItem obj)
 {
     int idx = -1;
     if (obj is NSMBObject) {
         idx = Objects.IndexOf(obj as NSMBObject);
         Objects.Remove(obj as NSMBObject);
     }
     if (obj is NSMBSprite) {
         idx = Sprites.IndexOf(obj as NSMBSprite);
         Sprites.Remove(obj as NSMBSprite);
     }
     if (obj is NSMBEntrance) {
         idx = Entrances.IndexOf(obj as NSMBEntrance);
         Entrances.Remove(obj as NSMBEntrance);
     }
     if (obj is NSMBView) {
         NSMBView v = obj as NSMBView;
         if (v.isZone) {
             idx = Zones.IndexOf(v);
             Zones.Remove(v);
         } else {
             idx = Views.IndexOf(v);
             Views.Remove(v);
         }
     }
     if (obj is NSMBPathPoint) {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         idx = pp.parent.points.IndexOf(pp);
         pp.parent.points.Remove(pp);
         if (pp.parent.points.Count == 0)
         {
             if (pp.parent.isProgressPath)
                 ProgressPaths.Remove(pp.parent);
             else
                 Paths.Remove(pp.parent);
         }
     }
     return idx == -1 ? 0 : idx;
 }
コード例 #39
0
ファイル: TabsPanel.cs プロジェクト: JaviLuki/NSMB-Editor
        public void SelectObjects(List<LevelItem> objs, LevelItem selectedTabType)
        {
            if (objs.Contains(selectedTabType))
            {
                objs.Remove(selectedTabType);
                objs.Insert(0, selectedTabType);
            }
            SelectedObjs = objs;
            ClearTabs();
            int tabIndex = -1;
            foreach (LevelItem obj in objs) {
                if (obj is NSMBObject) AddTab(objects);
                if (obj is NSMBSprite) AddTab(sprites);
                if (obj is NSMBEntrance) AddTab(entrances);
                if (obj is NSMBView) {
                    NSMBView v = obj as NSMBView;
                    if (v.isZone)
                        AddTab(zones);
                    else
                        AddTab(views);
                }
                if (obj is NSMBPathPoint) {
                    NSMBPathPoint pp = obj as NSMBPathPoint;
                    if (pp.parent.isProgressPath)
                        AddTab(progresspaths);
                    else
                        AddTab(paths);
                }

                if (selectedTabType != null && obj.GetType() == selectedTabType.GetType() && tabIndex == -1)
                    tabIndex = tabControl1.TabCount - 1;
            }
            if (tabControl1.TabCount == 0)
                SelectNone();
            if (tabIndex > -1)
                tabControl1.SelectedIndex = tabIndex;
            EdControl.Focus();
        }
コード例 #40
0
ファイル: GoodTabsPanel.cs プロジェクト: JaviLuki/NSMB-Editor
        private ItemType typeOfItem(LevelItem it)
        {
            if (it is NSMBObject) return ItemType.Object;
            if (it is NSMBSprite) return ItemType.Sprite;
            if (it is NSMBEntrance) return ItemType.Entrance;
            if (it is NSMBView && !(it as NSMBView).isZone) return ItemType.View;
            if (it is NSMBView && (it as NSMBView).isZone) return ItemType.Zone;
            if (it is NSMBPath && !(it as NSMBPath).isProgressPath) return ItemType.Path;
            if (it is NSMBPath && (it as NSMBPath).isProgressPath) return ItemType.ProgressPath;
            if (it is NSMBPathPoint && !(it as NSMBPathPoint).parent.isProgressPath) return ItemType.Path;
            if (it is NSMBPathPoint && (it as NSMBPathPoint).parent.isProgressPath) return ItemType.ProgressPath;

            throw new Exception("me dunno wat type can i has!"); //rofl
        }
コード例 #41
0
        private void RenderSelectedObject(LevelItem o, Graphics g)
        {
            if (o is NSMBView)
                {
                    Color c;
                    if ((o as NSMBView).isZone)
                        c = Color.LightGreen;
                    else
                        c = Color.White;

                    g.FillRectangle(new SolidBrush(Color.FromArgb(80, c)), o.x, o.y, o.width, o.height);
                    Rectangle viewText = GetViewTextRect(o);
                    if (viewText != Rectangle.Empty)
                    {
                        SolidBrush fill = new SolidBrush(Color.FromArgb(80, c));
                        g.FillRectangle(fill, viewText);
                        g.DrawRectangle(Pens.White, viewText);
                        fill.Dispose();
                    }
                }

                g.DrawRectangle(Pens.White, o.x, o.y, o.width, o.height);
                g.DrawRectangle(Pens.Black, o.x-1, o.y-1, o.width+2, o.height+2);
                if (o.isResizable && resizeHandles)
                {
                    drawResizeKnob(g, o.x, o.y);
                    drawResizeKnob(g, o.x, o.y + o.height);
                    drawResizeKnob(g, o.x, o.y + o.height / 2);
                    drawResizeKnob(g, o.x + o.width, o.y);
                    drawResizeKnob(g, o.x + o.width, o.y + o.height);
                    drawResizeKnob(g, o.x + o.width, o.y + o.height / 2);
                    drawResizeKnob(g, o.x + o.width / 2, o.y);
                    drawResizeKnob(g, o.x + o.width / 2, o.y + o.height);
                }
        }
コード例 #42
0
 private void OpenScene(LevelItem item) {
     if (item.level.sceneObject != null) {
         EditorApplication.delayCall += () => {
             if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) {
                 EditorApplication.OpenScene(item.level.scenePath);
             }
         };
     }
 }
コード例 #43
0
ファイル: UndoManager.cs プロジェクト: elfinlazz/NSMB-Editor
 //Helper functions? Here? :O
 public static List<LevelItem> ObjToList(LevelItem obj)
 {
     List<LevelItem> l = new List<LevelItem>();
     l.Add(obj);
     return l;
 }
コード例 #44
0
 private Rectangle GetViewTextRect(LevelItem view)
 {
     Rectangle visible = EdControl.ViewablePixels;
     visible = new Rectangle(visible.X, visible.Y, visible.Width, visible.Height);
     if (!visible.IntersectsWith(new Rectangle(view.x, view.y, view.width, view.height)))
         return Rectangle.Empty;
     NSMBView v = view as NSMBView;
     Rectangle viewText = new Rectangle(new Point(Math.Max(v.x, visible.X), Math.Max(v.y, visible.Y) + (v.isZone ? 16 : 0)), TextRenderer.MeasureText(v.GetDisplayString(), NSMBGraphics.SmallInfoFont));
     return viewText;
 }
コード例 #45
0
 private void selectIfInside(LevelItem it, Rectangle r)
 {
     if (it is NSMBView)
     {
         Rectangle viewText = GetViewTextRect(it);
         if (r.IntersectsWith(viewText) && !SelectedObjects.Contains(it))
             SelectedObjects.Add(it);
     }
     else if (r.IntersectsWith(new Rectangle(it.x, it.y, it.width, it.height)) && !SelectedObjects.Contains(it))
             SelectedObjects.Add(it);
 }
コード例 #46
0
        private void RenderSelectedObject(LevelItem o, Graphics g)
        {
            if (o is NSMBView)
            {
                Color c;
                if ((o as NSMBView).isZone)
                    c = Color.LightGreen;
                else
                    c = Color.White;

                g.FillRectangle(new SolidBrush(Color.FromArgb(80, c)), o.x, o.y, o.width, o.height);
                Rectangle viewText = GetViewTextRect(o);
                if (viewText != Rectangle.Empty)
                {
                    SolidBrush fill = new SolidBrush(Color.FromArgb(80, c));
                    g.FillRectangle(fill, viewText);
                    g.DrawRectangle(Pens.White, viewText);
                    fill.Dispose();
                }
            }

            if (o is NSMBPathPoint)
            {
                Bitmap img = Properties.Resources.pathpoint_add;
                g.DrawImage(img, o.x + 16, o.y);
                img.RotateFlip(RotateFlipType.RotateNoneFlipX);
                g.DrawImage(img, o.x - 16, o.y);
            }

            g.DrawRectangle(Pens.White, o.x, o.y, o.width, o.height);
            g.DrawRectangle(Pens.Black, o.x-1, o.y-1, o.width+2, o.height+2);
            if (o.isResizable && resizeHandles)
            {
                drawResizeKnob(g, o.x, o.y);
                drawResizeKnob(g, o.x, o.y + o.height);
                drawResizeKnob(g, o.x, o.y + o.height / 2);
                drawResizeKnob(g, o.x + o.width, o.y);
                drawResizeKnob(g, o.x + o.width, o.y + o.height);
                drawResizeKnob(g, o.x + o.width, o.y + o.height / 2);
                drawResizeKnob(g, o.x + o.width / 2, o.y);
                drawResizeKnob(g, o.x + o.width / 2, o.y + o.height);
            }
        }
コード例 #47
0
    void SetupLevelConfigData()
    {
        levelData = GameMasterScript.masterScript.GetCurrentLevelData();

        levelTitleUI.text = levelData.Title.Replace("/n", System.Environment.NewLine);
        levelDescriptionUI.text = levelData.Description.Replace("/n", System.Environment.NewLine);
        numOfThreeLetterWordsReq = levelData.ThreeLetterWordCount;
        numOfFourLetterWordsReq = levelData.FourLetterWordCount;
        numOfFiveLetterWordsReq = levelData.FiveLetterWordCount;
        numOfSixLetterWordsReq = levelData.SixLetterWordCount;
        numOfSevenLetterWordsReq = levelData.SevenLetterWordCount;
        numOfEightLetterWordsReq = levelData.EightLetterWordCount;
        numOfNineLetterWordsReq = levelData.NineLetterWordCount;
        numOfTenLetterWordsReq = levelData.TenLetterWordCount;

        CreateWordCounterUI();

    }