コード例 #1
0
ファイル: TrainCar.cs プロジェクト: Beanalby/1GameAMonth14
 protected override void SetNextSection(RailSection next)
 {
     if(rail == null) {
         rail = next; // initial rail
     } else {
         railQueue.Enqueue(next);
     }
     PropagateNextSection(next);
 }
コード例 #2
0
ファイル: TrainCommon.cs プロジェクト: Beanalby/1GameAMonth14
 public void Move()
 {
     if(railPos == -1) {
         /// we're just starting, figure out our initial railPos from
         /// how far we are from the rail
         railPos = (transform.position - rail.transform.position).magnitude;
     }
     railPos += Time.deltaTime * speed;
     Vector3 newPos = rail.GetPosition(railPos);
     if(newPos != transform.position) {
         transform.rotation = Quaternion.LookRotation(newPos - transform.position);
     }
     transform.position = newPos;
     float remainder = rail.GetRemainder(railPos);
     if(remainder > 0) {
         rail = GetNextSection();
         railPos = remainder;
         if(rail == null) {
             Debug.LogError("End of the line!");
             Debug.Break();
         }
     }
 }
コード例 #3
0
ファイル: TrainCommon.cs プロジェクト: Beanalby/1GameAMonth14
 protected abstract void SetNextSection(RailSection next);
コード例 #4
0
ファイル: TrainCommon.cs プロジェクト: Beanalby/1GameAMonth14
 protected void PropagateNextSection(RailSection next)
 {
     if(nextCar != null) {
         nextCar.SetNextSection(next);
     }
 }
コード例 #5
0
ファイル: TrainDriver.cs プロジェクト: Beanalby/1GameAMonth14
 protected override void SetNextSection(RailSection next)
 {
     throw new System.NotImplementedException("Driver shouldn't get its rail set");
 }