public override Train CreateTrain(TrainInfo element)
        {
            TrainElement locomotive = locomotivesPool.RealeseObject().GetComponent <TrainElement>();

            locomotive.Position = element.headPosition.position;
            locomotive.Rotation = element.headPosition.rotateDegree;

            Train train = null;

            if (element.type == TypeTrain.Suburban)
            {
                train = new SuburbanTrain(locomotive, element.trainColor, element.fromArrive, element.turnsDelayCount);
            }
            else if (element.type == TypeTrain.Express)
            {
                train = new ExpressTrain(locomotive, element.trainColor, element.fromArrive, element.turnsDelayCount);
            }

            for (int i = 0; i < element.carriagePositions.Count; i++)
            {
                TrainElement carriage = carriagesPool.RealeseObject().GetComponent <TrainElement>();
                train.AddCarriage(carriage, element.carriagePositions[i]);
            }

            return(train);
        }
예제 #2
0
 // --------------- Manage of carriage ---------------------
 public void AddCarriage(TrainElement carriage, StateTrainElement state)
 {
     carriage.SetColor(trainColor);
     carriage.Position = state.position;
     carriage.Rotation = state.rotateDegree;
     head.AddCarriage(carriage);
 }
예제 #3
0
 // -------------- Initialize ------------------
 public Train(TrainElement head, Color color, TileSides from, int rate)
 {
     this.head    = head;
     trainColor   = color;
     fromArrive   = from;
     isEnable     = true;
     clockPerTurn = rate;
     head.SetColor(color);
 }
예제 #4
0
 public virtual void DisconnectBackCarriage()
 {
     if (backTrainElement == null)
     {
         return;
     }
     backTrainElement.DisconnectFrontCarriage();
     backTrainElement = null;
 }
예제 #5
0
 // --------------------- Connection ----------------------
 public virtual void AddCarriage(TrainElement carriage)
 {
     if (backTrainElement != null)
     {
         backTrainElement.AddCarriage(carriage);
     }
     else
     {
         ConnectBackCarriage(carriage);
     }
 }
예제 #6
0
 public SuburbanTrain(TrainElement head, Color color, TileSides from, int rate) : base(head, color, from, rate)
 {
 }
예제 #7
0
 protected override void ConnectFrontCarriage(TrainElement carriage)
 {
     frontTrainElement = carriage;
 }
예제 #8
0
 public virtual void ConnectBackCarriage(TrainElement carriage)
 {
     backTrainElement = carriage;
     carriage.ConnectFrontCarriage(this);
 }
예제 #9
0
 protected virtual void ConnectFrontCarriage(TrainElement carriage)
 {
 }
예제 #10
0
 public ExpressTrain(TrainElement head, Color color, TileSides from, int rate) : base(head, color, from, rate)
 {
 }