protected virtual void Awake() { //Check if a Text class has been linked if (LabelOfTimer == null) { LabelOfTimer = gameObject.GetComponent <Text>(); //Try to find a Text class if (LabelOfTimer == null) { Debug.LogWarning("L_Text | Start | Text changer has no label to change and can't find one on its gameobject: " + gameObject.name); return; } else { Debug.LogWarning("L_Text | Start | Text changer has no label to change but it has found a Text class on its gameobject: " + gameObject.name); } } _ColourStart = LabelOfTimer.color; //load time setting from settings file; if there is no time setting in the file, the inspector value is used instead. string[] setting = GlobalGameSettings.GetSetting("Playtime").Split(' '); if (setting.Length > 0 && setting[0] != string.Empty) { TimeLimit = int.Parse(setting[0]); } int minutes = (int)(TimeLimit / 60); int seconds = (int)(TimeLimit % 60); LabelOfTimer.text = minutes.ToString("D2") + ":" + seconds.ToString("D2"); }
private void Start() { playerCount = int.Parse(GlobalGameSettings.GetSetting("Players")); for (int i = 0; i < playerCount; i++) { TeamCharacter player = Instantiate(teamPrefab, teamContainer); player.Init(i, charContainer.GetChild(i).GetComponent <Animator>(), flagContainer.GetChild(i).GetComponent <Flag>()); player.doneEvent.AddListener(TeamFinished); teams.Add(player); } for (int i = playerCount; i < 4; i++) { Destroy(charContainer.GetChild(i).gameObject); } for (int i = 0; i < charContainer.childCount; i++) { charContainer.GetChild(i).GetComponent <CharacterColor>() .SetColor(PlayerColourContainer.GetPlayerColour(i + 1)); } timer.TimerRanOut.AddListener(TimeUp); }
private void GetChosenPreset() { string theme = GlobalGameSettings.GetSetting("Theme"); GamePreset chosenPreset = themeStrings.First(x => x.name.Equals(theme)).preset; if (chosenPreset != null) { gamePreset = chosenPreset; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); GlobalGameSettings ggs = (GlobalGameSettings)target; if (GUILayout.Button("Create Settings File")) { ggs.CreateSettingFile(); } }
private void Awake() { if (_inst != null && _inst != this) { Destroy(this.gameObject); } else { _inst = this; } GameObject.DontDestroyOnLoad(this.gameObject); }
public void Init(int player, Animator character, Flag flag) { _Character = character; _CharacterStart = _Character.transform.position; _CharacterEnd = new Vector3(-_CharacterStart.x, _CharacterStart.y, _CharacterStart.z); stepCount = Convert.ToInt16(GlobalGameSettings.GetSetting("Steps")); Flag = flag; _Team = player; _Color = PlayerColourContainer.GetPlayerColour(_Team + 1); button.Init(this, _Color); }
private void Start() { //load time setting from settings file, if there is not Time setting in the file the inspector value is used. string[] temp = GlobalGameSettings.GetSetting("Playtime").Split(' '); if (temp.Length > 1) { TimeLimit = int.Parse(temp[0]); } int minutes = (int)(TimeLimit / 60); int seconds = (int)(TimeLimit % 60); LabelOfTimer.text = minutes.ToString("D2") + ":" + seconds.ToString("D2"); }
public void method() { string Difficulty = GlobalGameSettings.GetSetting("Difficulty"); switch (Difficulty) { case "Beginner": _Difficulty = 0; break; case "Intermediate": _Difficulty = 10; break; case "Advanced": _Difficulty = 20; break; case "Expert": _Difficulty = 30; break; } foreach (GameObject AllLevels in GameObject.FindGameObjectsWithTag("level")) { AllLevels.GetComponent <Menu>().levelName = AllLevels.GetComponent <Menu>().level + _Difficulty; int LevelAmount = AllLevels.GetComponent <Menu>().levelName = AllLevels.GetComponent <Menu>().level + levelName + 1; AllLevels.GetComponentInChildren <Text>().text = "Level " + LevelAmount; AllLevels.GetComponent <Image>().sprite = unUsingSprite; if (AllLevels.GetComponent <Menu>()._Difficulty == Controller.LevelName) { AllLevels.GetComponent <Image>().sprite = AllLevels.GetComponent <Menu>().UsingSprite; } StartCoroutine(AllLevels.GetComponent <Menu>().Working()); } foreach (GameObject AllLevels in GameObject.FindGameObjectsWithTag("niveau")) { AllLevels.GetComponent <Image>().sprite = unUsingSprite; StartCoroutine(AllLevels.GetComponent <Menu>().Working()); } }
private void Start() { //load time setting from settings file, if there is not Time setting in the file the inspector value is used. int savedTime = 0; if (GlobalGameSettings.GetSetting("Use Time").Equals("No")) { Gage.color = new Color(0, 0, 0, 0); LabelOfTimer.faceColor = new Color(0, 0, 0, 0); savedTime = 10000000; } else { savedTime += int.Parse(GlobalGameSettings.GetSetting("Playtime")); } TimeLimit = savedTime; int minutes = (int)(TimeLimit / 60); int seconds = (int)(TimeLimit % 60); LabelOfTimer.text = minutes.ToString("D2") + ":" + seconds.ToString("D2"); }
void Start() { _Score = Scores[0]; _stars.AmountStars(); i++; //load highscore from file if (GlobalGameSettings.GetSetting("Reset Highscore").Equals("No")) { LoadHighscore(); } else if (GlobalGameSettings.GetSetting("Reset Highscore").Equals(string.Empty)) { if (GlobalGameSettings.GetSetting("Reset HS").Equals("No")) { LoadHighscore(); } } //check if we have all requirements linked if (ScoreBarBase == null) { Debug.LogError("ScoreScreenController | Start | Missing base object for score bars."); } if (P_Scoring == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to perant panel."); } if (ReplayButton == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to replay button."); } if (Scores == null) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); } else { int numberOf0Scores = 0; int highestScore = 0; foreach (int score in Scores) { if (score == 0) { numberOf0Scores++; } if (score > highestScore) { highestScore = score; } } if (Scores.Count == 0) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); return; } else if (Scores.Count - numberOf0Scores == 1) { //SetupSinglePlayer(Scores.IndexOf(highestScore), _TimeGame); } else if (Scores.Count - numberOf0Scores > 1) { //SetupMultiPlayer(highestScore); } if (Highscore == 0) { _Highscore = highestScore; SaveHighscore(); } else if (highestScore < Highscore && _TimeGame == true) { _Highscore = highestScore; SaveHighscore(); } else if (highestScore > Highscore && _TimeGame == false) { _Highscore = highestScore; SaveHighscore(); } } Invoke("EnableReplay", BarRiseAnimationTime + 1f); if (Manager._LevelName == 39) { LeftButton.color = new Vector4(0.5f, 0.5f, 0.5f, 1); LeftButton.GetComponentInChildren <Image>().color = new Vector4(0.5f, 0.5f, 0.5f, 1); LeftButton.GetComponent <BoxCollider2D>().enabled = false; LeftButton.GetComponent <Button>().enabled = false; } if (Manager._LevelName == 0) { RightButton.color = new Vector4(0.5f, 0.5f, 0.5f, 1); RightButton.GetComponentInChildren <Image>().color = new Vector4(0.5f, 0.5f, 0.5f, 1); RightButton.GetComponent <BoxCollider2D>().enabled = false; RightButton.GetComponent <Button>().enabled = false; } }
private void Awake() { _Instance = this; }
void Start() { //turns on input processing BlobInputProcessing.SetState(true); //load highscore from file if (GlobalGameSettings.GetSetting("Reset Highscore").Equals("No")) { LoadHighscore(); } else if (GlobalGameSettings.GetSetting("Reset Highscore").Equals(string.Empty)) { if (GlobalGameSettings.GetSetting("Reset HS").Equals("No")) { LoadHighscore(); } } //check if we have all requirements linked if (ScoreBarBase == null) { Debug.LogError("ScoreScreenController | Start | Missing base object for score bars."); } if (P_Scoring == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to perant panel."); } if (ReplayButton == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to replay button."); } if (Scores == null) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); } else { int numberOf0Scores = 0; int highestScore = 0; foreach (int score in Scores) { if (score == 0 && _Are0ScoresIgnored) { numberOf0Scores++; } if (score > highestScore) { highestScore = score; } } //safety check, if we add a level it wount be in the highscore script if (_Highscore.Highscores.Count - 1 < _LevelIndex) { int count = _LevelIndex + 1 - _Highscore.Highscores.Count; for (int index = 0; index < count; index++) { _Highscore.Highscores.Add(0); } } if (Scores.Count == 0) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); return; } else if (Scores.Count - numberOf0Scores == 1) { SetupSinglePlayer(Scores.IndexOf(highestScore)); } else if (Scores.Count - numberOf0Scores > 1) { SetupMultiPlayer(highestScore); } if (highestScore > _Highscore.Highscores[_LevelIndex]) { _Highscore.Highscores[_LevelIndex] = highestScore; SaveHighscore(); } } Invoke("EnableReplay", BarRiseAnimationTime + 1f); }
public void SwitchScene() { string map = GlobalGameSettings.GetSetting("Map"); SceneManager.LoadScene(mapScenes.First(x => x.map.Equals(map)).scene); }
// Start is called before the first frame update void Start() { Diff.text = GlobalGameSettings.GetSetting("Difficulty"); Play.text = GlobalGameSettings.GetSetting("Players"); }
IEnumerator BoatMoving(float TotalDistance) { foreach (GameObject AllBoats in GameObject.FindGameObjectsWithTag("boat")) { AllBoats.GetComponent <BoatBehavoir>().CanUse = false; } Vector2 pointtopoint = boat.transform.position; controller.Score++; _text.GetComponentInChildren <SpriteRenderer>().enabled = true; _text.text = ": " + controller.Score; while (Vector2.Distance(gameObject.transform.position, pointtopoint) >= TotalDistance && boat != null) { float speed = 30; if (Mathf.Abs(Vector2.Distance(gameObject.transform.position, pointtopoint) - TotalDistance) < 0.15f) { speed = 230; } if (frontOrBack == true) { boat.transform.position += boat.transform.TransformDirection(Vector2.up / speed); } else { boat.transform.position -= boat.transform.TransformDirection(Vector2.up / speed); } pointtopoint = boat.transform.position; yield return(new WaitForSeconds(0.0166666666666667f)); } if (boat != null) { boat.GetComponent <BoatBehavoir>().CanUse = true; } foreach (GameObject Allboeats in GameObject.FindGameObjectsWithTag("boat")) { Allboeats.GetComponent <BoatBehavoir>().CanUse = true; } if (finishPoint == true) { Particles.Emit(100); _Button.transform.position = new Vector3(0, 0, 0); string HighScore = GlobalGameSettings.GetSetting("Reset_High_Score"); if (PlayerPrefs.GetInt(controller.LevelName.ToString()) == 0) { PlayerPrefs.SetInt(controller.LevelName.ToString(), controller.Score); } if (controller.Score < PlayerPrefs.GetInt(controller.LevelName.ToString())) { PlayerPrefs.SetInt(controller.LevelName.ToString(), controller.Score); } if (HighScore == "Ja") { PlayerPrefs.DeleteKey(controller.LevelName.ToString()); _Button.GetComponentInChildren <TextMesh>().text = "Beste score: " + controller.Score.ToString(); } else { _Button.GetComponentInChildren <TextMesh>().text = "Beste score: " + PlayerPrefs.GetInt(controller.LevelName.ToString()).ToString(); } _text.text = ""; _text.GetComponentInChildren <SpriteRenderer>().enabled = false; controller.GetComponent <AudioSource>().Play(); foreach (GameObject Allboeats in GameObject.FindGameObjectsWithTag("boat")) { Allboeats.GetComponent <BoatBehavoir>().CanUse = false; } for (int i = 0; i < 300; i++) { if (boat != null) { boat.transform.position += boat.transform.TransformDirection(Vector2.up / 30); } else { break; } yield return(new WaitForSeconds(0.0166666666666667f)); } Invoke("ToScores", 2.5f); } }
void Start() { //load highscore from file if (GlobalGameSettings.GetSetting("Reset Highscore").Equals("No")) { LoadHighscore(); } else if (GlobalGameSettings.GetSetting("Reset Highscore").Equals(string.Empty)) { if (GlobalGameSettings.GetSetting("Reset HS").Equals("No")) { LoadHighscore(); } } //check if we have all requirements linked if (ScoreBarBase == null) { Debug.LogError("ScoreScreenController | Start | Missing base object for score bars."); } if (P_Scoring == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to perant panel."); } if (ReplayButton == null) { Debug.LogError("ScoreScreenController | Start | Missing Link to replay button."); } if (Scores == null) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); } else { int numberOf0Scores = 0; int highestScore = 0; foreach (int score in Scores) { if (score == 0) { numberOf0Scores++; } if (score > highestScore) { highestScore = score; } } if (Scores.Count == 0) { Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!"); return; } else if (Scores.Count - numberOf0Scores == 1) { SetupSinglePlayer(Scores.IndexOf(highestScore)); } else if (Scores.Count - numberOf0Scores > 1) { SetupMultiPlayer(highestScore); } if (highestScore > Highscore) { _Highscore = highestScore; SaveHighscore(); } } Invoke("EnableReplay", BarRiseAnimationTime + 1f); }
private void Start() { string Difficulty = GlobalGameSettings.GetSetting("Difficulty"); switch (Difficulty) { case "Beginner": _Difficulty = 0; break; case "Easy": _Difficulty = 8; break; case "Medium": _Difficulty = 16; break; case "Hard": _Difficulty = 24; break; case "Expert": _Difficulty = 32; break; } int Level; int.TryParse(GlobalGameSettings.GetSetting("Level"), out Level); foreach (GameObject AllLevels in GameObject.FindGameObjectsWithTag("level")) { AllLevels.GetComponent <Menu>().levelName = AllLevels.GetComponent <Menu>().level + _Difficulty;//+1; int LevelAmount = AllLevels.GetComponent <Menu>().levelName = AllLevels.GetComponent <Menu>().level + _Difficulty; AllLevels.GetComponentInChildren <Text>().text = "Level " + LevelAmount; //AllLevels.GetComponent<Image>().sprite = unUsingSprite; //if (AllLevels.GetComponent<Menu>()._Difficulty == Controller.LevelName) //{ // AllLevels.GetComponent<Image>().sprite = AllLevels.GetComponent<Menu>().UsingSprite; //} StartCoroutine(AllLevels.GetComponent <Menu>().Working()); } foreach (GameObject AllLevels in GameObject.FindGameObjectsWithTag("niveau")) { //AllLevels.GetComponent<Image>().sprite = unUsingSprite; StartCoroutine(AllLevels.GetComponent <Menu>().Working()); } foreach (GameObject AllGrids in GameObject.FindGameObjectsWithTag("point")) { AllGrids.GetComponent <Pointbehavoir>().Image.enabled = false; AllGrids.GetComponent <Pointbehavoir>().CanInteract = false; } if (off_LEvelName == 0) { StartLevel((Level - 1) + _Difficulty); LevelName = ((Level) + _Difficulty); LevelNameText.text = Difficulty + ":" + Level; minimaleZetten = Levels[LevelName - 1].minimaleZetten; } else { int _lev = Level; StartLevel(_LevelName); LevelName = (_LevelName); int _switch = 0; _lev = (LevelName + 1); Debug.Log(_lev); while (_lev > 0) { _lev = _lev - 8; _switch++; } switch (_switch) { case 1: Difficulty = "Beginner"; break; case 2: Difficulty = "Easy"; break; case 3: Difficulty = "Medium"; break; case 4: Difficulty = "Hard"; break; case 5: Difficulty = "Expert"; break; } Debug.Log(_lev); _lev = _lev + 8; LevelNameText.text = Difficulty + ":" + _lev; minimaleZetten = Levels[LevelName].minimaleZetten; } }