示例#1
0
		public void initFromDatabase(string aUsersTeamName) {
			List<DriverLibraryRecord> availableDrivers = DriverLibrary.REF.drivers;
			for(int i = 0;i<availableDrivers.Count;i++) {
				availableDrivers[i].assignedTeam = 0;
			}
			GTDriver.allDrivers = new List<GTDriver>();
			List<DriverLibraryRecord> availableDrivers1 = DriverLibrary.REF.getAllAvailableDrivers();
			for(int i = 0;i<availableDrivers1.Count;i++) {
				GTDriver g = new GTDriver();
				g.initFromLibrary(availableDrivers1[i]);
			}
			ACTIVE_SEASON = this;
			List<TeamDataRecord> allTeams = Database.TeamDatabase.REF.teams;
			for(int i = 0;i<allTeams.Count;i++) {
				this.seasonForLeague(allTeams[i].startLeague).addTeam(new GTTeam(allTeams[i]));
			}
			for(int i = 0;i<this.leagues.Count;i++) {
				for(int c = 0;c<leagues[i].teams.Count;c++) {
					leagues[i].teams[c].ignoreFromRelegationAndPromotion = false;
				}
			}
			this.season = 1;
			this.getUsersTeam().teamName = aUsersTeamName;
			DialogueLua.SetVariable("PlayersTeamName",aUsersTeamName);
			ChampionshipSeason.ACTIVE_SEASON = this;
			if(Application.loadedLevelName=="MainMenu") {
				StartCoroutine(this.LoadLevel("Garage","Loading Garage"));
			}
		}
示例#2
0
	public void init(GTDriver aDriver,int aPosition,bool showPoints) {
		driver = aDriver;
		if(positionLabel==null) {
			UILabel[] childLabels = this.GetComponentsInChildren<UILabel>();
			for(int i = 0;i<childLabels.Length;i++) {
				if(childLabels[i].gameObject.name=="FinisherPosition") {
					positionLabel = childLabels[i];
				}
				if(childLabels[i].gameObject.name=="FinisherName") {
					nameLabel = childLabels[i];
				}
				if(childLabels[i].gameObject.name=="FinisherDetail") {
					prizeInfo = childLabels[i];
				}
			}
		}
		string pos = (aPosition+1)+". ";
		this.positionLabel.text = pos;
		this.nameLabel.text = aDriver.name+" "+ChampionshipSeason.ACTIVE_SEASON.getTeamFromDriver(aDriver).teamName;
		if(!showPoints)
			this.prizeInfo.text = ""; else {
			this.prizeInfo.text = ""+aDriver.championshipPoints;
		}

		
	}
示例#3
0
		public TeamDataRecord (TeamNamesRow aTeamNameRow)
		{
			id = aTeamNameRow._id;
			name = aTeamNameRow._teamname;
			description = aTeamNameRow._teamdescription;
			teamColor = new Color(aTeamNameRow._teamcolorr/255f,aTeamNameRow._teamcolorg/255f,aTeamNameRow._teamcolorb/255f);
			wheelColor = new Color(aTeamNameRow._wheelcolorr/255f,aTeamNameRow._wheelcolorg/255f,aTeamNameRow._wheelcolorb/255f);
			startLeague = aTeamNameRow._startleague;
			
			carA = new GTCar (aTeamNameRow._startingcar1);
			reputation = aTeamNameRow._reputation;
			
  
			driverA = new GTDriver (); 
			DriverLibraryRecord driverRecord = DriverLibrary.REF.getAvailableDriver();
			driverRecord.assignedTeam = id;
			driverA.initFromLibrary(driverRecord);
			carB = new GTCar (aTeamNameRow._startingcar2);
  
			driverB = new GTDriver ();
			driverRecord = DriverLibrary.REF.getAvailableDriver();
			driverB.initFromLibrary(driverRecord);
			driverRecord.assignedTeam = id;

		}
