Advertisement
apieceoffruit

SystemsExample

Feb 4th, 2023
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using Jason.Services;
  3. using UnityEngine;
  4. using Zenject;
  5. using static Jason.Blackboards.Keys.PlayerFlags;
  6. using static Jason.Sound.Keys.SFX;
  7. using Input = Jason.Services.Inputs.Input;
  8. namespace Jason.Experiments
  9. {
  10.     public class StartTheGame : MonoBehaviour
  11.     {
  12.         Transform _startPoint;
  13.        
  14.         void Update()
  15.         {
  16.             if (_input.Interact.Pressed)
  17.                 Begin();
  18.         }
  19.  
  20.         void Begin()
  21.         {
  22.             if (_game.AppStatus == AppStatus.Running)
  23.             {
  24.                 _logs.Debug("Attempting to Start Game","Game Already Running!");
  25.                 return;
  26.             }
  27.            
  28.             _logs.Info("Player Interaction", "Starting Game!");
  29.             _game.Start();
  30.             _audio.PlaySFX(TADA);
  31.             _player.TeleportTo(_room.Center);
  32.             _blackboard[LAST_START_TIME] = _clock.CurrentTime.ToString();
  33.         }
  34.  
  35.         #region plumbing
  36.  
  37.         [Inject]
  38.         void Init(Logs logs, Game game, Input input,Audio gameAudio,Player player,Room room,Blackboard blackboard,WorldClock clock)
  39.         {
  40.             _logs = logs;
  41.             _game = game;
  42.             _input = input;
  43.             _audio = gameAudio;
  44.             _player = player;
  45.             _room = room;
  46.             _clock = clock;
  47.             _blackboard = blackboard;
  48.         }
  49.  
  50.         Player _player;
  51.         Audio _audio;
  52.         Input _input;
  53.         Game _game;
  54.         Logs _logs;
  55.         Room _room;
  56.         Blackboard _blackboard;
  57.         WorldClock _clock;
  58.  
  59.         #endregion
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement