//Server only: private void UpdateProgressBars() { for (int i = playerProgress.Count - 1; i >= 0; i--) { playerProgress[i].progress += Time.deltaTime; if (playerProgress[i].timeToNotifyPlayer) { //Update the players progress bar ProgressBarMessage.Send(playerProgress[i].player, playerProgress[i].spriteIndex, playerProgress[i].position); if (playerProgress[i].spriteIndex == 12) { //Almost done, check to see if there is an additionalSFX to play: playerProgress[i].PlayAdditionalSound(); } } //Cancel the progress bar if the player moves away or faces another direction: if (playerProgress[i].HasMovedAway()) { playerProgress[i].completedAction.Finish(FinishProgressAction.FinishReason.INTERRUPTED); CloseProgressBar(playerProgress[i]); continue; } //Finished! Invoke the action and close the progress bar for the player if (playerProgress[i].progress >= playerProgress[i].timeToFinish) { playerProgress[i].completedAction.Finish(FinishProgressAction.FinishReason.COMPLETED); CloseProgressBar(playerProgress[i]); } } }
private void CloseProgressBar(PlayerProgressEntry playerProg) { //Notify player to turn off progress bar: ProgressBarMessage.Send(playerProg.player, -1, playerProg.position); //remove from the player progress list: playerProgress.Remove(playerProg); }
public void StartProgress(Vector3 pos, float timeForCompletion, FinishProgressAction finishProgressAction, GameObject _player, string _additionalSfx = "", float _additionalSfxPitch = 1f) { var _playerSprites = _player.GetComponent <PlayerSprites>(); playerProgress.Add(new PlayerProgressEntry { player = _player, timeToFinish = timeForCompletion, completedAction = finishProgressAction, position = pos, playerSprites = _playerSprites, playerPositionCache = _player.transform.position, facingDirectionCache = _playerSprites.CurrentDirection, additionalSfx = _additionalSfx, additionalSfxPitch = _additionalSfxPitch }); //Start the progress for the player: ProgressBarMessage.Send(_player, 0, pos); }
public void StartProgress(Vector3 pos, float timeForCompletion, FinishProgressAction finishProgressAction, GameObject _player, string _additionalSfx = "", float _additionalSfxPitch = 1f, bool _allowTurning = true) { var _playerDirectional = _player.GetComponent <Directional>(); playerProgress.Add(new PlayerProgressEntry { player = _player, timeToFinish = timeForCompletion, completedAction = finishProgressAction, position = pos, playerDirectional = _playerDirectional, playerPositionCache = _player.TileWorldPosition(), facingDirectionCache = _playerDirectional.CurrentDirection, additionalSfx = _additionalSfx, additionalSfxPitch = _additionalSfxPitch, allowTurning = _allowTurning }); //Start the progress for the player: ProgressBarMessage.Send(_player, 0, pos); }