private void Start() { _mazeGenerator = gameObject.AddComponent <MazeGenerator>(); _mazeSpawner = GetComponent <MazeSpawner>(); _navMeshSurface = GetComponent <NavMeshSurface>(); _playerType = PlayerSelectionManager.PlayerType; switch (_playerType) { case PlayerType.Spectator: _mazeSpawner.IsVisibleFog = false; break; case PlayerType.Mage: _mazeSpawner.IsVisibleLine = true; _mazeSpawner.IsVisibleGoal = true; break; } _mazeSpawner.RandomSeed = _mazeGenerator.GetRandomSeed(); _mazeSpawner.enabled = true; _navMeshSurface.enabled = true; InitializationPlayers(); if (PhotonNetwork.IsMasterClient) { InitializationMonsters(); } gameObject.AddComponent <NavMeshRebaker>(); BasicPlayerControl.WinningPanel = winningPanel; }
void FixedUpdate() { if (MazeSpawner.getNumberOfCoins() == 0) { GameObject.Find("/AlbinoDragon/Canvas/Coins").GetComponent <Text>().text = "You have collected all the coins: THE GAME IS OVER!"; } GameObject.Find("/AlbinoDragon/Canvas/Coins").GetComponent <Text>().text = MazeSpawner.getNumberOfCoins() + " coins left"; if (mRigidBody != null) { mRigidBody.AddTorque(ViewCamera.transform.TransformDirection(Vector3.back * Input.GetAxis("Horizontal") * 10)); // mRigidBody.transform.position = mRigidBody.transform.position + ViewCamera.transform.forward * 1f * Time.deltaTime; mRigidBody.AddTorque(ViewCamera.transform.TransformDirection(Vector3.right * Input.GetAxis("Vertical") * 10)); if (Input.GetButtonDown("Jump")) { if (mAudioSource != null && JumpSound != null) { mAudioSource.PlayOneShot(JumpSound); } if (mFloorTouched) { mRigidBody.AddForce(Vector3.up * 200); } } } Debug.Log(ViewCameraContainer); }
public void SubscribeEvent(object eventPublisher, PublisherSubscribedEventArgs publisherSubscribedEventArgs) { //SubScribe to the targeted eventPublisher with the same type if (publisherSubscribedEventArgs.Publisher.GetType() == typeof(MazeSpawner)) { MazeSpawner mazeSpawner = (MazeSpawner)publisherSubscribedEventArgs.Publisher; mazeSpawner.MazeGenerationStarted += OnMazeGenerationStarted; } }
public void UnSubScribeEvent() { StaticReferences.EventSubject.PublisherSubscribed -= SubscribeEvent; foreach (IEventPublisher eventPublisher in StaticReferences.EventSubject.EventPublishers) { if (eventPublisher.GetType() == typeof(MazeSpawner)) { MazeSpawner mazeSpawner = (MazeSpawner)eventPublisher; mazeSpawner.MazeGenerationStarted -= OnMazeGenerationStarted; } } }
void Update() { Slider.value = health; winCountText.text = "Побед: " + winData.winCount; mazeSpawner = wallSpawner.GetComponent <MazeSpawner>(); isCollectedAllCubes = CubesCount == mazeSpawner.maxCubeCount; var audioSources = GetComponents <AudioSource>(); if (isCollectedAllCubes && mazeSpawner.maxCubeCount != 0) { winText.text = "Вы победили.\nСчетчик побед увеличился.\nПоиграем еще?."; } else { winText.text = "Вы умерли.\nПроисходит реанимация."; } if (mazeSpawner.maxCubeCount == 0) { if (!audioSources[1].isPlaying) { audioSources[1].Play(); audioSources[2].Stop(); } } else { if (!audioSources[2].isPlaying) { audioSources[2].Play(); audioSources[1].Stop(); } } if (health <= 0) { Restart(); } if (mazeSpawner.maxCubeCount == 0) { cubesCountText.text = "Выберите уровень"; } else { cubesCountText.text = CubesCount + "/" + mazeSpawner.maxCubeCount; } }
//Added by mohanad private void Awake() { // Singleton //if we don't currently have a sound effect instance... if (instance == null) { //...set this one to be it... instance = this; } //...otherwise... else if (instance != this) { //...destroy this one because it is a duplicate Destroy(gameObject); } }
void CreateMaze(int rows, int columns) { if (currentMaze != null) { Destroy(currentMaze); } mazeNodes = new MazeNode[rows, columns]; currentMaze = Instantiate(MazePrefab); spawner = currentMaze.GetComponent <MazeSpawner>(); spawner.OnMazeCellCreated += HandleGridCreation; spawner.Rows = rows; spawner.Columns = columns; spawner.RandomSeed = UnityEngine.Random.Range(0, 999999); spawner.SpawnMaze(); OnNewMazeSize?.Invoke(rows, columns); OnNewMazeSpawner?.Invoke(spawner); }
public override void OnInspectorGUI() { _mapGenerator = (MazeSpawner)target; if (DrawDefaultInspector()) { } if (GUILayout.Button("Generate")) { GenerateMapInEditor(); } if (GUILayout.Button("Destroy")) { ClearMapInEditor(); } if (GUILayout.Button("Bake")) { BakeMapInEditor(); } if (GUILayout.Button("Save")) { SaveMapInEditor(); } }
private void Awake() { Debug.Log("LOAD"); LoadSave(); mazeLvl = 0; //playerLvl = 3; //playerLvlXp = 80; mazeSpawner = FindObjectOfType <MazeSpawner>(); player = FindObjectOfType <PlayerControls>(); inventar = FindObjectOfType <Inventar>(); try { mazeLvl = User.USER_INFO.mazeLvl; player.lvl = User.USER_INFO.lvl; player.lvlXp = User.USER_INFO.lvlxp; player.isFrize = User.USER_INFO.frize; player.isLifeStill = User.USER_INFO.lifeStill; player.LvlUp(0); player.hels = player.maxHels; inventar.shiltCount = User.USER_INFO.shiltCount; inventar.boombCount = User.USER_INFO.bombCount; inventar.slizeCount = User.USER_INFO.slimeCount; } catch (Exception e) { Debug.Log("Ошибка рпри загрузке 1"); } ColculatwMaze(); statTrak = 0; timer = 0; }
void AssignSpawner(MazeSpawner sp) { spawner = sp; }
private void Awake() { Instance = this; }
private void VisitCell(int row, int column, Direction moveMade) { Direction[] movesAvailable = new Direction[4]; int movesAvailableCount = 0; do { movesAvailableCount = 0; //check move right if (column + 1 < ColumnCount && !GetMazeCell(row, column + 1).IsVisited) { movesAvailable[movesAvailableCount] = Direction.Right; movesAvailableCount++; } else if (!GetMazeCell(row, column).IsVisited&& moveMade != Direction.Left) { GetMazeCell(row, column).WallRight = true; } //check move forward if (row + 1 < RowCount && !GetMazeCell(row + 1, column).IsVisited) { movesAvailable[movesAvailableCount] = Direction.Front; movesAvailableCount++; } else if (!GetMazeCell(row, column).IsVisited&& moveMade != Direction.Back) { GetMazeCell(row, column).WallFront = true; } //check move left if (column > 0 && column - 1 >= 0 && !GetMazeCell(row, column - 1).IsVisited) { movesAvailable[movesAvailableCount] = Direction.Left; movesAvailableCount++; } else if (!GetMazeCell(row, column).IsVisited&& moveMade != Direction.Right) { GetMazeCell(row, column).WallLeft = true; } //check move backward if (row > 0 && row - 1 >= 0 && !GetMazeCell(row - 1, column).IsVisited) { movesAvailable[movesAvailableCount] = Direction.Back; movesAvailableCount++; } else if (!GetMazeCell(row, column).IsVisited&& moveMade != Direction.Front) { GetMazeCell(row, column).WallBack = true; } if (movesAvailableCount == 0 && !GetMazeCell(row, column).IsVisited) { if (MazeSpawner.getNumberOfCoins() < 15) { GetMazeCell(row, column).IsGoal = true; } } GetMazeCell(row, column).IsVisited = true; // ensure that there are possible directions for the ball if (movesAvailableCount > 0) { switch (movesAvailable[Random.Range(0, movesAvailableCount)]) { case Direction.Start: break; case Direction.Right: VisitCell(row, column + 1, Direction.Right); break; case Direction.Front: VisitCell(row + 1, column, Direction.Front); break; case Direction.Left: VisitCell(row, column - 1, Direction.Left); break; case Direction.Back: VisitCell(row - 1, column, Direction.Back); break; } } }while(movesAvailableCount > 0); }