示例#4
0
		public virtual void FromString(string aString) {
			string uncom = Base64.Base64Decode(aString);
			string[] s = uncom.Split(new char[] {'|'});
			GTDriver d = new GTDriver();
			d.FromString(s[0]);

			this.drivers.Add(d);
			d = new GTDriver();
			d.FromString(s[1]);
			this.drivers.Add(d);
			GTCar c = new GTCar();
			c.FromString(s[2]);
			this.cars.Add(c);
			c = new GTCar();
			c.FromString(s[3]);
			this.cars.Add(c);

			teamColor.r = (float) Convert.ToDouble(s[4]);
			teamColor.g = (float) Convert.ToDouble(s[5]);
			teamColor.b = (float) Convert.ToDouble(s[6]);
			teamColor.a = 1f;
			wheelColor.r = (float) Convert.ToDouble(s[7]);
			wheelColor.g = (float) Convert.ToDouble(s[8]);
			wheelColor.b = (float) Convert.ToDouble(s[9]);
			wheelColor.a = 1f;

			if(s[10].ToLower()=="true") {
				humanControlled = true;
			} else {
				humanControlled = false;
			}
			this.teamName = s[11];
			this.seasonPoints = Convert.ToInt32(s[12]);
			this.seasonWins =Convert.ToInt32(s[13]);
			this.cash = Convert.ToInt32(s[14]);
			this.reputation = Convert.ToInt32(s[15]);
			this.id = Convert.ToInt32(s[16]);

			DriverLibraryRecord rec = DriverLibrary.REF.driverByID(drivers[0].id);
			
			rec.assignedTeam = id;
			rec = DriverLibrary.REF.driverByID(drivers[1].id);
			 
			rec.assignedTeam = id; 

			ignoreFromRelegationAndPromotion = false;
		}
		private static int SortListByReverse(GTDriver a1, GTDriver a2)
		{
			if(a1==a2) {
				return 0;
			}
			if(a1.championshipPoints>a2.championshipPoints) {
				return 1;
			} else if(a1.championshipPoints<a2.championshipPoints) {
				return -1;
			} else {
				if(UnityEngine.Random.Range(0,100)<50) {
					return -1;
				} else {
					return 1;  
				}
			}
		}
示例#6
0
	public void initDriver(GTDriver aDriver,GTDriver aDriverToReplace) {

		GarageManager.REF.doConversation("OpenHireDriverScreen");
		_thisDriver = aDriver;
		_driverToReplace = aDriverToReplace; 
		GTTeam driversTeam = ChampionshipSeason.ACTIVE_SEASON.getTeamFromDriver(aDriver);
		GTTeam myTeam = ChampionshipSeason.ACTIVE_SEASON.getUsersTeam();
		faceSprite.sprite2D = aDriver.record.sprite;
		if(driversTeam==myTeam) {
			this.titleForScreen.text = "Renew Contract with "+aDriver.name;
		} else {
			
			this.titleForScreen.text = "Offer Contract to "+aDriver.name;

		}
		if(driversTeam==null) {
			currentContractInfo.text = aDriver.name+" is a Free Agent";
		} else {
			currentContractInfo.text = aDriver.name+" is contracted to "+driversTeam.teamName+"";
		}
		offerContract.team = ChampionshipSeason.ACTIVE_SEASON.getUsersTeam();
		//float demandSalary = aDriver.contract;
		DriverRelationshipRecord relationshipForDriver = myTeam.relationshipWithDriver(aDriver);
	
		if(relationshipForDriver.interest.payDemand==0f) {
			this.driverDemands.text = aDriver.name+" is not interested in joining your team at any price";
		} else {
			string payDemand = aDriver.name+" is demanding "+relationshipForDriver.interest.payDemand.ToString("C0")+" Per Race for a minimum of "+relationshipForDriver.interest.contractLength+" seasons. ";
			offerContract.payPerRace = Convert.ToInt32(relationshipForDriver.interest.payDemand);
			if(relationshipForDriver.interest.bonusDemand>0f) {
				string bonusDemand = "They are also demanding a win bonus of "+relationshipForDriver.interest.bonusDemand.ToString("C0")+". ";
				payDemand += bonusDemand;
				offerContract.bonusPerRace = Convert.ToInt32(relationshipForDriver.interest.bonusDemand);
			}
			offerContract.remainingOnContract = relationshipForDriver.interest.contractLength;
			if(aDriver.contract.team!=null&&aDriver.contract.team!=myTeam) {
				string compensation = "If "+aDriver.name+" accepts our offer, we must pay "+aDriver.contract.team.teamName+" "+aDriver.contract.compensationAmount.ToString("C0")+" compensation if the contract is accepted.";
				payDemand += compensation;
			}
			this.driverDemands.text = payDemand;
		}
		showCurrentContractOffer();
	}
		public void FromString(string aString) {
			GTDriver.allDrivers = new List<GTDriver>();
			List<DriverLibraryRecord> availableDrivers = DriverLibrary.REF.drivers;
			for(int i = 0;i<availableDrivers.Count;i++) {
				availableDrivers[i].assignedTeam = 0;
			}
			GTDriver.allDrivers = new List<GTDriver>();

			ChampionshipSeason.ACTIVE_SEASON = (ChampionshipSeason) this;
			string[] split1 = aString.Split (new char[] {'%'});
			aString = split1[0];
			string[] split = aString.Split (new char[] {'|'});
			if(split.Length>1) {
				ChampionshipSeason.ACTIVE_SEASON.secondsPast = Convert.ToInt32(split[0]);
			}
			for(int i = 1;i<split.Length;i++) {
				ChampionshipSeasonLeague l = new ChampionshipSeasonLeague();
				if(split[i].Length>10) {
					l.FromString(split[i]);
					leagues.Add(l);
				}
			}
			split = split1[1].Split (new char[] {'|'});
			for(int i = 0;i<split.Length;i++) {
				if(split[i].Length>10) {
					GTDriver d = new GTDriver();
					d.FromString(split[i]);
				}
				
			}
			for(int i = 0;i<leagues.Count;i++) {
				leagues[i].postInit();
			}

			for(int i = 0;i<GTDriver.allDrivers.Count;i++) {
				GTDriver.allDrivers[i].initContract();
			}
		}
示例#8
0
	// Use this for initialization
	void Start () {
		UM_InAppPurchaseManager.instance.Init();
		DontDestroyOnLoad (this.gameObject);
		this.GetComponent<DriverLibrary> ().init ();
		this.GetComponent<CarDatabase> ().init ();
		this.GetComponent<TeamDatabase> ().init ();
		List<DriverLibraryRecord> availableDrivers = DriverLibrary.REF.getAllAvailableDrivers();
		for(int i = 0;i<availableDrivers.Count;i++) {
			GTDriver g = new GTDriver();
			g.initFromLibrary(availableDrivers[i]);
		}
		this.GetComponent<TrackDatabase>().init();
		this.GetComponent<SponsorDatabase>().init();
		if(Application.loadedLevelName=="InitGame") {
			Application.LoadLevel("MainMenu");
		}
		
		UM_InAppPurchaseManager.instance.addEventListener(UM_InAppPurchaseManager.ON_BILLING_CONNECT_FINISHED, OnConnectFinished);
	//	ChampionshipSeason champ = GameObject.Find ("ChampionshipObject").GetComponent<ChampionshipSeason>();
	//	champ.initFromDatabase();
		//StartCoroutine(LoadLevel());

	}
示例#9
0
	private void onContractManageAccepted(GTDriver aHiredDriver) {
		this.gameObject.SetActive(true);
		initDriver(aHiredDriver);
	}
示例#10
0
	private IEnumerator waitToReinit(GTDriver aDriver) {
		yield return new WaitForEndOfFrame();
		initDriver(aDriver);
	}
