Ejemplo n.º 1
0
    /// <summary>
    /// Hits the ball on the host.
    /// </summary>
    /// <param name="code">The message data from the packets.</param>
    internal void UpdateBalls(string code)
    {
        SerializationScript.BallShot ballShot = SerializationScript.DeserializeBallShot(code);
        GameObject    ball = ballShot.isAbilityBall ? golfBallManager.GetAbilityBallOfId(ballShot.ballID) : golfBallManager.GetBallOfId(ballShot.ballID);
        BallRetrieval br   = ball.GetComponent <BallRetrieval>();

        ball.GetComponent <Rigidbody>().velocity = ballShot.direction;
        if (br)
        {
            ball.GetComponent <BallRetrieval>().SetNewBallPos();
        }
        GolfBall golf = ball.GetComponent <GolfBall>();

        golf.HitBall(ballShot.shooterID, network.IsHost());
        if (network.IsHost())
        {
            if (golf.IsAbilityBall())
            {
                MovingAbilityBalls.Add(golf);
            }

            if (ballShot.shouldHome)
            {
                Honing theHone = ball.gameObject.GetComponent <Honing>();
                if (theHone != null && ballShot.homingTargetID >= 0)
                {
                    theHone.HoneToPlayer(network.GetPlayerOfID(ballShot.homingTargetID));
                }
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator NoNetworkingWaitForSwing(GolfBall golfBall, Vector3 dir)
    {
        while (!swing)
        {
            yield return(new WaitForEndOfFrame());
        }

        golfBall.GetComponent <Rigidbody>().velocity = dir;
        if (clubStats.ClubName == "Driver")
        {
            Honing     theHone = golfBall.gameObject.GetComponent <Honing>();
            GameObject obj     = theHone?.GetObjOfClosestPlayer();
            if (obj != null)
            {
                theHone.HoneToPlayer(obj);
            }
        }
    }