Exemplo n.º 1
0
 public void AddCarToPlayerCarsList(PlayerCarModel car)
 {
     if (!playerCars.Contains(car))
     {
         playerCars.Add(car);
     }
 }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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
            }
        }
Exemplo 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);
            }
        }
Exemplo 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);
        }