示例#11
0
	public void initDriver(GTDriver aDriver) {
		//if(driverTitle==null)
		initLabels();
		camController = GameObject.Find("Main Camera").GetComponent<GarageCameraController>();
		
		if(driverTitle!=null) {
			driverTitle.text = aDriver.name;
			brakingAggressionBar.value = GTDriver.percentOfGoodnessBrakingValue(aDriver.aggressivenessOnBrake);
			this.corneringBar.value = GTDriver.percentOfGoodnessCorneringValue(aDriver.corneringSpeedFactor);
			float errorVal = GTDriver.percentOfGoodnessErrorValue(aDriver.humanError);
			this.errorProneBar.value = errorVal;
			this.overtakingBar.value = GTDriver.percentOfGoodnessOvertakingValue(aDriver.overtakeSpeedDifference);
			this.sponsorAppealBar.value = GTDriver.percentOfGoodnessSponsorValue(aDriver.sponsorFriendliness);
		/*	brakingAggressionLabel.text = aDriver.brakingAggressionString;
			corneringLabel.text = aDriver.corneringSkillString;
			errorProneLabel.text = aDriver.errorProneString;
			overtakingLabel.text = aDriver.overtakingString;
		//	staminaLabel.text = aDriver.staminaString;*/
			GTTeam team = aDriver.contract.team;
			if(team==null) {
				this.currentTeamLabel.text = "No Team";
				
			} else
				this.currentTeamLabel.text = team.teamName;
			
			faceSprite.sprite2D = aDriver.record.sprite;;
			//this.sponsorAppealLabel.text = aDriver.sponsorAppealString;
			
			this.payPerRaceLabel.text = ""+aDriver.contract.payPerRace.ToString("C0");

			
		}
		if(overtakingBar.sprites.Count==0) {
			StartCoroutine(waitToReinit(aDriver));
		}
		this.driverRef = aDriver;
	}
		public DriverRelationshipRecord (GTDriver aRecord,int aRelationshipValue)
		{
			init(aRecord,aRelationshipValue);
		}
		public void init(GTDriver aRecord,int aRelationshipValue)
		{
			record = aRecord;
			currentRelationshipValue = aRelationshipValue - record.demandingReputation;
		}
		public GTTeam getTeamFromDriver(GTDriver aDriver) {
			for(int i = 0;i<teams.Count;i++) {
				if(teams[i].hasDriver(aDriver)!=null) {
					return teams[i];
				}
			}
			return null;
		}
示例#15
0
		public GTDriver hasDriver(GTDriver aDriver) {
			for(int i = 0;i<drivers.Count;i++) {
				if(drivers[i].id==aDriver.id) {
					return drivers[i];
				}
			}
			return null;
		}
示例#16
0
		public IRDSCarControllerAI getCarFromDriver(GTDriver aDriver) {
			int index = indexForDriver(aDriver);
			GTCar car = cars[index];

			IRDSCarControllerAI ret = car.carReference;
			ret.SetDriverName(aDriver.name);
			return ret;
		}
示例#17
0
	private void onContractAccepted(GTDriver aHiredDriver) {
		Destroy(this.gameObject);
		myDriverPanel.initDriver(aHiredDriver);
		myDriverPanel.showButtons();
	}
		public static int SortByChampionshipPoints(GTDriver aDriver1,GTDriver aDriver2) {
			if(aDriver1.championshipPoints<aDriver2.championshipPoints) {
				return 1;
			} if(aDriver1.championshipPoints>aDriver2.championshipPoints) {
				return -1;
			} else if(aDriver1.lastRacePoints>aDriver2.lastRacePoints) {
				return -1;
			} else if(aDriver1.lastRacePoints<aDriver2.lastRacePoints) {
				return 1;
			} else {
				return 0;
			}
		}
		public GTTeam getTeamFromDriver(GTDriver aDriver) {
			for(int i = 0;i<leagues.Count;i++) {
				GTTeam team = leagues[i].getTeamFromDriver(aDriver);
				if(team!=null) {
					return team;
				}
			}
			return null;
		}
