public override void OnInspectorGUI()
    {
        levelsAmmount = EditorGUILayout.IntField("Levels Amount", levelsAmmount);
        nodesPerLevel = EditorGUILayout.IntField("Nodes per level", nodesPerLevel);
        nodesMaxRange = EditorGUILayout.IntField("Nodes max range", nodesMaxRange);
        grid          = EditorGUILayout.ObjectField("Grid reference", grid, typeof(Grid)) as Grid;

        EditorGUILayout.Space(15);

        if (GUILayout.Button("Create levels"))
        {
            if (!grid)
            {
                Debug.LogError("Grid reference necessary");
                return;
            }

            var levelFile = (LevelScriptableFile)target;
            var package   = new LevelPackage();

            for (int i = 0; i < levelsAmmount; i++)
            {
                var level = LevelGenerator.CreateNewLevel(nodesPerLevel, nodesMaxRange, grid.gridSize);
                package.Add(level);
            }

            levelFile.levels.Add(package);
        }

        EditorGUILayout.Space(30);

        base.OnInspectorGUI();
    }
Example #2
0
 public void LoadSceneLevels(int levelId)
 {
     _levelId          = levelId;
     currentPackage    = levelPackages[levelId];
     namePackageLevels = levelPackages[levelId].nameLevels;
     grid.LoadGrid(currentPackage, numLevelsProgress[levelId]);
 }
Example #3
0
        // Instancia un botón para acceder a los niveles de un determinado paquete de niveles
        GroupButtonConfiguration AddGroupButton(LevelPackage group, int index)
        {
            GroupButtonConfiguration button = Instantiate(groupButtonPrefab, groupContainer.transform);

            button.Configure(group.buttonImage, group.buttonPressedImage, group.groupName, GameManager.instance.GetGroupProgress(index), this, index);

            return(button);
        }
Example #4
0
        // Pasa al menú de selección de nivel de un determinado grupo de niveles
        public void ShowLevelsFromGroup(int index)
        {
            groupSelectUI.SetActive(false); // Desactiva la interfaz de selección de grupo
            LevelPackage group = levelPackages[index];
            int          size  = group.levels.Length;

            levelButtons = new LevelButtonConfiguration[size];

            for (int i = 0; i < size; i++)
            {
                levelButtons[i] = AddLevelButton(i + 1, group.color, index);
            }

            levelsTitleText.text = group.groupName;
            levelSelectUI.SetActive(true);
        }
Example #5
0
        public void LoadGrid(LevelPackage currentPackage, int level)
        {
            for (int i = 0; i < buttons.Count; i++)
            {
                Destroy(buttons[i].gameObject);
            }
            buttons.Clear();

            for (int i = 0; i < currentPackage.levels.Length; i++)
            {
                Button b = Instantiate(levelButton);
                buttons.Add(b);
                b.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
                b.GetComponent <RectTransform>().anchorMax        = Vector2.zero;
                b.GetComponent <RectTransform>().anchorMin        = Vector2.zero;
                b.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1);
                b.transform.parent = gameObject.transform;
                b.GetComponent <Image>().sprite = currentPackage.levelNoPulsado;
                b.GetComponentInChildren <LevelButtonHandle>().levelId = i;
                b.image.color = Color.white;

                b.transform.GetChild(1).GetComponent <Image>().enabled = i > level;

                if (i > level)
                {
                    b.GetComponentInChildren <Text>().text  = "";
                    b.GetComponentInChildren <Text>().color = Color.black;
                }
                else
                {
                    b.GetComponentInChildren <Text>().text      = (i + 1).ToString();
                    b.GetComponentInChildren <Text>().alignment = TextAnchor.MiddleCenter;
                    b.GetComponentInChildren <Text>().color     = Color.black;
                    b.image.color = Color.white;

                    if (i < level)
                    {
                        b.image.color = new Color(currentPackage.color.r, currentPackage.color.g, currentPackage.color.b);
                        b.GetComponentInChildren <Text>().color = Color.white;
                    }
                }
            }
        }
