Exemple #1
0
 void CopyListToSpawnedCar(PastSelfForward pSelfForward)
 {
     if (RaceManager.instance.currentLap == 2)
     {
         pSelfForward.forwardRecordings = new List <PastSelfRecording>(pastSelvesLap1);
     }
     else if (RaceManager.instance.currentLap == 3)
     {
         pSelfForward.forwardRecordings = new List <PastSelfRecording>(pastSelvesLap2);
     }
     else if (RaceManager.instance.currentLap == 4)
     {
         pSelfForward.forwardRecordings = new List <PastSelfRecording>(pastSelvesLap3);
     }
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        //if (isRecording)
        //{
        //   if (thePlayer.position != lastPastSelfRecording.carBodyTransform || thePlayer.rotation != lastPastSelfRecording.carBodyRotation)
        //   {
        //      var newPastSelf = new PastSelfRecording(thePlayer.position, thePlayer.rotation,
        //         frontRightWheel.rotation, frontLeftWheel.rotation, backRightWheel.rotation, backLeftWheel.rotation);
        //      pastSelves.Add(newPastSelf);

        //      lastPastSelfRecording = newPastSelf;
        //   }
        //}


        if (RaceManager.instance.currentLap <= RaceManager.instance.maxLaps)
        {
            if (canSpawn)
            {
                canSpawn = false;

                GameObject spawnCar;

                if (RaceManager.instance.currentLap == 2)
                {
                    spawnCar = pastSelfCarLap1;
                }
                else if (RaceManager.instance.currentLap == 3)
                {
                    spawnCar = pastSelfCarLap2;
                }
                else if (RaceManager.instance.currentLap == 4)
                {
                    spawnCar = pastSelfCarLap3;
                }
                else
                {
                    spawnCar = pastSelfCarLap1;
                }


                var             forwardCar  = Instantiate(spawnCar, SpawnPoint.position, Quaternion.identity);
                var             backwardCar = Instantiate(spawnCar, SpawnPoint.position, Quaternion.identity);
                PastSelfForward pSForward   = forwardCar.GetComponent <PastSelfForward>();
                PastSelfForward pSBackward  = backwardCar.GetComponent <PastSelfForward>();


                if (pSForward)
                {
                    pSForward.isMovingForwardInTime = true;
                    //pSForward.forwardRecordings = new List<PastSelfRecording>(pastSelvesLap1);
                    CopyListToSpawnedCar(pSForward);
                }

                if (pSBackward)
                {
                    pSBackward.isMovingForwardInTime = false;
                    //pSBackward.forwardRecordings = new List<PastSelfRecording>(pastSelvesLap1);
                    CopyListToSpawnedCar(pSBackward);
                }
            }
        }
    }