public override void OnInspectorGUI() { if (target == null) { return; } this.animation = this.target as ComplexAnimation; this.DrawAnimations(); }
public Charlie(int x, int y) { ObeysGravity = true; IsCollidable = true; _complexAnimation = new ComplexAnimation(); Texture = ContentHelper.LoadTexture("Characters/NPCs/charlie"); CollRectangle = new Rectangle(x, y, 48, 80); SetPosition(new Vector2(x, y)); _complexAnimation.AddAnimationData("still", new ComplexAnimData(1, Texture, new Rectangle(0, 0, 24, 40), 0, 24, 40, 500, 1, true)); AddAnimationToQueue("still"); TMBAW_Game.Dialog.NextDialog += Dialog_NextDialog; }
void DrawAnimation(int index) { if (index < 0 || index >= this.animation.animations.Count) { return; } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); AnimationPattern newPattern = EditorGUILayout.ObjectField(this.animation.animations[index].pattern, typeof(AnimationPattern), false, GUILayout.MinWidth(100)) as AnimationPattern; AnimationFX newAnimation = EditorGUILayout.ObjectField(this.animation.animations[index].animation, typeof(AnimationFX), false, GUILayout.MinWidth(100)) as AnimationFX; float newLife = EditorGUILayout.FloatField(this.animation.animations[index].life, GUILayout.MinWidth(15)); float newDelay = EditorGUILayout.FloatField(this.animation.animations[index].delay, GUILayout.MinWidth(15)); if (newLife < 0) { newLife = 0; } if (newDelay < 0) { newDelay = 0; } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(this.animation, "Undo Inspector (Complex Animation)"); this.animation.animations[index].pattern = newPattern; this.animation.animations[index].animation = newAnimation; this.animation.animations[index].delay = newDelay; this.animation.animations[index].life = newLife; EditorUtility.SetDirty(this.animation); } /* * if (GUILayout.Button("Preview")) * { * if (this.animation.animations[index].pattern) * Debug.Log("Preview of pattern " + this.animation.animations[index].pattern.patternName); * else * Debug.LogWarning("Pattern is missing"); * } */ if (GUILayout.Button("X")) { Undo.RecordObject(this.animation, "Undo Inspector (Complex Animation)"); this.animation.animations.RemoveAt(index); EditorUtility.SetDirty(this.animation); } } GUILayout.EndHorizontal(); }
/// <summary> /// Initializes animation components and resets variables. /// </summary> public static void Initialize() { position = new Vector2(250, 30); animation = new ComplexAnimation() { Scale = 4 }; ComplexAnimData normal = new ComplexAnimData(1, GameWorld.UiSpriteSheet, new Rectangle(), 112, 16, 16, 125, 8, true); animation.AddAnimationData("normal", normal); animation.AddToQueue("normal"); fontBig = ContentHelper.LoadFont("Fonts/x32"); fontSmall = ContentHelper.LoadFont("Fonts/x16"); }
/// <summary> /// Initializes animation components and resets variables. /// </summary> public static void Initialize() { position = new Vector2(30, 30); animation = new ComplexAnimation() { Scale = 4 }; ComplexAnimData normal = new ComplexAnimData(1, GameWorld.UiSpriteSheet, new Rectangle(), 80, 16, 16, 125, 4, true); ComplexAnimData dead = new ComplexAnimData(1000, GameWorld.UiSpriteSheet, new Rectangle(), 96, 16, 16, 125, 4, true); ComplexAnimData poison = new ComplexAnimData(100, GameWorld.UiSpriteSheet, new Rectangle(), 64, 16, 16, 125, 4, true); animation.AddAnimationData("normal", normal); animation.AddAnimationData("dead", dead); animation.AddAnimationData("poison", poison); animation.AddToQueue("normal"); fontBig = ContentHelper.LoadFont("Fonts/x32"); fontSmall = ContentHelper.LoadFont("Fonts/x16"); }
public new static Animation LoadFromFile(string path) { VariantAnimation va = JsonAsset.LoadFromFile <VariantAnimation>(path); if (va != null) { if (va.variants > 0) { // init variant animation stuff return(va); } } ComplexAnimation ca = JsonAsset.LoadFromFile <ComplexAnimation>(path); if (ca != null) { // init complex animation stuff } return(ca); }
public override void populate(ComplexAnimation animation) { // delete old childrens ? float angle = (float)(6.283185307179586476925286766559 / (double)this.childs); this.childContainer = new GameObject(this.patternName); this.childContainer.transform.SetParent(animation.transform); this.childContainer.transform.localPosition = Vector3.zero; for (int i = 0; i < this.childs; ++i) { GameObject child = Instantiate(this.prefab) as GameObject; Vector3 initialPosition = new Vector3((float)Math.Sin(angle * i) * this.circleInitialRange, 0, (float)Math.Cos(angle * i) * this.circleInitialRange); Vector3 finalPosition = new Vector3((float)Math.Sin(angle * i) * this.circleFinalRange, 0, (float)Math.Cos(angle * i) * this.circleFinalRange); child.name = this.patternName + " " + i; child.transform.SetParent(this.childContainer.transform); this.initialPositions.Add(new Vector3(initialPosition.x, initialPosition.y, initialPosition.z)); this.finalPositions.Add(new Vector3(finalPosition.x, finalPosition.y, finalPosition.z)); child.transform.localPosition = initialPosition; this.childrens.Add(child); } }
//public float duration; public abstract void populate(ComplexAnimation animation);