public bool Add(TrainCarPerson person) { if (people.Count >= peopleXPositions.Count) { return(false); } person.transform.parent = transform; person.transform.localPosition = new Vector3(peopleXPositions[people.Count], peopleYPosition, 0); people.Add(person); return(true); }
public TrainCarPerson PopPersonFromLine() { if (peopleInLine.Count == 0) { return(null); } TrainCarPerson person = peopleInLine.Last.Value; person.gameObject.SetActive(true); peopleInLine.RemoveLast(); return(person); }
bool AddPersonToLine() { if (peopleInLine.Count >= maxLineLength) { return(false); } SpenderType nextPersonSpenderType = SpenderTypeOfNextPersonInLine(); TrainCarPerson person = Instantiate(personPrefab, transform); person.spenderType = nextPersonSpenderType; person.desriedMoneyInWallet = DesiredMoneyInWalletForSpenderType(nextPersonSpenderType); person.moneyInBank = MoneyInBankForSpenderType(nextPersonSpenderType); person.gameObject.SetActive(false); peopleInLine.AddLast(person); return(true); }
public void LoadTrain() { foreach (var car in cars) { while (numberOfPeople > 0) { TrainCarPerson person = peopleManager.PeekPersonInLine(); if (person != null) { if (!car.Add(person)) { break; } peopleManager.PopPersonFromLine(); numberOfPeople -= 1; } else { break; } } } }