public void InitializeGameState() { backGroundImage = new Entity( new StationaryShape(new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f)), new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"))); titel = new Text("Select Level", new Vec2F(0f, 0.4f), new Vec2F(1f, 0.4f)); titel.SetColor(new Vec3F(1f, 1f, 0f)); titel.SetFontSize(65); maxMenuButtons = LevelContainer.GetInstance().Levels.Length; menuButtons = new Text[maxMenuButtons + 1]; activeMenuButton = 2; for (int i = 0; i < maxMenuButtons; i++) { var levelName = LevelContainer.GetInstance().Levels[i].Name; var text = new Text(levelName, new Vec2F(0.3f, i * 0.1f + 0.2f), new Vec2F(0.8f, 0.4f)); text.SetColor(new Vec3F(1.0f, 1.0f, 1.0f)); text.SetFontSize(20); menuButtons[maxMenuButtons - 1 - i] = text; } menuButtons[maxMenuButtons] = new Text("Return", new Vec2F(0.3f, -0.2f), new Vec2F(0.8f, 0.4f)); menuButtons[maxMenuButtons].SetColor(new Vec3F(0.0f, 1.0f, 0.0f)); }
public void RenderState() { backGroundImage.RenderEntity(); LevelContainer.GetInstance().ActiveLevel.RenderLevel(); bottomPanel.Render(); }
private static void CreateLevelContainer() { LevelContainer levelContainer = AssetDatabase.LoadAssetAtPath("Assets/_Project/Datas/Level/LevelContainer.asset", typeof(LevelContainer)) as LevelContainer; if (levelContainer == null) { levelContainer = ScriptableObject.CreateInstance <LevelContainer>(); AssetDatabase.CreateAsset(levelContainer, "Assets/_Project/Datas/Level/LevelContainer.asset"); AssetDatabase.SaveAssets(); Debug.Log("LevelContainer is created"); } else { Debug.LogWarning("LevelContainer is already Exist"); } LevelManager levelManager = FindObjectOfType <LevelManager>(); SerializedObject serializedLevelManager = new SerializedObject(levelManager); serializedLevelManager.FindProperty("levelContainer").objectReferenceValue = levelContainer; serializedLevelManager.ApplyModifiedProperties(); Selection.activeObject = levelContainer; EditorUtility.FocusProjectWindow(); Selection.activeGameObject = levelManager.gameObject; }
void CreateLevelData() { TextAsset levelText = Resources.Load("Levels") as TextAsset; levels = JsonUtility.FromJson <LevelContainer>(levelText.text); Debug.Log("LevelDataCreated"); }
private void ShowLevelDetails(string lvlName) { SelectedLevel = LevelContainer.GetInstance().Levels[lvlName]; var lvlDetails = GUIController.GetInstance().Screens[Screen.ScreenType.LevelDetails]; Screen.GoTo(lvlDetails); }
public void AnimateXpGain(ReadyCallback readyCallback) { xpReadyCallback = readyCallback; updateSpeed = Configs.main.UI.XpBarUpdateSpeed; xpGained = Resource.Value; levelsAtStart = Resource.Level; currentLevel = levelsAtStart; levelsGained = 0; XPContainer.SetActive(false); if (xpGained > 0) { BarContainer.SetActive(true); IconContainer.SetActive(true); LevelContainer.SetActive(true); } xpsPerLevel = new List <int>(); currentLevelXpBound = Resource.XpPerLevel; while (xpGained >= Resource.XpPerLevel) { levelsGained++; xpGained -= Resource.XpPerLevel; xpsPerLevel.Add(Resource.XpPerLevel); Resource.Level++; } SetCurrentTarget(); StartCoroutine("GainXP"); }
public void Init(LoadingCurtain _loadingCurtain, PlayerMain _player, GameplayHUD _HUD, LevelContainer _levelContainer) { loadingCurtain = _loadingCurtain; player = _player; HUD = _HUD; levelContainer = _levelContainer; }
// Use this for initialization void Start () { lvlCon = FindObjectOfType(typeof(LevelContainer)) as LevelContainer; category = PlayerPrefs.GetInt("LvlCategory"); lvl = PlayerPrefs.GetInt("Level"); switch (category) { case 0: arrCurrentCategory = lvlCon.Tutorial; break; case 1: arrCurrentCategory = lvlCon.Easy; break; case 2: arrCurrentCategory = lvlCon.Medium; break; case 3: arrCurrentCategory = lvlCon.Hard; break; } numberOfLevels = arrCurrentCategory.Length; LoadCurrentLevel(); }
protected ProgressData() { Levels = new Dictionary <string, bool>(); Tasks = new Dictionary <string, bool>(); foreach (var p in LevelContainer.GetInstance().Levels) { Levels.Add(p.Key, false); if (p.Value.Tasks == null) { continue; } foreach (var t in p.Value.Tasks) { Tasks.Add(t.Name, false); } } Skins = new Dictionary <string, bool>(); foreach (var skin in SkinsContainer.GetInstance().Skins) { Skins.Add(skin.Skin.name, false); } //todo Data = new Dictionary <DataType, Dictionary <string, bool> > { { DataType.Level, Levels }, { DataType.Task, Tasks }, { DataType.Skin, Skins }, }; //special Levels["main"] = true; }
public static LevelContainer LoadFromText(string text) { XmlSerializer serializer = new XmlSerializer(typeof(LevelContainer)); LevelContainer lc = serializer.Deserialize(new StringReader(text)) as LevelContainer; return(lc); }
public void Init(GameFactory _gameFactory, LevelContainer _levelContainer) { gameFactory = _gameFactory; levelContainer = _levelContainer; Subscribe(); //Spawn(); //SpawnEnemies(); }
public void Init(GameFactory _gameFactory, GameObject spawn, MWayPoint wayPoint, LevelContainer _levelContainer) { gameFactory = _gameFactory; levelContainer = _levelContainer; SpawnPlayer(spawn); gameFactory.PlayerContainer.Init(wayPoint, Camera.main, levelContainer); gameFactory.PlayerContainer.PlayerShoot.IsInputInverted = SaveLoadService.Instance.GameSettings.IsInputInverted; gameFactory.PlayerContainer.PlayerShoot.Sensitivity = SaveLoadService.Instance.GameSettings.Sensitivity; }
private void Construct(LevelContainer levelContainer, PlayerController playerController, LockerController lockerController) { m_levelContainer = levelContainer; m_player = playerController; m_lockerController = lockerController; Instance = this; }
private void LoadLevel() { if (_bEndlessMode) { return; } TextAsset levelTxt = (TextAsset)Resources.Load("LevelXML/" + GameData.Instance.Level); _level = LevelContainer.LoadFromText(levelTxt.text); }
public LevelContainer GetLevel() { if (levels.Count > 0) { LevelContainer returnLvl = levels[Random.Range(0, levels.Count)]; levels.Remove(returnLvl); return(returnLvl); } return(null); }
public void Init(LevelContainer _levelContainer, Camera camera) { levelContainer = _levelContainer; mainCamera = camera; foreach (Level level in levelContainer.Levels) { level.Finished += DestroyProjectiles; } }
private void Awake() { if (currentLevelContainer == null) { currentLevelContainer = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
private void AddLevel(int x, int y, int lvlMoves, Vector2 division, int[,] lvlMap) { if (levels == null) { levels = new List <LevelContainer>(); } LevelContainer newLevel = new LevelContainer(); newLevel.Setup(x, y, lvlMap, lvlMoves, division); levels.Add(newLevel); }
public void LoadBtn() { if (LevelId == 0) { return; } TextAsset levelTxt = (TextAsset)Resources.Load("LevelXML/" + LevelId); Level = LevelContainer.LoadFromText(levelTxt.text); ClearLevelObjects(); SetLevelObjects(); _loadedLevelNum = LevelId; }
private void btnOK_Click(object sender, EventArgs e) { int iLevel = 0; try { bool bFoundCheckedLevel = false; PivotTable.ManualUpdate = true; //first make levels visible so that at least one level will be visible for (int i = 0; i < chkLevels.Items.Count; i++) { iLevel = i + 1; LevelContainer lc = (LevelContainer)chkLevels.Items[i]; bool bHidden = !chkLevels.GetItemChecked(i); if (!bHidden) { bFoundCheckedLevel = true; lc.PivotField.Hidden = bHidden; } if (!bFoundCheckedLevel && !lc.PivotField.Hidden && i + 1 < chkLevels.Items.Count) //don't drilldown the last level { lc.PivotField.DrilledDown = true; //drill down any hidden levels above the first visible level } } //second make levels hidden for (int i = 0; i < chkLevels.Items.Count; i++) { iLevel = i + 1; LevelContainer lc = (LevelContainer)chkLevels.Items[i]; bool bHidden = !chkLevels.GetItemChecked(i); if (bHidden) { lc.PivotField.Hidden = bHidden; } } PivotTable.ManualUpdate = false; } catch (Exception ex) { MessageBox.Show("Error on level " + iLevel + " when clicking OK:\r\n" + ex.Message + "\r\n" + ex.StackTrace, "OLAP PivotTable Extensions"); PivotTable.ManualUpdate = false; } }
public static void Load() { if (!File.Exists(dataPath)) { TextAsset textAsset = (TextAsset)Resources.Load("Level"); File.WriteAllBytes(dataPath, textAsset.bytes); } var serializer = new XmlSerializer(typeof(LevelContainer)); using (var stream = new FileStream(dataPath, FileMode.Open)) { _levelContainer = serializer.Deserialize(stream) as LevelContainer; } }
private void Start() { Level = new LevelContainer(); _caveParent = GameObject.Find("Caves").transform; _mothParent = GameObject.Find("Moths").transform; _stalParent = GameObject.Find("Stalactites").transform; _spiderParent = GameObject.Find("Spiders").transform; _triggerParent = GameObject.Find("Triggers").transform; _shroomParent = GameObject.Find("Mushrooms").transform; _npcParent = GameObject.Find("Npcs").transform; _webParent = GameObject.Find("Webs").transform; _levelObj = GameObject.Find("Level"); SetZLayers(); SetLevelNum(); LoadBtn(); }
public void HandleKeyEvent(string keyValue, string keyAction) { if (keyAction == "KEY_PRESS") { switch (keyValue) { case "KEY_UP": if (activeMenuButton > 0) { menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f)); activeMenuButton--; menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f)); } break; case "KEY_DOWN": if (activeMenuButton < maxMenuButtons) { menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f)); activeMenuButton++; menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f)); } break; case "KEY_ENTER": switch (activeMenuButton) { case 2: SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "MAIN_MENU", "")); break; default: LevelContainer.GetInstance().GetLevel(maxMenuButtons - activeMenuButton - 1); SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); break; } break; } } }
public void HandleTimedEvent(string msg, string par1, string par2) { switch (msg) { case "SPAWN_CUSTOMER": LevelContainer.GetInstance().ActiveLevel.SpawnCustomer(); break; case "DESPAWN_CUSTOMER": LevelContainer.GetInstance().ActiveLevel.DespawnCustomer(); break; case "DELETE_OLD_CUSTOMER": LevelContainer.GetInstance().ActiveLevel.DeleteOldCustomer(); break; } }
void SetScrollRectPosition() { Level l = GameManager.CurrentLevel; if (l != null) { float i = funct(l.id, LevelContainers.Count); ScrollRect.verticalNormalizedPosition = i; } else { LevelContainer levCont = LevelContainers.Where(lev => lev.unlocked == true).LastOrDefault(); float j = funct(levCont.Level.id, LevelContainers.Count); ScrollRect.verticalNormalizedPosition = j; } }
void Start() { GridLayoutGroup grid = GetComponent <GridLayoutGroup>(); /* int i = 1; * * for (; i <= CampaignState.chapterStats[chapterName].levelsFinished; i++) * { * GameObject newButton = Instantiate(buttonPrefab); * newButton.GetComponentInChildren<Text>().text = i.ToString(); * newButton.GetComponent<LoadScene>().sceneName = chapterName + i.ToString(); * newButton.transform.SetParent(grid.transform, false); * } * * for (; i <= CampaignState.chapterStats[chapterName].countLevels; i++) * { * GameObject newButton = Instantiate(buttonPrefab); * newButton.GetComponent<Image>().sprite = lockSprite; * newButton.GetComponent<Button>().enabled = false; * newButton.transform.SetParent(grid.transform, false); * }*/ //var levelCollection = LevelContainer.Load(Path.Combine(Application.dataPath, "Resources", "test.xml")); var levelCollection = new LevelContainer(); if (Application.platform == RuntimePlatform.WindowsEditor) { levelCollection = LevelContainer.Load(Path.Combine(Application.dataPath, "StreamingAssets", "levels.xml")); } else if (Application.platform == RuntimePlatform.Android) { levelCollection = LevelContainer.Load("jar:file://" + Application.dataPath + "!/assets/levels.xml"); } for (int i = 0; i < levelCollection.Levels.Count; i++) { GameObject newButton = Instantiate(buttonPrefab); newButton.GetComponentInChildren <Text>().text = levelCollection.Levels[i].id.ToString(); newButton.GetComponent <LoadLevel>().level = levelCollection.Levels[i]; newButton.GetComponent <LoadScene>().sceneName = "CampaignLevel"; newButton.transform.SetParent(grid.transform, false); } GameMode.levelCollection = levelCollection; }
void GenerateLevelContainers() { Levels = GameObject.FindObjectOfType <GameManager>().Levels; List <Progress> progressList = Database.GetAllProgresses(); foreach (Level L in Levels) { GameObject levelContainerGO = Instantiate(LevelContainerPrefab.gameObject); levelContainerGO.transform.SetParent(this.transform); levelContainerGO.transform.localScale = new Vector3(0.6f, 0.5f, 1); LevelContainer LevelContainer = levelContainerGO.GetComponent <LevelContainer>(); LevelContainer.Level = L; LevelContainer.LevelProgress = progressList.Where(x => x.id == L.id).SingleOrDefault(); LevelContainers.Add(LevelContainer); } }
public void Init(PlayerMain _player, LevelContainer _levelContainer, SceneLoader _sceneLoader) { player = _player; levelContainer = _levelContainer; sceneLoader = _sceneLoader; player.HealthChanged += UpdateHealthBar; player.Died += OpenGameOverPopUp; UpdateHealthBar(); SetLevelNumber(SaveLoadService.Instance.PlayerProgress.LevelID); SubscribeOnLevelChange(); NextLevelPopUp.Init(LoadingCurtain, player, this, levelContainer); GameOverPopUp.Init(sceneLoader, LoadingCurtain); WinPopUp.Init(sceneLoader, LoadingCurtain); SettingsPopUp.Init(player.Shooter); PausePopUp.Init(sceneLoader, LoadingCurtain, SettingsPopUp); }
public void LoadLevel(string levelFilePath) { for (int i = numLayers - 1; i >= 0; --i) { if (layers[i] != null) { Destroy(layers[i].gameObject); } } TextAsset container = Resources.Load <TextAsset>(levelFilePath); XmlSerializer serializer = new XmlSerializer(typeof(LevelContainer)); Stream stream = new MemoryStream(container.bytes); _xmlContainer = serializer.Deserialize(stream) as LevelContainer; init(_xmlContainer.rows, _xmlContainer.cols, _xmlContainer.numLayers); for (int i = 0; i < numLayers; ++i) { layers[i].LoadMap(_xmlContainer.layers[i]); layers[i].ColorTiles(layers[i].color, 1.0f); } }
private void Start() { if (_instance != null) { throw new Exception("Second singleton"); } _instance = this; _lvlContainer = LevelContainer.GetInstance(); _casualStyle.CommonAssets = _commonAssets; _avaCtrl = AvatarController.GetInstance(); _buildCtrl = BuildController.GetInstance(); _buildCtrl.SetStyle(_casualStyle); _taskCtrl = TaskController.GetInstance(); _taskCtrl.Initialize(); GameplayController.InitializeInstance(); _gameplayCtrl = GameplayController.GetInstance(); LocalizationController.Instance.ChangeLocale(LocalizationController.Locale.EN); var a = AppSettings.GetInstance(); }
/**Haalt alle levels in een file op, mits de file bestaat en voegt er een nieuwe entry aan toe*/ public void WriteData(string reason) { LevelContainer levelCollection; List<Level> levels; /**Als file bestaat haal alle bestaaned data op en voeg een entry toe, anders maak een bestand */ if (File.Exists(Path.Combine(Application.persistentDataPath, "gamedata.xml"))) { Debug.Log("File Found"); levelCollection = LevelContainer.Load(Path.Combine(Application.persistentDataPath, "gamedata.xml")); levels = levelCollection.Levels; bool hasLevel = false; foreach (Level l in levels) { if (l.lastLevel == Application.loadedLevel - 1) hasLevel = true; } if (!hasLevel) levels.Add(new Level(Application.loadedLevel - 1)); foreach (Level l in levels) { if(l.lastLevel == Application.loadedLevel - 1) { l.AddPoging(msEind, vKStart, dKStart, Mass, Score, reason, l.pogingen.Count + 1); } } Debug.Log(Path.Combine(Application.persistentDataPath, "gamedata.xml")); levelCollection.Save(Path.Combine(Application.persistentDataPath, "gamedata.xml")); } else { levels = new List<Level>(); levelCollection = new LevelContainer(levels); levels.Add(new Level(Application.loadedLevel - 1)); foreach (Level l in levels) { if (l.lastLevel == Application.loadedLevel - 1) { l.AddPoging(msEind, vKStart, dKStart, Mass, Score, reason, 1); } } Debug.Log(Path.Combine(Application.persistentDataPath, "gamedata.xml")); levelCollection.Save(Path.Combine(Application.persistentDataPath, "gamedata.xml")); } }