Exemple #1
0
        private void ConfigVehicleAllGameData(VehicleEntity vehicle)
        {
            var config   = GetCarConfig(vehicle);
            var gameData = vehicle.carGameData;

            if (SharedConfig.IsOffline || SharedConfig.IsServer)
            {
                VehicleCommonUtility.SetSoundGameData(gameData);
            }

            gameData.MaxFuel  = config.maxFuelVolume;
            gameData.FuelCost = config.fuelCost / 60.0f;
            gameData.FuleCostOnAcceleration = gameData.FuelCost * (1 + config.accelerateFuelCostRatio);
            gameData.RemainingFuel          = config.GetRandomFuelVolume();

            gameData.MaxHp = config.maxHp;
            gameData.Hp    = gameData.MaxHp;

            gameData.IsAccelerated = false;

            var controller = GetController(vehicle);

            gameData.WheelCount    = controller.WheelCount;
            gameData.MaxWheelHp    = config.maxWheelHp;
            gameData.FirstWheelHp  = gameData.MaxWheelHp;
            gameData.SecondWheelHp = gameData.MaxWheelHp;
            gameData.ThirdWheelHp  = gameData.MaxWheelHp;
            gameData.FourthWheelHp = gameData.MaxWheelHp;

            vehicle.vehicleBrokenFlag.Init();
        }
        public void ConfigHitBoxImposter(VehicleEntity vehicle, GameObject hitboxImposter)
        {
            var config = GetShipConfig(vehicle);

            config.hitBoxRootImposter = VehicleCommonUtility.GetChildByName(hitboxImposter.transform, config.hitBoxRootName);
            if (config.hitBoxRootImposter == null)
            {
                config.hitBoxRootImposter = hitboxImposter.transform;
            }

            var rudderCount = config.rudderHitBoxes.Length;

            config.rudderHitBoxImposters = new Transform[rudderCount];
            for (int i = 0; i < rudderCount; ++i)
            {
                config.rudderHitBoxImposters[i] = VehicleCommonUtility.GetChildByName(hitboxImposter.transform, config.rudderHitBoxNames[i]);
                AssertUtility.Assert(config.rudderHitBoxImposters[i] != null);
            }
        }
        private void ConfigVehicleAllGameData(VehicleEntity vehicle)
        {
            var config   = GetShipConfig(vehicle);
            var gameData = vehicle.shipGameData;

            if (SharedConfig.IsOffline || SharedConfig.IsServer)
            {
                VehicleCommonUtility.SetSoundGameData(gameData);
            }

            gameData.MaxFuel  = config.maxFuelVolume;
            gameData.FuelCost = config.fuelCost / 60.0f;
            gameData.FuleCostOnAcceleration = gameData.FuelCost * (1 + config.accelerateFuelCostRatio);
            gameData.RemainingFuel          = config.GetRandomFuelVolume();

            gameData.MaxHp = config.maxHp;
            gameData.Hp    = gameData.MaxHp;

            gameData.IsAccelerated = false;

            vehicle.vehicleBrokenFlag.Init();
        }
Exemple #4
0
        public void ConfigHitBoxImposter(VehicleEntity vehicle, GameObject hitboxImposter)
        {
            var config = GetCarConfig(vehicle);

            config.hitBoxRootImposter = VehicleCommonUtility.GetChildByName(hitboxImposter.transform, config.hitBoxRootName);
            if (config.hitBoxRootImposter == null)
            {
                config.hitBoxRootImposter = hitboxImposter.transform;
            }

            var flexibleHitBoxNames = config.flexibleHitBoxNames;

            if (flexibleHitBoxNames.Length > (int)VehiclePartIndex.MaxFlexibleCount)
            {
                _logger.ErrorFormat("The flexible hitbox in the car exceed maximum number {0}", VehiclePartIndex.MaxFlexibleCount);
            }
            else
            {
                config.flexibleHitBoxImposters = new Transform[flexibleHitBoxNames.Length];
                for (int i = 0; i < flexibleHitBoxNames.Length; ++i)
                {
                    config.flexibleHitBoxImposters[i] =
                        VehicleCommonUtility.GetChildByName(hitboxImposter.transform, flexibleHitBoxNames[i]);
                }
            }

            var wheelCount = config.wheelHitBoxNames.Length;

            config.wheelHitBoxImposters = new WheelHitBox[wheelCount];
            for (int i = 0; i < wheelCount; ++i)
            {
                config.wheelHitBoxImposters[i]             = new WheelHitBox();
                config.wheelHitBoxImposters[i].OuterHitBox = VehicleCommonUtility.GetChildByName(hitboxImposter.transform, config.wheelHitBoxNames[i].OuterHitBoxName);
                config.wheelHitBoxImposters[i].InnerHitBox = VehicleCommonUtility.GetChildByName(hitboxImposter.transform, config.wheelHitBoxNames[i].InnerHitBoxName);
                AssertUtility.Assert(config.wheelHitBoxImposters[i].OuterHitBox != null, "node " + i + ", " + config.wheelHitBoxNames[i]);
            }
        }
        public void InitController(VehicleEntity vehicle, bool isServer, int vehicleId)
        {
            var controller = GetController(vehicle);

            VehicleCommonUtility.InitController(controller, isServer, vehicleId);
        }