Exemplo n.º 1
0
        /// <summary>
        /// Sets the vehicles parts as stored in the PlayersData array
        /// </summary>
        private void SetVehicleParts()
        {
            //Debug.Log("Setting vehicle parts");
            foreach (GameObject P in Players)
            {
                SimpleCarController S = P.GetComponent <SimpleCarController>();
                VehicleMods         V = P.GetComponent <VehicleMods>();

                for (int i = 0; i < PlayersData.Length; i++)
                {
                    if (S.playerId == PlayersData[i].playerID)
                    {
                        V.MyChassis     = PlayersData[i].myChassis;
                        V.MyFrontMotor  = PlayersData[i].myFrontMotor;
                        V.MyRearMotor   = PlayersData[i].myRearMotor;
                        V.MyBattery     = PlayersData[i].myBattery;
                        V.MyFrontWheels = PlayersData[i].myFrontWheels;
                        V.MyRearWheels  = PlayersData[i].myRearWheels;
                        V.MyArmor       = PlayersData[i].myArmor;
                        V.MyFrontWeapon = PlayersData[i].myFrontWeapon;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets vehicle data that is stored persistently in the scene.
        /// </summary>
        /// <param name="PlayerID"></param>
        /// <param name="Slot"></param>
        /// <param name="Value"></param>
        public void SetVehicleData(int PlayerID, VehicleMods.VehicleSlots Slot, string Value)
        {
            foreach (GameObject P in Players)
            {
                SimpleCarController S = P.GetComponent <SimpleCarController>();
                VehicleMods         V = P.GetComponent <VehicleMods>();

                if (S.playerId == PlayerID)
                {
                    switch (Slot)
                    {
                    case VehicleMods.VehicleSlots.ChassisSlot:
                        PlayersData[PlayerID].myChassis = Value;
                        V.MyChassis = Value;
                        break;

                    case VehicleMods.VehicleSlots.FrontMotorSlot:
                        PlayersData[PlayerID].myFrontMotor = Value;
                        V.MyFrontMotor = Value;
                        break;

                    case VehicleMods.VehicleSlots.RearMotorSlot:
                        PlayersData[PlayerID].myRearMotor = Value;
                        V.MyRearMotor = Value;
                        break;

                    case VehicleMods.VehicleSlots.FrontWheelsSlot:
                        PlayersData[PlayerID].myFrontWheels = Value;
                        V.MyFrontWheels = Value;
                        break;

                    case VehicleMods.VehicleSlots.RearWheelsSlot:
                        PlayersData[PlayerID].myRearWheels = Value;
                        V.MyRearWheels = Value;
                        break;

                    case VehicleMods.VehicleSlots.BatterySlot:
                        PlayersData[PlayerID].myBattery = Value;
                        V.MyBattery = Value;
                        break;

                    case VehicleMods.VehicleSlots.ArmorSlot:
                        PlayersData[PlayerID].myArmor = Value;
                        V.MyArmor = Value;
                        break;

                    case VehicleMods.VehicleSlots.FrontWeaponSlot:
                        PlayersData[PlayerID].myFrontWeapon = Value;
                        V.MyFrontWeapon = Value;
                        break;

                    case VehicleMods.VehicleSlots.RearWeaponSlot:
                        PlayersData[PlayerID].myRearWeapon = Value;
                        V.MyRearWeapon = Value;
                        break;

                    case VehicleMods.VehicleSlots.TopWeaponSlot:
                        PlayersData[PlayerID].myTopWeapon = Value;
                        V.MyTopWeapon = Value;
                        break;
                    }
                }
            }
        }