public void PlayAttackNumber(EffectType type, string animationName, string animationStr, int val) { delay = AttackNumAnimPosDelayTime; duration = AttackNumAnimPosDurationTime; val = Mathf.Abs(val); int length = val.ToString().Length + 1; // Scale 0.5f float scaleFactor = 1.0f; if (type == EffectType.NUMBER_GREEN || type == EffectType.NUMBER_GRAY) { scaleFactor = 0.5f; } float singleWidth = numberPreb.width; singleWidth *= scaleFactor; float width = length * singleWidth; if (!animationName.Equals("GreenPlus")) { PackedSprite number = GameObject.Instantiate(numberPreb) as PackedSprite; number.width *= scaleFactor; number.height *= scaleFactor; number.transform.parent = _gobjCrit.transform; number.transform.localPosition = new Vector3(-width / 2, 0, 0); number.transform.localScale = Vector3.one; number.SetAnchor(SpriteRoot.ANCHOR_METHOD.MIDDLE_LEFT); number.PlayAnim(animationName); FadeSpriteAlpha.Do(number, EZAnimation.ANIM_MODE.To, Color.clear, EZAnimation.linear, AnimAlphaDurationTime, AnimAlphaDelayTime, null, DestroyEffectObj); AnimatePosition.Do(_gobjCrit.gameObject, EZAnimation.ANIM_MODE.To, _gobjCrit.transform.localPosition + new Vector3(0, AttackNumRiseUpHeight, 0), EZAnimation.linear, duration, delay, null, DestroyEffectObj); } for (int i = 0; i < length - 1; i++) { int currNum = val / (int)Mathf.Pow(10, length - 2 - i) % 10; PackedSprite number2 = GameObject.Instantiate(numberPreb) as PackedSprite; number2.width *= scaleFactor; number2.height *= scaleFactor; number2.transform.parent = _gobjCrit.transform; number2.transform.localPosition = new Vector3(-width / 2 + singleWidth * (i + 1), 0, 0); number2.transform.localScale = Vector3.one; number2.SetAnchor(SpriteRoot.ANCHOR_METHOD.MIDDLE_LEFT); number2.PlayAnim(animationStr + currNum); FadeSpriteAlpha.Do(number2, EZAnimation.ANIM_MODE.To, Color.clear, EZAnimation.linear, AnimAlphaDurationTime, AnimAlphaDelayTime, null, null); AnimatePosition.Do(_gobjCrit.gameObject, EZAnimation.ANIM_MODE.To, _gobjCrit.transform.localPosition + new Vector3(0, AttackNumRiseUpHeight, 0), EZAnimation.linear, duration, delay, null, DestroyEffectObj); } }
/// <summary> /// Waits for the Application Launcher before beginning initialization /// </summary> /// <returns></returns> System.Collections.IEnumerator WaitOnAppLauncher() { Log.Debug("Waiting on AppLauncher..."); while (!ApplicationLauncher.Ready) { yield return(null); } Log.Verbose("Retrieving animation sheet."); var sheet = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.sheet_app.png", false, false); if (sheet == null) { Log.Error("Failed to locate embedded app sheet texture!"); // well ... without it we're sunk. Something is better than // nothing. We can't let the stock behaviour fail Log.Warning("Creating dummy sprite texture"); sheet = new Texture2D(38, 38, TextureFormat.ARGB32, false); sheet.SetPixels32(Enumerable.Repeat((Color32)Color.clear, 38 * 38).ToArray()); sheet.Apply(); } Log.Verbose("Setting up sprite"); sprite = PackedSprite.Create("ScienceAlert.Button.Sprite", Vector3.zero); sprite.SetMaterial(new Material(Shader.Find("Sprite/Vertex Colored")) { mainTexture = sheet }); sprite.renderer.sharedMaterial.mainTexture.filterMode = FilterMode.Point; sprite.Setup(38f, 38f); sprite.SetFramerate(Settings.Instance.StarFlaskFrameRate); sprite.SetAnchor(SpriteRoot.ANCHOR_METHOD.UPPER_LEFT); sprite.gameObject.layer = LayerMask.NameToLayer("EzGUI_UI"); // normal state Log.Verbose("Setting up normal animation"); UVAnimation normal = new UVAnimation() { name = "Unlit", loopCycles = 0, framerate = Settings.Instance.StarFlaskFrameRate }; normal.BuildUVAnim(sprite.PixelCoordToUVCoord(9 * 38, 8 * 38), sprite.PixelSpaceToUVSpace(38, 38), 1, 1, 1); // animated state Log.Verbose("Setting up star flask animation"); UVAnimation anim = new UVAnimation() { name = "Spin", loopCycles = -1, framerate = Settings.Instance.StarFlaskFrameRate }; anim.BuildWrappedUVAnim(new Vector2(0, sprite.PixelCoordToUVCoord(0, 38).y), sprite.PixelSpaceToUVSpace(38, 38), 100); // add animations to button sprite.AddAnimation(normal); sprite.AddAnimation(anim); sprite.PlayAnim("Unlit"); Log.Verbose("Creating mod button..."); button = ApplicationLauncher.Instance.AddModApplication( OnToggle, OnToggle, () => { }, () => { }, () => { }, () => { }, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, sprite); GameEvents.onGUIApplicationLauncherUnreadifying.Add(AppLauncherUnreadifying); Log.Debug("AppLauncherInterface: Button transform = {0}", button.transform.position.ToString()); Log.Verbose("AppLauncherInterface ready"); }