Example #6
0
            public override void Update()
            {
                shared.timer.Update();

                // Keep Kodu animating even if a dialog is active.
                shared.boku.UpdateFace();
                shared.boku.UpdateAnimations();

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                if (parent.newWorldDialog.Active)
                {
                    parent.newWorldDialog.Update();
                    return;
                }

                // If not modal, always show status.
                AuthUI.ShowStatusDialog();

                // Update the dialogs.
                parent.prevSessionCrashedMessage.Update();
                parent.noCommunityMessage.Update();
                parent.noSharingMessage.Update();

                // Don't do anything else until the user reads and dismisses the dialogs.
                if (parent.prevSessionCrashedMessage.Active ||
                    parent.exitingKodu)
                {
                    return;
                }

                // Update the options menu.  Do this first so that if it is active it can steal input.
                shared.optionsMenu.Update();

                // Main menu should always be active.
                shared.menu.Active = true;

                // If OptionsMenu is active, don't look at input.  This is a problem for touch input
                // which doesn't support any kind of "ClearAllWasPressedState" functionality.
                if (!shared.optionsMenu.Active)
                {
                    // Check for click on signOut tile or url.
                    if (MouseInput.Left.WasPressed || Actions.Select.WasPressed || TouchInput.WasTouched)
                    {
                        TouchContact touch = TouchInput.GetOldestTouch();
                        if (touch != null)
                        {
                            touch.position = ScreenWarp.ScreenToRT(touch.position);
                        }
                        Vector2 mouseHit = MouseInput.GetMouseInRtCoords();

                        // url is in rt coords.
                        if (shared.urlBox.Contains(mouseHit) ||
                            (null != touch && shared.urlBox.Contains(touch.position)))
                        {
#if NETFX_CORE
                            Launcher.LaunchUriAsync(new Uri(KoduGameLabUrl));
#else
                            Process.Start(KoduGameLabUrl);
#endif
                            MouseInput.Left.ClearAllWasPressedState();
                        }
                    }

                    // Enable resume option if we have something to resume to.
                    if (InGame.UnDoStack.HaveResume() && (shared.menu.Item(0) != Strings.Localize("mainMenu.resume")))
                    {
                        shared.menu.InsertText(Strings.Localize("mainMenu.resume"), 0);
                    }

                    shared.liveFeed.UpdateFeed();
                    shared.liveFeed.Update(shared.camera);

                    if (!UpdateNonMenuItems())
                    {
                        // JW - Only update the menu and process input if the interactive non-menu
                        // items didn't already handle the input.
                        int curIndex = shared.menu.CurIndex;
                        shared.menu.Update(shared.camera, ref shared.worldMatrix);
                        int newIndex = shared.menu.CurIndex;

                        // If the user made a menu change, have boku glance over.
                        if (curIndex != newIndex)
                        {
                            shared.boku.DirectGaze(new Vector3(0.2f, -0.4f, 0.08f - 0.05f * newIndex), 0.5f);
                        }
                    }
                }

                if (Actions.MiniHub.WasPressed && InGame.XmlWorldData != null)
                {
                    parent.Deactivate();
                    InGame.inGame.SwitchToMiniHub();
                    return;
                }

#if IMPORT_DEBUG
                if (!string.IsNullOrEmpty(StartupWorldFilename))
                {
                    LevelPackage.DebugPrint("MainMenu");
                    LevelPackage.DebugPrint("    StartupWorldFilename : " + StartupWorldFilename);
                }
#endif
                // Jump into the startup world, if it was specified.
                if (!String.IsNullOrEmpty(StartupWorldFilename))
                {
                    if (Storage4.FileExists(StartupWorldFilename, StorageSource.All))
                    {
#if IMPORT_DEBUG
                        LevelPackage.DebugPrint("    level exists, trying to load and run");
#endif
                        if (BokuGame.bokuGame.inGame.LoadLevelAndRun(StartupWorldFilename, keepPersistentScores: false, newWorld: false, andRun: true))
                        {
#if IMPORT_DEBUG
                            LevelPackage.DebugPrint("    success on load and run");
#endif
                            parent.Deactivate();
                        }
#if IMPORT_DEBUG
                        else
                        {
                            LevelPackage.DebugPrint("    fail to load and run");
                        }
#endif
                        shared.waitingForStorage = false;
                    }
#if IMPORT_DEBUG
                    else
                    {
                        LevelPackage.DebugPrint("    level not found");
                    }
#endif

                    StartupWorldFilename = null;
                }

                // Set news feed state to opposite of options menu.  This allows the
                // News Feed to "hide" when the Options Menu is active.
                if (shared.optionsMenu.Active)
                {
                    shared.liveFeed.Deactivate();
                }
                else
                {
                    shared.liveFeed.Activate();
                    shared.liveFeed.UpdateFeed();
                }
            }   // end of Update()
Example #7
0
        /// <summary>
        /// Return whether a file exists in either title or user space.
        /// Looks in user space first.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool FileExists(string filePath, StorageSource sources)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(filePath))
                {
                    // Test user space first.
                    if ((sources & StorageSource.UserSpace) != 0)
                    {
                        string fullPath = Path.Combine(UserLocation, filePath);
                        result = File.Exists(fullPath);
                    }

                    // If not found, try title space.
                    if (result == false && (sources & StorageSource.TitleSpace) != 0)
                    {
                        string fullPath = Path.Combine(TitleLocation, filePath);
                        result = File.Exists(fullPath);
                    }
                }
            }
            catch (Exception e)
            {
                string str = e.Message;
                if (e.InnerException != null)
                {
                    str += e.InnerException.Message;
                }
                Debug.Assert(false, str);

#if IMPORT_DEBUG
                LevelPackage.DebugPrint("FileExists threw an error");
                LevelPackage.DebugPrint(e.ToString());
#endif
            }

#if IMPORT_DEBUG
            if (result == false)
            {
                LevelPackage.DebugPrint("FileExists cant't find : " + filePath);
                LevelPackage.DebugPrint("    UserLocation : " + UserLocation);
                LevelPackage.DebugPrint("    TitleLocation : " + TitleLocation);

                string   dirPath = Path.GetDirectoryName(filePath);
                string[] files   = GetFiles(dirPath, sources);
                LevelPackage.DebugPrint("==Files in : " + dirPath);
                if (files == null || files.Length == 0)
                {
                    LevelPackage.DebugPrint("    none");
                }
                else
                {
                    foreach (string file in files)
                    {
                        LevelPackage.DebugPrint("    " + file);
                    }
                }
            }
#endif

            return(result);
        }   // end of FileExists()