Question by 
               amanuilBoku · Sep 05, 2021 at 05:24 AM · 
                unityeditor  
              
 
              Give points to player and he/she hits specific target, deduct points otherwise
C# script for game manager that regulates the player to hit a specific target and if the player misses then there is a deduction from the score else if player hits a different game object then the deduction made depends on the game object that is hit
 using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
 using ThreeDPool.EventHandlers;
 using ThreeDPool.Controllers;
 using ThreeDPool.UIControllers;
 
 namespace ThreeDPool.Managers
 {
 
     /// This class is a rule manager for this pool game
     /// decides on the players playing
     /// calculates score and decides the fate of the ball and the players after each turn
     public class GameManager : Singleton
     {    
         public enum GameType
         {    
             JustCue = 1,
             ThreeBall = 3,
             SixBall = 6,
             ThreePointRack = 15,
             SevenBall    
         }
          public enum GameState
          {
              Practise = 1,
              GetSet,
              Play,
              Pause,
              Complete
          }
     
          // update the players you would be playing this round
          [SerializeField]
          private string[] _playerNames;
     
          [SerializeField]
          private GameType _gameType;
     
          [SerializeField]
          private Transform _rackTransform;
     
          [SerializeField]
          private CueBallController _cueBall;
     
          [SerializeField]
          private GameUIScreen _gameUIScreen;
     
          // maintaining a queue here so that we dont have to worry about maintain a separate field for the player turn
          private Queue<Player> _players = new Queue<Player>();
     
          private List<CueBallController> _ballsPocketed;
          private List<CueBallController> _ballsHitOut;
          private GameState _currGameState;
          private GameState _prevGameState;
          private bool _ballsInstantiated;
     
          public int NumOfBallsStriked;
     
          public GameState CurrGameState { get { return _currGameState; } }
          public GameState PrevGameState { get { return _prevGameState;  } }
     
          public Queue<Player> Players { get { return _players;  } }
     
          public string[] Winners;
     
          public int NumOfTimesPlayed { private set; get; }
     
          protected override void Start()
          {
              base.Start();
     
              ChangeGameState(GameState.Practise);
              NumOfBallsStriked = 0;
     
              if (_playerNames != null)
              {
                  foreach (var playerName in _playerNames)
                  {
                      var player = new Player(playerName);
     
                      _players.Enqueue(player);
                  }
              }
     
              // declare the ballspotted and ballshit out array
              // consider all the balls are either potted or hitout,
              // lets fix the array size based on game type + cueball
              int arraySize = (int)_gameType + 1;
              _ballsPocketed = new List<CueBallController>(arraySize);
              _ballsHitOut = new List<CueBallController>(arraySize);
     
              // create player uis
              _gameUIScreen.CreatePlayerUI();
     
              // the first player in the queue will be playing first
     
          }
      }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                