Example #1
0
        /// <summary>
        /// Called from the HoleGoal entity
        /// </summary>
        /// <param name="ball"></param>
        /// <param name="hole"></param>
        public void CupBall(GolfBall ball, int hole)
        {
            // Make sure the hole they cupped in is the current one...
            if (hole != Course.CurrentHole.Number)
            {
                // Do a custom reset if you cup it in the wrong hole
                ResetBall(ball);

                return;
            }

            // Cup the ball entity, this does fx and stops motion.
            ball.Cup(false);

            // Let all players know the ball has been cupped.
            // CuppedBall( To.Everyone, ball, player.Strokes );
            CuppedBall(To.Everyone, ball);

            Action task = async() =>
            {
                await Task.DelaySeconds(5);

                Course.AdvancedHole();

                // Reset for now
                // player.Strokes = 0;
                ResetBall(ball);
            };

            task.Invoke();
        }
Example #2
0
        public FollowBallCamera(GolfBall ball)
        {
            Ball = ball;

            Distance       = 150;
            distanceTarget = Distance;
        }
Example #3
0
        public void BallOutOfBounds(GolfBall ball, OutOfBoundsType type)
        {
            if (IsClient)
            {
                return;
            }

            ResetBall(ball);

            // Tell the ball owner his balls are out of bounds
            ClientBallOutOfBounds(To.Single(ball));
        }
Example #4
0
        protected void CuppedBall(GolfBall ball)
        {
            // Add to UI
            // Sandbox.UI.ChatBox.AddInformation(Player.All, $"{player.Name} scored on hole {hole}!", $"avatar:{player.SteamId}");

            if (Local.Pawn != ball)
            {
                return;
            }

            // nice job bro, hole in one!

            /* if ( strokes == 1 )
             *      Sound.FromScreen( SoundHoleInOne.Name ).SetVolume( 0.8f );
             * else if ( strokes - Course.CurrentHole.Par > 0 )
             *      Sound.FromScreen( SoundBelowPar.Name ); */

            _ = EndScore.Current.ShowScore(Course.CurrentHole.Number, Course.CurrentHole.Par, 3);
        }
Example #5
0
        public void StartGame()
        {
            Log.Info("Starting game?");

            // TODO: Only do clients marked as ready.
            PlayingClients = new List <Client>(Client.All);

            GameStarted    = true;
            WaitingToStart = false;

            // Set the active course
            // Spawn balls for all clients
            foreach (var cl in PlayingClients)
            {
                Log.Info($"Creating ball for {cl.Name}");

                var ball = new GolfBall();
                cl.Pawn = ball;
                ball.ResetPosition(Course.CurrentHole.SpawnPosition, Course.CurrentHole.SpawnAngles);
            }
        }
Example #6
0
 public void OnBallStoppedMoving(GolfBall ball)
 {
     // if ( CheckBounds && !ball.Cupped && !Course.CurrentHole.InBounds(ball) )
     //  BallOutOfBounds(ball, OutOfBoundsType.Normal);
 }
Example #7
0
 protected void ResetBall(GolfBall ball)
 {
     ball.ResetPosition(Course.CurrentHole.SpawnPosition, Course.CurrentHole.SpawnAngles);
 }