//returns the entire duration of the camera movement. public float GetDuration(Cinematic_Type type) { float dur = 0f; foreach (Camera_Move cMove in sceneCinematics[(int)type]) { dur += cMove.duration; } return dur; }
public void Cinematic(Cinematic_Type type) { if (!hasStarted) { AddNextStep(type); hasStarted = true; } if (mDel != null) { mDel(); } }
public void PlayOutro() { if (levelCinematic != null && levelCinematic.stepsOutro.Count > 0) { //player control handled by gamecontroller topB.gameObject.SetActive(false); downB.gameObject.SetActive(false); rightB.gameObject.SetActive(false); leftB.gameObject.SetActive(false); levelCinematic.Reset(); dCin += levelCinematic.Cinematic; currrentCinematicType = Cinematic_Type.OUTRO; } }
// Use this for initialization void Start() { if (levelCinematic != null && levelCinematic.stepsIntro.Count > 0) { player1.GetComponent<Player>().SetPlayerControl(false); player2.GetComponent<Player>().SetPlayerControl(false); dCin += levelCinematic.Cinematic; currrentCinematicType = Cinematic_Type.INTRO; StartCoroutine(WaitForCinematicCamera(levelCinematic.GetDuration(Cinematic_Type.INTRO))); } }
public void RemoveStep(Cinematic_Type listType, int loc) { if (listType == Cinematic_Type.INTRO) { stepsIntro.RemoveAt(loc); } else if (listType == Cinematic_Type.OUTRO) { stepsOutro.RemoveAt(loc); } }
//calls the next step after previous step is over. IEnumerator Clock(float delay, Cinematic_Type type) { yield return new WaitForSeconds(delay); AddNextStep(type); }
void AddNextStep(Cinematic_Type type) { //Removes the previous step. if (currentStep > 0) { switch (sceneCinematics[(int)type][currentStep - 1].type) { case Movement_Type.WAIT: mDel -= Wait; break; case Movement_Type.MOVELERP: mDel -= MoveLerp; break; case Movement_Type.MOVESLERP: mDel -= MoveSlerp; break; case Movement_Type.SETPOSITION: mDel -= SetPosition; break; case Movement_Type.SETROTATION: mDel -= SetRotation; break; case Movement_Type.END: break; } } if (currentStep >= stepsIntro.Count) { return; } Camera_Move nextStep = sceneCinematics[(int)type][currentStep]; //Select the next step to add. switch (nextStep.type) { case Movement_Type.WAIT: mDel += Wait; break; case Movement_Type.MOVELERP: startTime = Time.time; movementDuration = nextStep.duration; stepStartPOS = new Vector3(transform.position.x, transform.position.y, transform.position.z); stepEndPOS = nextStep.position; endRotation = nextStep.rotation; startRotation = transform.rotation; mDel += MoveLerp; break; case Movement_Type.MOVESLERP: startTime = Time.time; movementDuration = nextStep.duration; stepStartPOS = new Vector3(transform.position.x, transform.position.y, transform.position.z); stepEndPOS = nextStep.position; endRotation = nextStep.rotation; startRotation = transform.rotation; mDel += MoveSlerp; break; case Movement_Type.SETPOSITION: transform.position = nextStep.position; transform.rotation = nextStep.rotation; mDel += SetPosition; break; case Movement_Type.SETROTATION: transform.rotation = nextStep.rotation; mDel += SetRotation; break; case Movement_Type.END: break; } currentStep++; //Delay the next step by current step duration. StartCoroutine(Clock(nextStep.duration, type)); }
//For editor Functions---------// public void SaveFrame(Cinematic_Type listType, int selected, Movement_Type type, float dur, bool isNew) { Camera_Move newStep = new Camera_Move(); newStep.position = transform.position; newStep.rotation = transform.rotation; newStep.duration = dur; newStep.type = type; if (listType == Cinematic_Type.INTRO) { if (isNew) { stepsIntro.Add(newStep); } else { stepsIntro[selected] = newStep; } } else if (listType == Cinematic_Type.OUTRO) { if (isNew) { stepsOutro.Add(newStep); } else { stepsOutro[selected] = newStep; } } }