using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class AMCameraSwitcherAction : AMAction { public override string ToString(int codeLanguage, int frameRate) { if (this.endFrame == -1 || !this.hasStartTarget() || this.targetsAreEqual()) { return null; } bool flag = this.cameraFadeType == 5; string text; if (codeLanguage == 0) { text = string.Concat(new object[] { "AMTween.CameraFade (AMTween.Fade.", Enum.GetName(typeof(AMTween.Fade), this.cameraFadeType), ", ", (!flag && !this.still).ToString().ToLower(), ", ", this.getParametersString(codeLanguage), ", AMTween.Hash (\"delay\", ", base.getWaitTime(frameRate, 0f), "f, \"time\", ", this.getTime(frameRate), "f, " }); if (!flag) { text = text + base.getEaseString(codeLanguage) + ", "; } if (this.isReversed()) { text += "\"reversed\", true, "; } if (AMCameraFade.needsTexture(this.cameraFadeType)) { text = text + "\"texture\", AMTween.LoadTexture2D(\"" + this.irisShape.name + "\"), "; } if (!flag) { if (this.startTargetType == 0) { if (this.startCamera) { text = text + "\"camera1\", GameObject.Find(\"" + this.startCamera.gameObject.name + "\").camera, "; } else { text += "\"camera1\", null /* Missing Camera */"; } } else { string text2 = text; text = string.Concat(new object[] { text2, "\"color1\", new Color(", this.startColor.r, "f, ", this.startColor.g, "f, ", this.startColor.b, "f, ", this.startColor.a, "f), " }); } } if (this.endTargetType == 0) { if (this.endCamera) { text = text + "\"camera2\", GameObject.Find(\"" + this.endCamera.gameObject.name + "\").camera"; } else { text += "\"camera2\", null /* Missing Camera */"; } } else { string text2 = text; text = string.Concat(new object[] { text2, "\"color2\", new Color(", this.endColor.r, "f, ", this.endColor.g, "f, ", this.endColor.b, "f, ", this.endColor.a, "f)" }); } if ((!flag && this.startTargetType == 0) || this.endTargetType == 0) { text += ", \"allcameras\", csCameras"; } text += "));"; } else { text = string.Concat(new object[] { "AMTween.CameraFade (AMTween.Fade.", Enum.GetName(typeof(AMTween.Fade), this.cameraFadeType), ", ", (!flag && !this.still).ToString().ToLower(), ", ", this.getParametersString(codeLanguage), ", {\"delay\": ", base.getWaitTime(frameRate, 0f), ", \"time\": ", this.getTime(frameRate), ", " }); if (!flag) { text = text + base.getEaseString(codeLanguage) + ", "; } if (this.isReversed()) { text += "\"reversed\": true, "; } if (AMCameraFade.needsTexture(this.cameraFadeType)) { text = text + "\"texture\": AMTween.LoadTexture2D(\"" + this.irisShape.name + "\"), "; } if (!flag) { if (this.startTargetType == 0) { if (this.startCamera) { text = text + "\"camera1\": GameObject.Find(\"" + this.startCamera.gameObject.name + "\").camera, "; } else { text += "\"camera1\", null /* Missing Camera */"; } } else { string text2 = text; text = string.Concat(new object[] { text2, "\"color1\": Color(", this.startColor.r, ", ", this.startColor.g, ", ", this.startColor.b, ", ", this.startColor.a, "), " }); } } if (this.endTargetType == 0) { if (this.endCamera) { text = text + "\"camera2\", GameObject.Find(\"" + this.endCamera.gameObject.name + "\").camera"; } else { text += "\"camera2\", null /* Missing Camera */"; } } else { string text2 = text; text = string.Concat(new object[] { text2, "\"color2\": Color(", this.endColor.r, ", ", this.endColor.g, ", ", this.endColor.b, ", ", this.endColor.a, ")" }); } if ((!flag && this.startTargetType == 0) || this.endTargetType == 0) { text += ", \"allcameras\", csCameras"; } text += "));"; } return text; } public void execute(int frameRate, float delay, Camera[] allCameras) { if (this.endFrame == -1 || !this.hasTargets() || this.targetsAreEqual()) { return; } float[] array = this.cameraFadeParameters.ToArray(); Hashtable hashtable = new Hashtable(); hashtable.Add("time", this.getTime(frameRate)); hashtable.Add("delay", base.getWaitTime(frameRate, delay)); if (this.easeType == 32) { hashtable.Add("easecurve", base.easeCurve); } else { hashtable.Add("easetype", (AMTween.EaseType)this.easeType); } hashtable.Add("reversed", AMTween.isTransitionReversed(this.cameraFadeType, array)); hashtable.Add("allcameras", allCameras); if (this.startTargetType == 0) { hashtable.Add("camera1", this.startCamera); } else { hashtable.Add("color1", this.startColor); } if (this.endTargetType == 0) { hashtable.Add("camera2", this.endCamera); } else { hashtable.Add("color2", this.endColor); } if (AMCameraFade.needsTexture(this.cameraFadeType)) { hashtable.Add("texture", this.irisShape); } AMTween.CameraFade(this.cameraFadeType, !this.still, array, hashtable); } public string getParametersString(int codeLanguage) { string str = string.Empty; str += ((codeLanguage != 0) ? "[" : "new float[]{"); for (int i = 0; i < this.cameraFadeParameters.Count; i++) { str += this.cameraFadeParameters[i].ToString(); if (codeLanguage == 0) { str += "f"; } if (i <= this.cameraFadeParameters.Count - 2) { str += ", "; } } return str + ((codeLanguage != 0) ? "]" : "}"); } public override int getNumberOfFrames() { return this.endFrame - this.startFrame; } public float getTime(int frameRate) { return (float)this.getNumberOfFrames() / (float)frameRate; } public bool hasTargets() { return this.hasStartTarget() && this.hasEndTarget(); } public bool hasStartTarget() { return this.startTargetType != 0 || this.startCamera; } public bool hasEndTarget() { return this.endFrame != -1 && (this.endTargetType != 0 || this.endCamera); } public bool targetsAreEqual() { return this.startTargetType == this.endTargetType && (this.startTargetType != 0 || !(this.startCamera != this.endCamera)) && (this.startTargetType != 1 || !(this.startColor != this.endColor)); } public string getStartTargetName() { if (this.startTargetType != 0) { return "Color"; } if (this.startCamera) { return this.startCamera.gameObject.name; } return "None"; } public string getEndTargetName() { if (this.endTargetType != 0) { return "Color"; } if (this.endCamera) { return this.endCamera.gameObject.name; } return "None"; } public bool isReversed() { return AMTween.isTransitionReversed(this.cameraFadeType, this.cameraFadeParameters.ToArray()); } public override AnimatorTimeline.JSONAction getJSONAction(int frameRate) { if (this.endFrame == -1 || !this.hasTargets() || this.targetsAreEqual()) { return null; } AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction(); jsonaction.method = "camerafade"; jsonaction.delay = base.getWaitTime(frameRate, 0f); jsonaction.time = this.getTime(frameRate); base.setupJSONActionEase(jsonaction); jsonaction.ints = new int[] { this.cameraFadeType, this.startTargetType, this.endTargetType }; List list = new List(); List list2 = new List(); if (this.startTargetType == 0) { list.Add(this.startCamera.gameObject.name); list2.Add(null); } else { AnimatorTimeline.JSONColor jsoncolor = new AnimatorTimeline.JSONColor(); jsoncolor.setValue(this.startColor); list2.Add(jsoncolor); list.Add(null); } if (this.endTargetType == 0) { list.Add(this.endCamera.gameObject.name); list2.Add(null); } else { AnimatorTimeline.JSONColor jsoncolor2 = new AnimatorTimeline.JSONColor(); jsoncolor2.setValue(this.endColor); list2.Add(jsoncolor2); list.Add(null); } jsonaction.strings = list.ToArray(); jsonaction.colors = list2.ToArray(); jsonaction.bools = new bool[] { this.isReversed(), !this.still }; if (AMCameraFade.needsTexture(this.cameraFadeType)) { jsonaction.stringsExtra = new string[] { this.irisShape.name }; } jsonaction.floats = this.cameraFadeParameters.ToArray(); return jsonaction; } public int endFrame; public int cameraFadeType; public List cameraFadeParameters; public Texture2D irisShape; public bool still; public int startTargetType; public int endTargetType; public Camera startCamera; public Camera endCamera; public Color startColor; public Color endColor; }