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);
    }
Beispiel #2
0
    public TrainCarPerson PopPersonFromLine()
    {
        if (peopleInLine.Count == 0)
        {
            return(null);
        }

        TrainCarPerson person = peopleInLine.Last.Value;

        person.gameObject.SetActive(true);
        peopleInLine.RemoveLast();
        return(person);
    }
Beispiel #3
0
    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);
    }
Beispiel #4
0
 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;
             }
         }
     }
 }