// Returns the default level information array
	public static LevelInfoHolder[] GetDefaultLevelCompleteArray()
    {
        LevelInfoHolder[] retArray = new LevelInfoHolder[NUMBER_OF_LEVELS];
     
        for (int i = 0;  i < NUMBER_OF_LEVELS; i++)
        {
            retArray[i] = new LevelInfoHolder(false, 0);
		}

        return retArray;
	}
Пример #2
0
            public void ThisLvlAsMeteor()
            {
                roadSetup = new RoadSetup();
                enemyShips.Clear();
                LevelInfoHolder level = new LevelInfoHolder();

                level.type = LevelType.Meteor;
                level.data = new List <string> {
                    new Meteor.MeteorDispenser(0).ToString()
                };
                levels.Add(level);
                roadSetup  = new RoadSetup();
                enemyShips = new List <List <string> >();
            }
Пример #3
0
            public void FinishLevel()
            {
                LevelInfoHolder level = new LevelInfoHolder();

                level.type = LevelType.Classic;
                var lines = ConvertEnemies(enemyShips);

                lines.Add("---");
                lines.AddRange(ConvertRoads());
                level.data = lines;
                levels.Add(level);
                roadSetup  = new RoadSetup();
                enemyShips = new List <List <string> >();
            }
Пример #4
0
        public ILevelBuilder SetContent(LevelInfoHolder info)
        {
            Tier t    = info.tier;
            var  boss = GetRandomBoss(t);

            boss.SetDefaultMoveStrategy();
            level.AppendEnemy(boss);
            level.Finished += b => { if (b)
                                     {
                                         RewardPlayer(t);
                                     }
            };
            return(this);
        }
Пример #5
0
            public static LevelInfoHolder ReadLevel(string fileName, LevelType type)
            {
                var    lines    = File.ReadLines(fileName);
                var    iter     = lines.GetEnumerator();
                string toFind   = type.ToString();
                int    idToFind = 0;

                switch (type)
                {
                case LevelType.Classic:
                    idToFind = VALUES.random.Next(1, VALUES.MAX_CLASSIC_LVL_ID);
                    break;

                case LevelType.Event:
                    idToFind = VALUES.random.Next(1, VALUES.MAX_EVENT_LVL_ID);
                    break;
                }

                LevelInfoHolder lvl = new LevelInfoHolder
                {
                    id   = idToFind,
                    data = new List <string>()
                };
                var begin = lines
                            .SkipWhile(line => !(line.Contains("===") &&
                                                 line.Contains(idToFind.ToString()) &&
                                                 line.Contains(type.ToString())))
                            .ToList();

                lvl.type = ParseLevelType(begin.First().Split(' ').Last());
                lvl.data = begin
                           .Skip(1)
                           .TakeWhile(line => !line.Contains("==="))
                           .ToList();
                return(lvl);
            }
	public void CreateLevelSelectButtons(LevelInfoHolder[] levelInfoHolderArray){
		int buttonCount = 0;

		foreach (LevelInfoHolder lHolder in levelInfoHolderArray){
			buttonCount++;

			float xPos = startingPos.x;
			float yPos = startingPos.y - heightSpacing * (Mathf.Floor(buttonCount/2));

			if (buttonCount % 2 == 0){
				xPos = startingPos.x + widthSpacing;
				yPos = startingPos.y - Mathf.Abs(heightSpacing * (1 - (buttonCount/2)));
			}

			GameObject button = Instantiate(buttonPrefab) as GameObject;

			button.transform.SetParent(GameObject.FindGameObjectWithTag("LevelMenuContentImage").transform);

			RectTransform rectTrans = button.GetComponent<RectTransform>();

			rectTrans.anchorMin =  new Vector2(xPos - buttonWidth/2, yPos - buttonHeight/2 );
			rectTrans.anchorMax =  new Vector2(xPos + buttonWidth/2, yPos + buttonHeight/2 );

			rectTrans.offsetMax = new Vector2(0,0);
			rectTrans.offsetMin = new Vector2(0,0);
			button.transform.localScale = new Vector3(1,1,1);

			GameObject levelNumberObject;
			GameObject levelHighScoreObject;

			// Figures out which child is which text object and 
			if (button.transform.GetChild(0).tag.Equals("LevelNumberObject")){
				levelNumberObject = button.transform.GetChild(0).gameObject;
				levelHighScoreObject = button.transform.GetChild(1).gameObject;
			}
			else {
				levelNumberObject = button.transform.GetChild(1).gameObject;
				levelHighScoreObject = button.transform.GetChild(0).gameObject;
			}
		
			levelNumberObject.GetComponent<Text>().text = buttonCount.ToString();

			if (levelInfoHolderArray[buttonCount - 1].Completed == true){
				levelHighScoreObject.gameObject.GetComponent<Text>().text = lHolder.HighestPointAmount.ToString();
			}
			else {
				levelHighScoreObject.gameObject.GetComponent<Text>().text = "";
			}
				

			button.GetComponent<ButtonStatusScript>().levelNumber = buttonCount;

			button.GetComponent<Button>().onClick.AddListener(delegate { 
				LevelMenuSceneLoaderScript levelLoader = 
                GameObject.FindGameObjectWithTag("LevelSelectSceneLoader").GetComponent<LevelMenuSceneLoaderScript>();

				ButtonStatusScript levelNumberScript = button.GetComponent<ButtonStatusScript>();

				levelLoader.LoadLevel(levelNumberScript.levelNumber);
			});
		}

	}
	public static void SetLevelCompleteArrayWithoutSaving(LevelInfoHolder[] levelArray){
		levelCompletedArray = levelArray;
		UpdateButtonStatus();
	}