示例#20
0
	public void showChampionshipPoints(GTDriver aDriver,int aPosition) {
		if(positionLabel==null) {
			UILabel[] childLabels = this.GetComponentsInChildren<UILabel>();
			for(int i = 0;i<childLabels.Length;i++) {
				if(childLabels[i].gameObject.name=="FinisherPosition") {
					positionLabel = childLabels[i];
				}
				if(childLabels[i].gameObject.name=="FinisherName") {
					nameLabel = childLabels[i];
				}
				if(childLabels[i].gameObject.name=="FinisherDetail") {
					prizeInfo = childLabels[i];
				}
			}
		}
		this.positionLabel.text = (aPosition+1)+". ";
		if(ChampionshipSeason.ACTIVE_SEASON.getTeamFromDriver(aDriver)==ChampionshipSeason.ACTIVE_SEASON.getUsersTeam()) {
			this.nameLabel.color = colorWhenOwned;
		} else this.nameLabel.color = colorWhenNotOwned;
		this.nameLabel.text = aDriver.name+" "+ChampionshipSeason.ACTIVE_SEASON.getTeamFromDriver(aDriver).teamName;
		this.prizeInfo.text = aDriver.championshipPoints+"";
	}
示例#21
0
	// Update is called once per frame


	public RacingAI initDriver(GTDriver aRecord) {
		GameObject g = this.gameObject;
		aiCar = g.GetComponent<IRDSCarControllerAI>();
		if (aiCar != null) {
			driverRecord = aRecord;
			lastMessageTime = Time.time;
			aiCar.SetAggressivenessOnBrake(aRecord.aggressivenessOnBrake);
			this.originalBrakingAggressiveness = aRecord.aggressivenessOnBrake;
			aiCar.SetBackCollDist(aRecord.backCollDist);
			aiCar.backToLineIncrement = aRecord.backToLineIncrement;
			aiCar.SetCollisionSideFactor(aRecord.collisionSideFactor);
			aiCar.SetCorneringSpeedFactor(aRecord.corneringSpeedFactor);
			//aRecord.driftingThrottleFactor
			aiCar.SetFrontCollDist(aRecord.frontCollDist);
			aiCar.SetFuelloadPorcentage(aRecord.fuelLoadPercentage);
			aiCar.SetFullAccelMaring(aRecord.fullAccelMargin);
			aiCar.SetHeightMargin(aRecord.heightMargin);
			aiCar.SetHumanError(aRecord.humanError);
			aiCar.jumpThrottleMulpilier = aRecord.jumpThrottleMultiplier;
			aiCar.jumpThrottleTime = aRecord.jumpThrottleTime;
			aiCar.SetLength_Margin(aRecord.lengthMargin);
			aiCar.LookAheadConst = aRecord.lookAheadConstant;
			aiCar.SetLookahead_factor(aRecord.lookAheadFactor);
			aiCar.SetMaxDriftAngle(aRecord.maxDriftAngle);
			aiCar.offTrackThrottleMulpilier = aRecord.offtrackThrottleMultiplier;
			aiCar.SetOvertakeFactor(aRecord.overtakeFactor);
			aiCar.SetOvertakeOffsetIncrementMax(aRecord.overtakeOffsetIncrementMax);
			aiCar.SetOvertakeOffsetIncrementMin(aRecord.overtakeOffsetIncrementMin);
			aiCar.SetOvertakeSpeedDiference(aRecord.overtakeSpeedDifference);
			aiCar.SetShifFactor(aRecord.shiftFactor);
			aiCar.shiftUpFactor = aRecord.shiftUpFactor;
			//aRecord.sideAvoidingFactor
			aiCar.SetSideMargin(aRecord.sideMargin);
			aiCar.SetSide_Margin(	aRecord.SIDE_MARGIN);
			aiCar.SetSpeedSteeringFactor(aRecord.speedSteeringFactor);
			aiCar.SetSteeringDriftFactor(aRecord.steeringDriftFactor);
			aiCar.SetTyrechangePorcentage(aRecord.tyreChangePercentage);
			
			this.originalCorneringSpeed = aRecord.corneringSpeedFactor;
			this.originalOvertakeSpeedDiff = aRecord.overtakeSpeedDifference;
			this.originalOvertakeFactor = aRecord.overtakeFactor;
			this.originalShiftUp = aRecord.shiftUpFactor;
			initSmokes();


			this.aiCar = this.GetComponent<IRDSCarControllerAI>();
			this.aiDriveTrain = this.GetComponent<IRDSDrivetrain>();
			wheels = this.gameObject.GetComponentsInChildren<IRDSWheel>();

			IRDSCameraPosition[] cp = this.GetComponentsInChildren<IRDSCameraPosition>();
			for(int i = 0;i<cp.Length;i++) {
				if(cp[i].gameObject.name=="Roof") {
					Vector3 v = new Vector3(5f,27f,-7.3f);
					cp[i].distanceSides= v;
					cp[i].minFieldOfView = 55;
					cp[i].maxFieldOfView = 72;
					cp[i].fieldOfViewChangeSpeedMultiplier = 2f;
					cp[i].set_rotationDamping_(1000f);
					cp[i].set_heightDamping_(20f);
					cp[i].set_height_(80f);
					cp[i].set_distance_(5f);
					cp[i].sidesDamping = 9f; 
				}
				if(cp[i].gameObject.name=="FrontBumper") {
					Vector3 v = new Vector3(5f,1.21f,9.4f);
					cp[i].distanceSides= v;
					cp[i].minFieldOfView = 55;
					cp[i].maxFieldOfView = 72;
					cp[i].fieldOfViewChangeSpeedMultiplier = 2f;
					cp[i].set_rotationDamping_(1000f);
					cp[i].set_heightDamping_(20f);
					cp[i].set_height_(40f);
					cp[i].set_distance_(5f);
					cp[i].sidesDamping = 9f; 
				}
			}
		}
		return this;
	}
