void Start() { if (instance == null) { instance = this; } else { Destroy(gameObject); } if (!car) { car = FindObjectOfType <CND.Car.ArcadeCarController>().GetComponent <CarGhost>(); state = car.GetComponent <CND.Car.CarStateManager>(); } oldGhost = null; newGhost = null; GameManager.instance.ResetVar(true); if (practise || GameManager.instance.practise) { AllowMoves(); } else { StartCoroutine(StartCountDown()); } }
/// <summary> /// Fill the state with the current info of a CarGhost /// </summary> /// <param name="s"></param> /// <param name="c"></param> void FillState(State s, CarGhost c) { s.carPosition = c.transform.position; s.carRotation = c.transform.rotation; s.wheelsPosition = new List <Vector3>(); s.wheelsRotation = new List <Quaternion>(); //Save relative position of wheels foreach (Transform t in c.wheels) { s.wheelsPosition.Add(t.localPosition); s.wheelsRotation.Add(t.localRotation); } s.boost = c.particles[0].isPlaying; }
public void StartRecording(CarGhost target, int maxStatesStored) { isPlaying = false; recordTime = Time.realtimeSinceStartup; targetCarGhost = target; lastRecordedStateIndex = 0; states = new State[maxStatesStored]; for (int i = 0; i < states.Length; i++) { states[i] = new State(); } State firstState = states[0]; firstState.timeSinceGhostStart = 0; FillState(firstState, targetCarGhost); currentIndexRecorded = 1; isRecording = true; }
/// <summary> /// Wrapper for recording target status on a ghost. /// </summary> public void StartRecording(Ghost g, CarGhost target) { g.StartRecording(target, maxStatesStored); }