private void Awake() { if (instance == null) { instance = this; } }
//Инициализация игрового процесса public void InitGame(LocationController loc) { Location = loc; GamePanel.SetActive(true); LevelDesign.SetActive(true); Path.Data = Location.Data; Path.Line = Path.GetComponent <LineRenderer>(); CurrentWaveNumber.Value = 0; FillTowers(); CreateTowersGroup(); //Создание пула врагов CreateEnemyPool(); // CreateBulletPool(); WaveController.WaveFinished += CreateWave; //Создание волны CreateWave(); //Старт волны //StartWave(wavePool, path); }
// Use this for initialization void Start() { target = GameObject.Find("Player"); camera = GameObject.Find("Main Camera"); levelDesign = camera.GetComponent <LevelDesign>(); sfxManager = GameObject.Find("MusicBox").GetComponent <SFXManager>(); rb = GetComponent <Rigidbody2D>(); isAlive = true; }
/// <summary> /// singleton /// </summary> public void SetSingleton() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else if (instance != this) { Destroy(gameObject); } }
void Start() { levels = GetComponent <LevelDesign>(); gameplay = GetComponent <Gameplay>(); lineCompletedSound.volume = Settings.soundsVolume; if (!isRestored) { playGrid = new GameObject[22][]; for (int i = 0; i < playGrid.Length; i++) { playGrid[i] = new GameObject[10]; } } }
void Start() { PlayerController.PlayerDeath += StopGame; if (GamePanel) { GamePanel.SetActive(false); } if (LevelDesign) { LevelDesign.SetActive(false); } MainMenuController.GameStarted += InitGame; }
// Use this for initialization private void Start() { playfieldState = GetComponent <PlayfieldState>(); levelDesign = GetComponent <LevelDesign>(); musicSound = GetComponent <AudioSource>(); musicSound.volume = Settings.musicVolume; gameOverSound.volume = Settings.soundsVolume; countDownSound.volume = Settings.soundsVolume; MusicPlayer.DestroyInstance(); if (!isRestored) { RandomGenerator(); for (int i = 0; i < 3; i++) { GameObject tetrimino = generatedQueue.Dequeue(); nextPieces.Add(Instantiate(tetrimino, nextPoints[i].position, Quaternion.identity)); } } StartCoroutine(StartCountDown()); }
public GameState(Game1 game, GraphicsDevice graphics, ContentManager content) : base(game, content) { _sprites = new List <Sprite>() { new Hero(Game1.textureHero) { Input = new Input() { Left = Keys.Left, Right = Keys.Right, Up = Keys.Up, Down = Keys.Down }, Position = new Vector2(200, 545), Speed = 5, }, new Enemy(Game1.textureEnemy) { Position = new Vector2(300, 385) } }; level = new LevelDesign(content); LoadContent(); }
public override void OnInspectorGUI() { design = (LevelDesign)target; profile = design.profile; if (profile.levelId == 0 || profile.levelId != target.GetInstanceID()) { if (profile.levelId != target.GetInstanceID()) { profile = profile.GetClone(); } profile.levelId = target.GetInstanceID(); } design.name = (design.transform.GetSiblingIndex() + 1).ToString(); parametersFade.target = GUILayout.Toggle(parametersFade.target, "Level Parameters", EditorStyles.foldout); if (EditorGUILayout.BeginFadeGroup(parametersFade.faded)) { profile.width = Mathf.RoundToInt(EditorGUILayout.Slider("Width", 1f * profile.width, 5f, 12f)); profile.height = Mathf.RoundToInt(EditorGUILayout.Slider("Height", 1f * profile.height, 5f, 12f)); profile.chipCount = Mathf.RoundToInt(EditorGUILayout.Slider("Count of Possible Colors", 1f * profile.chipCount, 3f, 6f)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Score Stars", GUILayout.ExpandWidth(true)); profile.firstStarScore = Mathf.Max(EditorGUILayout.IntField(profile.firstStarScore, GUILayout.ExpandWidth(true)), 1); profile.secondStarScore = Mathf.Max(EditorGUILayout.IntField(profile.secondStarScore, GUILayout.ExpandWidth(true)), profile.firstStarScore + 1); profile.thirdStarScore = Mathf.Max(EditorGUILayout.IntField(profile.thirdStarScore, GUILayout.ExpandWidth(true)), profile.secondStarScore + 1); EditorGUILayout.EndHorizontal(); profile.limitation = (Limitation)EditorGUILayout.EnumPopup("Limitation", profile.limitation); switch (profile.limitation) { case Limitation.Time: profile.duraction = Mathf.Max(0, EditorGUILayout.IntField("Session duration", profile.duraction)); break; } profile.target = (FieldTarget)EditorGUILayout.EnumPopup("Target", profile.target); EditorGUILayout.EndFadeGroup(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); defaultColor = GUI.color; GUI.color = currentMode == EditMode.Slot ? unpressedColor : defaultColor; if (GUILayout.Button("Slot", EditorStyles.toolbarButton, GUILayout.Width(40))) { currentMode = EditMode.Slot; } GUI.color = currentMode == EditMode.Chip ? unpressedColor : defaultColor; if (GUILayout.Button("Chip", EditorStyles.toolbarButton, GUILayout.Width(40))) { currentMode = EditMode.Chip; } GUI.color = currentMode == EditMode.PowerUp ? unpressedColor : defaultColor; if (GUILayout.Button("PowerUp", EditorStyles.toolbarButton, GUILayout.Width(70))) { currentMode = EditMode.PowerUp; } GUI.color = defaultColor; GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset", EditorStyles.toolbarButton, GUILayout.Width(40))) { profile = new LevelProfile(); } EditorGUILayout.EndVertical(); // Slot modes if (currentMode == EditMode.Slot) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); defaultColor = GUI.color; GUI.color = toolID == "Slots" ? unpressedColor : defaultColor; if (GUILayout.Button("Slots", EditorStyles.toolbarButton, GUILayout.Width(40))) { toolID = "Slots"; } GUI.color = toolID == "Generators" ? unpressedColor : defaultColor; if (GUILayout.Button("Generators", EditorStyles.toolbarButton, GUILayout.Width(70))) { toolID = "Generators"; } GUI.color = toolID == "Teleports" ? unpressedColor : defaultColor; if (GUILayout.Button("Teleports", EditorStyles.toolbarButton, GUILayout.Width(70))) { toolID = "Teleports"; } GUI.color = defaultColor; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } // Chip modes if (currentMode == EditMode.Chip) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); string key; defaultColor = GUI.color; GUI.color = toolID == "Random" ? unpressedColor : defaultColor; if (GUILayout.Button("Random", EditorStyles.toolbarButton, GUILayout.Width(50))) { toolID = "Random"; } for (int i = 0; i < profile.chipCount; i++) { key = "Color " + alphabet[i]; GUI.color = toolID == key ? unpressedColor * chipColor[i] : defaultColor * chipColor[i]; if (GUILayout.Button(key, EditorStyles.toolbarButton, GUILayout.Width(50))) { toolID = key; } } GUI.color = toolID == "Stone" ? unpressedColor : defaultColor; if (GUILayout.Button("Stone", EditorStyles.toolbarButton, GUILayout.Width(40))) { toolID = "Stone"; } GUI.color = defaultColor; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); rect = GUILayoutUtility.GetRect(profile.width * (cellSize + slotOffect), profile.height * (cellSize + slotOffect)); rect.x += slotOffect; rect.y += slotOffect; EditorGUILayout.BeginHorizontal(); DrawModeTools(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); switch (currentMode) { case EditMode.Slot: DrawSlot(); break; // case EditMode.Chip: DrawChip(); break; // case EditMode.PowerUp: DrawPowerUp(); break; } design.profile = profile; EditorUtility.SetDirty(design); }
private void LoadLevel(int levelIndex) { _currentLevelDesignIndex = levelIndex; ClearExistingLevel(); LevelDesign currentLevel = _levelDesigns[_currentLevelDesignIndex]; //set camera position and size Camera.main.transform.position = currentLevel.CameraPos; Camera.main.orthographicSize = currentLevel.CameraSize; _currentLevelTimeLimit = currentLevel.LevelTimeLimit; UpdateTimeLimitText(); ApplyMoveLimitVisualEffects(Color.white, Color.black); //set current level tiles _currentLevelTiles = new Tile[currentLevel.LevelWidth, currentLevel.LevelHeight]; for (int x = 0, coordX = 0; x < currentLevel.LevelWidth; ++x, ++coordX) { for (int y = 0, coordY = currentLevel.LevelHeight - 1; y < currentLevel.LevelHeight; ++y, --coordY) { GameObject go; Vector3 coordsVec = new Vector3(coordX, coordY, 0); switch (currentLevel.LevelLayout[x, y]) { case 0: //no tile, but we might need something later on break; case 1: //empty tile go = Instantiate(emptyTilePrefabs[Random.Range(0, emptyTilePrefabs.Length)], coordsVec, Quaternion.identity) as GameObject; go.transform.Rotate(new Vector3(0, 0, Random.Range(0, 4) * 90)); _currentLevelTiles[coordX, coordY] = go.GetComponent <Tile>(); _currentLevelTiles[coordX, coordY].SetTilePosition(new Vector2Int(coordX, coordY)); _currentLevelGameObjects.Add(go); break; case 2: //start tile go = Instantiate(startTilePrefab, coordsVec, Quaternion.identity) as GameObject; go.transform.Rotate(new Vector3(0, 0, Random.Range(0, 4) * 90)); StartTile startTile = go.GetComponent <StartTile>(); _startTiles.Add(startTile); _currentLevelTiles[coordX, coordY] = startTile; _currentLevelTiles[coordX, coordY].SetTilePosition(new Vector2Int(coordX, coordY)); _currentLevelGameObjects.Add(go); break; case 3: //goal tile AddLevelTileToLists(goalTilePrefab, coordX, coordY, coordsVec, true); break; case 4: //straight pipe AddLevelTileToLists(straightPipeTilePrefab, coordX, coordY, coordsVec, false); break; case 5: //str2-pipe AddLevelTileToLists(straightPipe2TilePrefab, coordX, coordY, coordsVec, false); break; case 6: //l-pipe AddLevelTileToLists(lPipeTilePrefab, coordX, coordY, coordsVec, false); break; case 7: //l-pipe90 AddLevelTileToLists(lPipe90TilePrefab, coordX, coordY, coordsVec, false); break; case 8: //r-pipe AddLevelTileToLists(rPipeTilePrefab, coordX, coordY, coordsVec, false); break; case 9: //r-pipe90 AddLevelTileToLists(rPipe90TilePrefab, coordX, coordY, coordsVec, false); break; case 10: //bomb AddLevelTileToLists(bombTilePrefab, coordX, coordY, coordsVec, false); break; case 11: //timebonus AddLevelTileToLists(timeBonusTilePrefab, coordX, coordY, coordsVec, false); break; default: throw new System.NotImplementedException(); } } } }