示例#22
0
	public void createDriverDetailsScreen(GameObject aLastScreen,GTDriver aDriver,bool aShowButtons) {
		destroyCarDetailsScreen();
		GameObject g = NGUITools.AddChild(GameObject.Find ("UI Root"),this.prefabDriverDetails.gameObject);
		this.driverDetailsScreen = g.GetComponent<DriverPanel>();
		driverDetailsScreen.initDriver(aDriver);
		if(!aShowButtons) {
		//	carDetailsScreen.disableButtons();
		}
	}
示例#23
0
		public void initDriver(GTDriver aDriver) {
			this.drivers.Add(aDriver);
			aDriver.contract.team = (GTTeam) this;
			aDriver.contract.remainingOnContract = 1;
		}
示例#24
0
		public GTCar getGTCarFromDriver(GTDriver aDriver) {
			int index = indexForDriver(aDriver);
			GTCar car = cars[index];
			return car;
		}
示例#25
0
		public DriverRelationshipRecord relationshipWithDriver(GTDriver aDriver) {
			for(int i = 0;i<driverRelationships.Count;i++) {
				Debug.Log(driverRelationships[i].record.name+" - "+aDriver.name+" "+driverRelationships[i].record.id+" - "+aDriver.id);
				if(driverRelationships[i].record.id==aDriver.id) {
					return driverRelationships[i]; 
				}
			}
			return null;
		}
示例#26
0
		public int indexForDriver(GTDriver aDriver) {
			for(int i = 0;i<drivers.Count;i++) {
				if(drivers[i]==aDriver) {
					return i;
				}
			}
			return -1;
		}
示例#27
0
	public void showChampionshipPoints(GTDriver aDriver) {
		this.nameLabel.text = aDriver.name+" "+ChampionshipSeason.ACTIVE_SEASON.getTeamFromDriver(aDriver).teamName;
		this.prizeInfo.text = aDriver.championshipPoints+"";
	}