示例#1
0
    void UpdatePassengerOnSeats()
    {
        hasDriver = false;
        for (int i = 0; i < Seats.Length; i++)
        {
            if (Seats[i].PassengerID != "none")
            {
                // Searching for a player with passenger id to snap them into a vehicle.
                GameObject obj = findPlayerByID(Seats[i].PassengerID);
                if (obj)
                {
                    CharacterDriver driver = obj.GetComponent <CharacterDriver>();

                    if (driver)
                    {
                        driver.NeedParachute = NeedParachute;

                        FPSController fps = driver.GetComponent <FPSController>();
                        if (fps)
                        {
                            fps.FixedRotation();
                        }

                        if (Seats[i].ForceView != PlayerViewType.None)
                        {
                            PlayerView view = driver.GetComponent <PlayerView>();
                            if (view)
                            {
                                view.View          = Seats[i].ForceView;
                                view.OrbitDistance = Seats[i].ViewDistance;
                            }
                        }
                        if (Seats[i].FixRotation)
                        {
                            driver.transform.rotation = Seats[i].transform.rotation;
                        }
                        driver.character.Motor.grounded     = false;
                        driver.transform.position           = Seats[i].transform.position;
                        driver.transform.parent             = Seats[i].transform;
                        driver.CurrentVehicle               = this;
                        driver.character.controller.enabled = false;
                        driver.DrivingSeat = Seats[i];
                        hasDriver          = true;
                        if (driver.character.IsAlive == false)
                        {
                            Seats[i].PassengerID = "none";
                        }
                    }
                }
            }
            else
            {
                Seats[i].CleanSeat();
            }
        }

        if (isServer)
        {
            GenSeatsData();
        }
    }
示例#2
0
    void UpdatePassengerOnSeats()
    {
        hasDriver = false;
        for (int i = 0; i < Seats.Length; i++)
        {
            if (Seats[i].PassengerID != -1)
            {
                //搜索具有乘客ID的玩家将其捕捉到车辆中。
                NetworkInstanceId passengerid = new NetworkInstanceId((uint)Seats[i].PassengerID);
                GameObject        obj         = ClientScene.FindLocalObject(passengerid);
                if (obj)
                {
                    CharacterDriver driver = obj.GetComponent <CharacterDriver>();

                    if (driver)
                    {
                        driver.NeedParachute = NeedParachute;

                        FPSController fps = driver.GetComponent <FPSController>();
                        if (fps)
                        {
                            fps.FixedRotation();
                        }

                        if (Seats[i].ForceView != PlayerViewType.None)
                        {
                            PlayerView view = driver.GetComponent <PlayerView>();
                            if (view)
                            {
                                view.View          = Seats[i].ForceView;
                                view.OrbitDistance = Seats[i].ViewDistance;
                            }
                        }
                        if (Seats[i].FixRotation)
                        {
                            driver.transform.rotation = Seats[i].transform.rotation;
                        }
                        driver.character.Motor.grounded     = false;
                        driver.transform.position           = Seats[i].transform.position;
                        driver.transform.parent             = Seats[i].transform;
                        driver.CurrentVehicle               = this;
                        driver.character.controller.enabled = false;
                        driver.DrivingSeat = Seats[i];
                        hasDriver          = true;
                        if (driver.character.IsAlive == false)
                        {
                            Seats[i].PassengerID = -1;
                        }
                    }
                }
            }
            else
            {
                Seats[i].CleanSeat();
            }
        }

        if (isServer)
        {
            GenSeatsData();
        }
    }