// Start is called before the first frame update void Start() { playerScore = 0; tweener = GetComponent <Tweener>(); LevelGeneratorObj = GameObject.FindWithTag("levelGen").GetComponent <LevelGenerator>(); TeleporterObj = GameObject.FindWithTag("levelGen").GetComponent <Teleporter>(); levelMapObjects = LevelGeneratorObj.getLevelMapObjects(); surroundLMObjects = LevelGeneratorObj.checkSurround((int)gridPos.x, (int)gridPos.y); movingAudio = GetComponent <AudioSource>(); playerAnimator = GetComponent <Animator>(); dustParticles = GetComponent <ParticleSystem>(); ghostHandler = GameObject.FindWithTag("ghosthandler").GetComponent <GhostHandler>(); Score = HUD.transform.GetChild(2).gameObject.GetComponent <Text>(); Lives = HUD.transform.GetChild(5).gameObject.GetComponent <Text>(); gameTimer = HUD.transform.GetChild(0).gameObject.GetComponent <Text>(); Instantiate(deathExplosionObj, new Vector3(0, 0, 0), Quaternion.identity); deathExplosion = deathExplosionObj.GetComponent <ParticleSystem>(); deathExplosion.Stop(); playerState = PacmanStates.ALIVE; playerLives = 3; deadTimer = 0.0f; deathSound = Instantiate(deathSoundObj, new Vector3(0, 0, 0), Quaternion.identity); startTimer = 0.0f; countdown = HUD.transform.GetChild(6).GetComponent <Image>(); playerTimer = 0.0f; pelletLeft = 0; bool done = false; while (!done) { for (int i = 0; i < levelMapObjects.Count; i++) { for (int j = 0; j < levelMapObjects[i].Count; j++) { if (levelMapObjects[i][j].tag == "innerwall" || levelMapObjects[i][j].tag == "outerwall") { wallAudioSource = levelMapObjects[i][j].GetComponent <AudioSource>(); done = true; } if (levelMapObjects[i][j].tag == "pellet" || levelMapObjects[i][j].tag == "powerpellet") { pelletLeft++; } } } } }
// Start is called before the first frame update private void Start() { _dropInterval = baseDropInterval; _gameBoard = FindObjectOfType <Board>(); _spawner = FindObjectOfType <Spawner>(); _soundManager = FindObjectOfType <SoundManager>(); _scoreManager = FindObjectOfType <ScoreManager>(); _ghostShape = FindObjectOfType <GhostHandler>(); _shapeHolder = FindObjectOfType <ShapeHolder>(); if (_spawner) { if (_currentlyActiveShape == null) { _currentlyActiveShape = _spawner.SpawnShape(); } } else { Debug.LogWarning("There is no spawner!"); } if (!_gameBoard) { Debug.LogWarning("There is no game board!"); } if (!_soundManager) { Debug.LogWarning("There is no sound manager!"); } if (!_scoreManager) { Debug.LogWarning("There is no score manager!"); } if (gameOverPanel) { gameOverPanel.SetActive(false); } if (pausePanel) { pausePanel.SetActive(false); } }
public void Update(Board board) { Board = board; Weights = new float[board.Size, board.Size]; AfkTimes = new int[board.Size, board.Size]; IsIncreasedBlast = IncreasedRadiusHandler.IsIncreased(board, this); CanRemoteDamaged = RemoveControlHandler.CanDamaged(board, this); AfkPlayersHandler.UpdateAfkTimes(board, this); BombermanState.Update(board); FreeDirections = FreeDirectionsHandler.GetFreeDirections(board, Utils.DirectionsWithStop); SafeFromGhostsDirections = GhostHandler.GetSafeDirections(board, Utils.DirectionsWithStop); SafeFromAngryGhostsDirections = AngryGhostHandler.GetSafeDirections(board, this, Utils.DirectionsWithStop); TimesToBoom = TimesToBoomHandler.GetTimesToBoom(board, this); CanDamageBuff = CanDamageBuffHandler.GetCanDamageBuffMass(board, this); TimesToGhostMove = GhostPositionsHandler.GetTimeToGhostMove(board, this); // TODO: fix this method // GhostsWeights = GhostsWeightsHandler.GetGhostsWeights(board, this); Weights = DestroyableStaticObjectsWeightsHandler.Handle(board, this, Weights); BuffsWeightsHandler.UpdateWeights(board, this); IEnumerable <Direction> directions = Utils.DirectionsWithStop; if (UseFreeDirections) { var intersected = directions.Intersect(FreeDirections).ToArray(); if (intersected.Any()) { directions = intersected; } } if (UseSafeFromGhostsDirections) { var intersected = directions.Intersect(SafeFromGhostsDirections).ToArray(); if (intersected.Any()) { directions = intersected; } } if (UseSafeFromAngryGhostsDirections) { var intersected = directions.Intersect(SafeFromAngryGhostsDirections).ToArray(); if (intersected.Any()) { directions = intersected; } } DirectionWeights = new DeepDirectionsWeightsHandler().GetWeights(board, this, directions, board.GetBomberman()); if (DirectionWeights.Max(kvp => kvp.Value) <= 0) // костыль для обработки некорректного поведения, когда бомберман стоит впритык к мит чопперу { DirectionWeights = new DeepDirectionsWeightsHandler().GetWeights(board, this, FreeDirections.ToArray(), board.GetBomberman()); } }