123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- 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<string> list = new List<string>();
- List<AnimatorTimeline.JSONColor> list2 = new List<AnimatorTimeline.JSONColor>();
- 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<float> 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;
- }
|