Esempio n. 1
0
 public void AddCarToPlayerCarsList(PlayerCarModel car)
 {
     if (!playerCars.Contains(car))
     {
         playerCars.Add(car);
     }
 }
Esempio n. 2
0
        public CarBase CreateEnemyCar(PlayerCarModel model, int colorId)
        {
            CarBase _enemyCar = CreateCar(model);

            _enemyCar.Transform.position = new Vector3(0f, 3f, -2f);
            _enemyCar.SetColorInGame(colorId);
            _enemyCar.transform.tag = "Enemy";
            return(_enemyCar);
        }
Esempio n. 3
0
        public CarBase CreatePlayerCar(PlayerCarModel model, int colorId)
        {
            CarBase playerCar;

            playerCar = CreateCar(model);
            playerCar.SetColorInGame(colorId);
            playerCar.transform.tag      = "Player";
            playerCar.Transform.position = new Vector3(0f, 3f, 2f);
            return(playerCar);
        }
Esempio n. 4
0
        public PlayerCarModel GetCar(string gameId)
        {
            string         Game    = PlayerPrefs.GetString(PPKeys.JSON);
            JObject        gameObj = JObject.Parse(Game);
            PlayerCarModel car     = new PlayerCarModel()
            {
                car_upgrade_level = int.Parse(gameObj[gameId]["car_upgrade_level"]),
                current_color     = int.Parse(gameObj[gameId]["current_color"]),
                carLevel          = int.Parse(gameObj[gameId]["carLevel"]),
                type = int.Parse(gameObj[gameId]["type"])
            };

            return(car);
        }
Esempio n. 5
0
        public void ChooseCar(PlayerCarModel car)
        {
            if (playerCars.Contains(car))
            {
                selectedCar = car;
            }
            else
            {
                #region DEBUG
#if UNITY_EDITOR
                //Debug.LogError("User don't have car: " + car);
#endif
                #endregion
            }
        }
Esempio n. 6
0
        private CarBase CreateCar(PlayerCarModel model)
        {
            if (model == null)
            {
                model = new PlayerCarModel()
                {
                    carType = CarTypeEnum.Baggy, carLevel = 0, car_upgrade_level = 0
                };
            }
            CarModel carModel = DataModel.Instance.GetCar(model.carType, model.carLevel);

            if (carModel == null)
            {
                carModel = new CarModel()
                {
                    CarType = model.carType, level = model.carLevel
                };
            }
            //TODO  get car upgrades from model;

            //Load specific car from resources, cast to CarBase
            //Init physics parameters by car options


            var c = Resources.Load("RaceCarsPrefabs/" + carModel.GetPrefabName(model.car_upgrade_level));

            if (c != null)
            {
                var carGO = GameObject.Instantiate(c) as GameObject;
                var car   = carGO.GetComponent <CarBase>();
                car.model = model;
                car.Init();
                return(car);
            }
            else
            {
                c = Resources.Load("RaceCarsPrefabs/" + carModel.GetPrefabName(model.car_upgrade_level - 1));
                var carGO = GameObject.Instantiate(c) as GameObject;
                var car   = carGO.GetComponent <CarBase>();
                car.model = model;
                car.Init();
                return(car);
            }
        }
Esempio n. 7
0
        public void SaveRecordData(GameData gameData, PlayerCarModel pcm, JObject respObj)
        {   //
            respObj[gameData.gameId].Add("replayData", "crash");
            respObj[gameData.gameId].Add("smile", new object());
            if (gameData.smiles != null)
            {
                foreach (var str in gameData.smiles)
                {
                    respObj[gameData.gameId]["smile"].Add(str.ToString());
                }
            }
            else
            {
                respObj[gameData.gameId]["smile"].Add("1");
                respObj[gameData.gameId]["smile"].Add("1");
                respObj[gameData.gameId]["smile"].Add("1");
            }



            respObj[gameData.gameId].Add("IsFinishedRecord", gameData.IsFinishedRecord);
            respObj[gameData.gameId].Add("IsDone", gameData.IsDone);
            respObj[gameData.gameId].Add("track_id", gameData.track_id);
            respObj[gameData.gameId].Add("gameResultScore", gameData.gameResultScore);


            respObj[gameData.gameId].Add("current_color", pcm.current_color);
            respObj[gameData.gameId].Add("carLevel", pcm.carLevel);
            respObj[gameData.gameId].Add("type", pcm.type);
            respObj[gameData.gameId].Add("car_upgrade_level", pcm.car_upgrade_level);



            string respons = respObj.ToString();

            PlayerPrefs.SetString(PPKeys.JSON, respons);
        }