bool CheckFinishLap(CarRally carScript) { if (this.route.Length == carScript.route.Count) { for (int i = 0; i < this.route.Length; i++) { for (int j = i; j < carScript.route.Count;) { if (this.route[i] != carScript.route[j]) { //print ("false"); //print (this.route[i]); //print (carScript.route[j]); return(false); } break; } } //print ("true"); carScript.route.Clear(); return(true); } //print (this.route.Length); //print (carScript.route.Count); return(false); }
//public method to be called when your local car is spawned public void Init() { for (int i = 0; i < 3; i++) { weapon[i] = new Weapon_UI("weapon" + i, PlayerPrefs.GetString("weapon" + (i + 1))); SetWeaponEnabled(i, false); boost[i] = new Boost_UI("boost" + i, "boostSprite"); } mapDimensions = new Vector2(Mathf.Abs(boundaryR.position.x - boundaryL.position.x), Mathf.Abs(boundaryT.position.z - boundaryB.position.z)); carControl = GameObject.FindGameObjectWithTag("Player").GetComponent <CarController>(); speedometer = GameObject.Find("SpeedOmeter").GetComponent <UISprite>(); //boostMeter = GameObject.Find("Boost").GetComponent<UISprite>(); shield = GameObject.Find("Shield_UI").GetComponent <UISprite>(); critLight = GameObject.Find("CriticalLight").GetComponent <UISprite>(); shieldT = GameObject.Find("Shield_UI").transform; timeTxt = GameObject.Find("TotalTime").GetComponent <UILabel>(); MapBG = GameObject.Find("MapBG").GetComponent <UISprite>(); PlayerLocT = GameObject.Find("PlayerLoc").transform; PlayerGlobalTransform = GameObject.FindGameObjectWithTag("Player").transform; carStats = GameObject.FindGameObjectWithTag("Player").GetComponent <CarRally>(); carUsercontrol = GameObject.FindGameObjectWithTag("Player").GetComponent <CarUserControl>(); // PLAYER PREFS TEST Debug.Log("weapon1: " + PlayerPrefs.GetString("weapon1")); Debug.Log("weapon2: " + PlayerPrefs.GetString("weapon2")); Debug.Log("weapon3: " + PlayerPrefs.GetString("weapon3")); /* * Debug.Log("Data From Player Selection"); * Debug.Log("CarModel: " + PlayerPrefs.GetString("car")); * Debug.Log("speed: " + PlayerPrefs.GetFloat("speed")); * Debug.Log("boost: " + PlayerPrefs.GetFloat("boost")); * Debug.Log("handling: " + PlayerPrefs.GetFloat("handling")); * Debug.Log("accel: " + PlayerPrefs.GetFloat("accel")); */ StartCoroutine(InitMiniMapSprite()); carSpawned = true; }
//public method to be called when your local car is spawned public void Init() { for(int i=0;i<3;i++) { weapon[i] = new Weapon_UI("weapon"+i,PlayerPrefs.GetString("weapon"+ (i+1) )); SetWeaponEnabled(i,false); boost[i] = new Boost_UI("boost"+i,"boostSprite"); } mapDimensions = new Vector2(Mathf.Abs(boundaryR.position.x-boundaryL.position.x),Mathf.Abs(boundaryT.position.z-boundaryB.position.z)); carControl = GameObject.FindGameObjectWithTag("Player").GetComponent<CarController>(); speedometer = GameObject.Find("SpeedOmeter").GetComponent<UISprite>(); boostMeter = GameObject.Find("Boost").GetComponent<UISprite>(); shield = GameObject.Find("Shield_UI").GetComponent<UISprite>(); critLight = GameObject.Find("CriticalLight").GetComponent<UISprite>(); shieldT = GameObject.Find("Shield_UI").transform; timeTxt = GameObject.Find("TotalTime").GetComponent<UILabel>(); MapBG = GameObject.Find("MapBG").GetComponent<UISprite>(); PlayerLocT = GameObject.Find("PlayerLoc").transform; PlayerGlobalTransform = GameObject.FindGameObjectWithTag ("Player").transform; carStats = GameObject.FindGameObjectWithTag("Player").GetComponent<CarRally>(); // PLAYER PREFS TEST Debug.Log("weapon1: " + PlayerPrefs.GetString("weapon1")); Debug.Log("weapon2: " + PlayerPrefs.GetString("weapon2")); Debug.Log("weapon3: " + PlayerPrefs.GetString("weapon3")); /* Debug.Log("Data From Player Selection"); Debug.Log("CarModel: " + PlayerPrefs.GetString("car")); Debug.Log("speed: " + PlayerPrefs.GetFloat("speed")); Debug.Log("boost: " + PlayerPrefs.GetFloat("boost")); Debug.Log("handling: " + PlayerPrefs.GetFloat("handling")); Debug.Log("accel: " + PlayerPrefs.GetFloat("accel")); */ StartCoroutine (InitMiniMapSprite ()); carSpawned = true; }