/// <summary> /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class. /// </summary> /// <param name="singleAnimation">The single animation.</param> /// <param name="animation">The AnimationUI component.</param> /// <param name="dependencyProperty">The dependency property to animate.</param> /// <param name="scene">The associated scene.</param> public SingleAnimationGameAction(SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty, Scene scene = null) : base("SingleAnimationGameAction" + instances++, scene) { this.animation = animation; this.singleAnimation = singleAnimation; this.dependencyProperty = dependencyProperty; }
public void CloseLastOpenUiElement() { Debug.Log("Closing last opened UI element"); if (openUI.Count > 0) { AnimationUI lastElement = openUI.Pop(); if (lastElement == null) { CloseLastOpenUiElement(); return; } else { Hide(lastElement); } } else { if (!GameManager.instance.PlaySection(GameManager.instance.landingSection)) { Debug.Log("Exiting the app as expected with the 'back' button"); #if UNITY_EDITOR OpenConfigMenu(); #else AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity"); activity.Call <bool>("moveTaskToBack", true); #endif } } }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundTransform = foregroundEntity.FindComponent <Transform2D>(); this.foregroundAnimation = foregroundEntity.FindComponent <AnimationUI>(); Entity bulletEntity = Owner.FindChild("BulletEntity"); this.bulletTransform = bulletEntity.FindComponent <Transform2D>(); this.bulletAnimation = bulletEntity.FindComponent <AnimationUI>(); this.textControl = Owner.FindChild("TextEntity").FindComponent <TextControl>(); if (this.on) { this.bulletTransform.X = DefaultOffset; this.foregroundTransform.XScale = DefaultOffset; this.textControl.Text = this.onText; } else { this.bulletTransform.X = 0; this.foregroundTransform.XScale = 0; this.textControl.Text = this.offText; } }
/// <summary> /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class. /// </summary> /// <param name="singleAnimation">The single animation.</param> /// <param name="animation">The AnimationUI component.</param> /// <param name="dependencyProperty">The dependency property to animate.</param> /// <param name="scene">The associated scene.</param> public SingleAnimationGameAction(SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty, Scene scene = null) : base("SingleAnimationGameAction" + instances++, scene) { this.animation = animation; this.singleAnimation = singleAnimation; this.dependencyProperty = dependencyProperty; }
/// <summary> /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class. /// </summary> /// <param name="parent">The parent task.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animation">The AnimationUI component.</param> /// <param name="dependencyProperty">The dependency property to animate.</param> public SingleAnimationGameAction(IGameAction parent, SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty) : base(parent, "SingleAnimationGameAction" + instances++) { this.animation = animation; this.singleAnimation = singleAnimation; this.dependencyProperty = dependencyProperty; }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.textEntity = Owner.FindChild("TextEntity"); this.Animation = this.textEntity.FindComponent<AnimationUI>(); }
/// <summary> /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class. /// </summary> /// <param name="parent">The parent task.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animation">The AnimationUI component.</param> /// <param name="dependencyProperty">The dependency property to animate.</param> public SingleAnimationGameAction(IGameAction parent, SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty) : base(parent, "SingleAnimationGameAction" + instances++) { this.animation = animation; this.singleAnimation = singleAnimation; this.dependencyProperty = dependencyProperty; }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.textEntity = Owner.FindChild("TextEntity"); this.Animation = this.textEntity.FindComponent <AnimationUI>(); }
public Insect(int type, float speed, int score, string spriteName) { m_Type = type; m_Speed = speed; m_Score = score; m_SpriteName = spriteName; int x = WaveServices.Random.Next(0, 768); string spritePath = m_SpriteName + ".wpkk"; string spriteMap = m_SpriteName + ".xml"; m_Entity = new Entity() .AddComponent( new Transform2D() { Origin = Vector2.Center, X = x, Y = 0, }) .AddComponent(new Sprite(spritePath)) .AddComponent(Animation2D.Create <TexturePackerGenericXml> (spriteMap) .Add("Run", new SpriteSheetAnimationSequence() { First = 2, Length = 2, FramesPerSecond = 10 }) .Add("Die", new SpriteSheetAnimationSequence() { First = 1, Length = 1, FramesPerSecond = 5 }) ) .AddComponent(new AnimationUI()) .AddComponent(new TouchGestures() { EnabledGestures = SupportedGesture.Translation }) .AddComponent(new RectangleCollider()) .AddComponent(new InsectBehavior()) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Debug)); var move = new SingleAnimation(0f, WaveServices.Platform.ScreenHeight, 1f / m_Speed, EasingFunctions.Cubic); AnimationUI animation = m_Entity.FindComponent <AnimationUI>(); animation.BeginAnimation(Transform2D.YProperty, move); var anim2D = m_Entity.FindComponent <Animation2D>(); anim2D.Play(true); var insectBehavior = m_Entity.FindComponent <InsectBehavior> (); insectBehavior.SetState(InsectBehavior.AnimState.Run); }
public bool Hide(AnimationUI uiElement) { if (openUI.Contains(uiElement)) { Debug.LogError("Trying to close an UI Element (" + uiElement + ") was not the las opened. This can not happen."); return(false); } uiElement.Hide(); return(true); }
protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera") { BackgroundColor = Color.Black, ClearFlags = ClearFlags.DepthAndStencil, }; camera2d.BackgroundColor = Color.Black; EntityManager.Add(camera2d); Entity logo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 227, Origin = Vector2.Center, DrawOrder = 0.1f }) .AddComponent(new Sprite("Content/DeepSpace_logo.wpk")) .AddComponent(new AnimationUI()) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); this.labelAnimation = logo.FindComponent <AnimationUI>(); this.EntityManager.Add(logo); var button = new Button() { Margin = new Thickness(0, 657, 0, 0), HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top, Text = string.Empty, IsBorder = false, BackgroundImage = "Content/PressStart.wpk", PressedBackgroundImage = "Content/PressStart.wpk" }; button.Click += (o, e) => { var gameScene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene <GamePlayScene>(); gameScene.State = GameState.Game; WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f))); ////WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f))); }; button.Entity.AddComponent(new AnimationUI()); this.playAnimation = button.Entity.FindComponent <AnimationUI>(); this.EntityManager.Add(button); this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back); this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.textControl = Owner.FindChild("TextEntity").FindComponent <TextControl>(); this.textBeforeCursor = this.textControl.Text; Entity cursorEntity = Owner.FindChild("CursorEntity"); this.cursorTransform = cursorEntity.FindComponent <Transform2D>(); this.cursorAnimation = cursorEntity.FindComponent <AnimationUI>(); }
public bool Show(AnimationUI uiElement) { if (openUI.Contains(uiElement)) { Debug.LogWarning("Trying to open an UI element (" + uiElement + ") that already is opened. This can not happen"); return(false); } uiElement.Show(); openUI.Push(uiElement); return(true); }
protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera") { BackgroundColor = Color.Black, ClearFlags = ClearFlags.DepthAndStencil, }; camera2d.BackgroundColor = Color.Black; EntityManager.Add(camera2d); Entity logo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 227, Origin = Vector2.Center, DrawOrder = 0.1f }) .AddComponent(new Sprite("Content/DeepSpace_logo.wpk")) .AddComponent(new AnimationUI()) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); this.labelAnimation = logo.FindComponent<AnimationUI>(); this.EntityManager.Add(logo); var button = new Button() { Margin = new Thickness(0, 657, 0, 0), HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top, Text = string.Empty, IsBorder = false, BackgroundImage = "Content/PressStart.wpk", PressedBackgroundImage = "Content/PressStart.wpk" }; button.Click += (o, e) => { var gameScene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene<GamePlayScene>(); gameScene.State = GameState.Game; WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f))); ////WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f))); }; button.Entity.AddComponent(new AnimationUI()); this.playAnimation = button.Entity.FindComponent<AnimationUI>(); this.EntityManager.Add(button); this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back); this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic); }
/// <summary> /// Initializes a new instance of the <see cref="Squid" /> class. /// </summary> /// <param name="positionY">The position Y.</param> public Squid(float positionY) { this.initialPosY = positionY; this.gamePlayPosY = WaveServices.ViewportManager.BottomEdge + 50; this.entity = new Entity("SquidEntity") .AddComponent(new Transform2D() { Origin = new Vector2(0.5f, 0f), X = WaveServices.ViewportManager.VirtualWidth / 2, Y = this.gamePlayPosY, DrawOrder = 0.3f, }) .AddComponent(new AnimationUI()) .AddComponent(new SquidBehavior()) .AddComponent(new Sprite(Directories.TexturePath + "squidSpriteSheet.wpk")) .AddComponent(Animation2D.Create <TexturePackerGenericXml>(Directories.TexturePath + "squidSpriteSheet.xml") .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 30, FramesPerSecond = 30 })) .AddComponent(new PerPixelCollider(Directories.TexturePath + "squidCollider.wpk", 0.5f)) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); // Cached this.transform = this.entity.FindComponent <Transform2D>(); this.animation2D = this.entity.FindComponent <Animation2D>(); this.direction = -Vector2.UnitY; this.animation = this.entity.FindComponent <AnimationUI>(); // Bubble this.entity.AddChild(new Entity("bubblesParticle") .AddComponent(new Transform2D() { LocalY = 210, }) .AddComponent(ParticleFactory.CreateBubbleParticles()) .AddComponent( new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk", DefaultLayers.Additive))) .AddComponent(new ParticleSystemRenderer2D("bubblesParticle"))); // Cached this.particleSystem = this.entity.FindChild("bubblesParticle").FindComponent <ParticleSystem2D>(); // Animations this.appearAnim = new SingleAnimation(gamePlayPosY, this.initialPosY, TimeSpan.FromSeconds(1.5f), EasingFunctions.Cubic); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.textControl = this.Owner.FindChild("TextEntity").FindComponent <TextControl>(); this.textBeforeCursor = this.textControl.Text; Entity cursorEntity = this.Owner.FindChild("CursorEntity"); this.cursorTransform = cursorEntity.FindComponent <Transform2D>(); this.cursorAnimation = cursorEntity.FindComponent <AnimationUI>(); this.imageControl = this.Owner.FindChild("ImageEntity").FindComponent <ImageControl>(); this.imageControl.Width = this.Panel.Width; this.imageControl.Height = this.Panel.Height; }
/// <summary> /// Initializes a new instance of the <see cref="Squid" /> class. /// </summary> /// <param name="positionY">The position Y.</param> public Squid(float positionY) { this.initialPosY = positionY; this.gamePlayPosY = WaveServices.ViewportManager.BottomEdge + 50; this.entity = new Entity("SquidEntity") .AddComponent(new Transform2D() { Origin = new Vector2(0.5f, 0f), X = WaveServices.ViewportManager.VirtualWidth / 2, Y = this.gamePlayPosY, DrawOrder = 0.3f, }) .AddComponent(new AnimationUI()) .AddComponent(new SquidBehavior()) .AddComponent(new Sprite(Directories.TexturePath + "squidSpriteSheet.wpk")) .AddComponent(Animation2D.Create<TexturePackerGenericXml>(Directories.TexturePath + "squidSpriteSheet.xml") .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 30, FramesPerSecond = 30 })) .AddComponent(new PerPixelCollider(Directories.TexturePath + "squidCollider.wpk", 0.5f)) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); // Cached this.transform = this.entity.FindComponent<Transform2D>(); this.animation2D = this.entity.FindComponent<Animation2D>(); this.direction = -Vector2.UnitY; this.animation = this.entity.FindComponent<AnimationUI>(); // Bubble this.entity.AddChild(new Entity("bubblesParticle") .AddComponent(new Transform2D() { LocalY = 210, }) .AddComponent(ParticleFactory.CreateBubbleParticles()) .AddComponent( new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk", DefaultLayers.Additive))) .AddComponent(new ParticleSystemRenderer2D("bubblesParticle"))); // Cached this.particleSystem = this.entity.FindChild("bubblesParticle").FindComponent<ParticleSystem2D>(); // Animations this.appearAnim = new SingleAnimation(gamePlayPosY, this.initialPosY, TimeSpan.FromSeconds(1.5f), EasingFunctions.Cubic); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.imageCheckedEntity = this.Owner.FindChild("ImageCheckedEntity"); this.imageCheckedTransform = this.imageCheckedEntity.FindComponent <Transform2D>(); this.Animation = this.imageCheckedEntity.FindComponent <AnimationUI>(); // Initial configuration if (this.isChecked) { this.imageCheckedTransform.Opacity = 1.0f; } else { this.imageCheckedTransform.Opacity = 0.0f; } }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity bulletEntity = Owner.FindChild("BulletEntity"); this.bulletTransform = bulletEntity.FindComponent <Transform2D>(); this.bulletImage = bulletEntity.FindComponent <ImageControl>(); this.bulletImage.Width = DefaultSliderWeight; this.bulletImage.Height = DefaultSliderWeight; Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundImage = foregroundEntity.FindComponent <ImageControl>(); this.foregroundTransform = foregroundEntity.FindComponent <Transform2D>(); this.backgroundImage = Owner.FindChild("BackgroundEntity").FindComponent <ImageControl>(); Entity textEntity = Owner.FindChild("TextEntity"); this.textControl = textEntity.FindComponent <TextControl>(); this.textTransform = textEntity.FindComponent <Transform2D>(); this.animation = textEntity.FindComponent <AnimationUI>(); // Default parameters this.UpdateOrientation(); // Initialization value switch (this.orientation) { case Orientation.Vertical: float result = this.maximunOffset * (this.value - this.minimum) / this.difference; this.bulletTransform.Y = -result; this.foregroundTransform.YScale = result; break; case Orientation.Horizontal: this.bulletTransform.X = this.maximunOffset * (this.value - this.minimum) / this.difference; this.foregroundTransform.XScale = this.bulletTransform.X; break; } }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundImage = foregroundEntity.FindComponent <ImageControl>(); this.foregroundTransform = foregroundEntity.FindComponent <Transform2D>(); this.foregroundImage.Height = this.Panel.Height; this.foregroundImage.Width = 1; this.foregroundTransform.XScale = this.Panel.Width * (this.value - this.minimum) / this.difference; this.backgroundImage = Owner.FindChild("BackgroundEntity").FindComponent <ImageControl>(); this.backgroundImage.Width = this.Panel.Width; this.backgroundImage.Height = this.Panel.Height; this.animation = foregroundEntity.FindComponent <AnimationUI>(); }
protected override void Update(TimeSpan gamTime) { // Touch var touch = this.Owner.FindComponent <TouchGestures>(); touch.TouchPressed += (s, o) => { this.currentState = AnimState.Die; }; if (this.Owner.FindComponent <Transform2D> ().Y >= 1280) { this.currentState = AnimState.Destroy; } if (currentState == AnimState.Die) { // display the die sprite anim2D.CurrentAnimation = "Die"; trans2D.Effect = SpriteEffects.FontSprite; anim2D.Play(); this.Owner.RemoveComponent <AnimationUI> (); // play animation blur var dieing = new SingleAnimation(1f, 0f, 0.8f, EasingFunctions.Cubic); this.Owner.AddComponent(new AnimationUI()); animUI = this.Owner.FindComponent <AnimationUI>(); animUI.BeginAnimation(Transform2D.OpacityProperty, dieing); currentState = AnimState.BeforeDesTroy; } if (currentState == AnimState.BeforeDesTroy && this.trans2D.Opacity == 0) { currentState = AnimState.Destroy; } if (currentState == AnimState.Destroy) { this.EntityManager.Remove(this.Owner); } }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); // [SerializedObject]が表示される AnimationUI _target = target as AnimationUI; /* これだとInspectorで変更した値が更新されない * _target.isPlay = EditorGUILayout.Toggle("再生", _target.isPlay); * _target.isForward = EditorGUILayout.Toggle("再生/逆再生", _target.isForward); * _target.aniTarget = (RectTransform)EditorGUILayout.ObjectField("ターゲット",_target.aniTarget, typeof(RectTransform)); * _target.aniCurve = EditorGUILayout.CurveField("カーブ", _target.aniCurve); * _target.aniLength = EditorGUILayout.FloatField("再生時間", _target.aniLength); * _target.aniPlayType = (AnimationBase.PlayType)EditorGUILayout.EnumPopup("再生タイプ", _target.aniPlayType);*/ serializedObject.Update(); EditorGUILayout.PropertyField(_isPlay); EditorGUILayout.PropertyField(_isForward); EditorGUILayout.PropertyField(_aniTarget); EditorGUILayout.PropertyField(_aniLength); EditorGUILayout.PropertyField(_aniCurve); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundImage = foregroundEntity.FindComponent<ImageControl>(); this.foregroundTransform = foregroundEntity.FindComponent<Transform2D>(); this.foregroundImage.Height = this.Panel.Height; this.foregroundImage.Width = 1; this.foregroundTransform.XScale = this.Panel.Width * (this.value - this.minimum) / this.difference; this.backgroundImage = Owner.FindChild("BackgroundEntity").FindComponent<ImageControl>(); this.backgroundImage.Width = this.Panel.Width; this.backgroundImage.Height = this.Panel.Height; this.animation = foregroundEntity.FindComponent<AnimationUI>(); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.BackgroundColor = Color.White; EntityManager.Add(camera2d); // Sonic Button spankerButton = new Button() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(40, 500, 0, 0), BackgroundImage = "Content/spanker.wpk", PressedBackgroundImage = "Content/spankerPressed.wpk", }; spankerButton.Entity.AddComponent(new AnimationUI()); this.spankerAnimation = spankerButton.Entity.FindComponent<AnimationUI>(); spankerButton.Click += (s, o) => { WaveServices.GetService<AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Spanker"); }; EntityManager.Add(spankerButton); // Link Button colonelButton = new Button() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(288, 500, 0, 0), BackgroundImage = "Content/colonel.wpk", PressedBackgroundImage = "Content/colonelPressed.wpk", }; colonelButton.Entity.AddComponent(new AnimationUI()); this.colonelAnimation = colonelButton.Entity.FindComponent<AnimationUI>(); colonelButton.Click += (s, o) => { WaveServices.GetService<AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Colonel"); }; EntityManager.Add(colonelButton); // Mario Button fuzzButton = new Button() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(536, 500, 0, 0), BackgroundImage = "Content/fuzz.wpk", PressedBackgroundImage = "Content/fuzzPressed.wpk", }; fuzzButton.Entity.AddComponent(new AnimationUI()); this.fuzzAnimation = fuzzButton.Entity.FindComponent<AnimationUI>(); fuzzButton.Click += (s, o) => { WaveServices.GetService<AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Fuzz"); }; EntityManager.Add(fuzzButton); this.showSpanker = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); this.showColonel = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); this.showFuzz = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); }
/// <summary> /// Creates the single animation action. /// </summary> /// <param name="scene">The scene.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animationUI">The animation UI.</param> /// <param name="dependencyProperty">The dependency property.</param> /// <returns>The action</returns> public static IGameAction CreateSingleAnimationGameAction(this Scene scene, SingleAnimation singleAnimation, AnimationUI animationUI, DependencyProperty dependencyProperty) { return new SingleAnimationGameAction(singleAnimation, animationUI, dependencyProperty, scene); }
/// <summary> /// And play a single animation action. /// </summary> /// <param name="parent">The parent.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animationUI">The animation UI.</param> /// <param name="dependencyProperty">The dependency property.</param> /// <returns>The action</returns> public static IGameAction AndPlaySingleAnimation(this IGameAction parent, SingleAnimation singleAnimation, AnimationUI animationUI, DependencyProperty dependencyProperty) { return new SingleAnimationGameAction(parent, singleAnimation, animationUI, dependencyProperty); }
public JellyFish(JellyFishType type, Vector2 position, bool rightAnimation = true) { this.entity = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = position.X, Y = position.Y, DrawOrder = 0.3f, }) .AddComponent(new AnimationUI()); // Cached this.animation = this.entity.FindComponent <AnimationUI>(); string textureName, colliderName; switch (type) { case JellyFishType.Big: textureName = "jellyFishSpriteSheet"; colliderName = "jellyFishCollider.wpk"; break; case JellyFishType.Little: textureName = "jellyFishLittleSpriteSheet"; colliderName = "jellyFishLittleCollider.wpk"; break; default: textureName = "jellyFishSpriteSheet"; colliderName = "jellyFishCollider.wpk"; break; } this.entity.AddComponent(new PerPixelCollider(Directories.TexturePath + colliderName, 0.5f) { IsGlobalAsset = true }); this.entity.AddComponent(new Sprite(Directories.TexturePath + string.Format("{0}.wpk", textureName)) { IsGlobalAsset = true }); this.entity.AddComponent(Animation2D.Create <TexturePackerGenericXml>(Directories.TexturePath + string.Format("{0}.xml", textureName)) .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 40, FramesPerSecond = 30 })); this.entity.AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); this.entity.FindComponent <Animation2D>().Play(true); // Animations float offset = 80; this.leftAnim = new SingleAnimation(position.X + offset, position.X, TimeSpan.FromSeconds(3)); this.leftAnim.Completed += (s, o) => { this.animation.BeginAnimation(Transform2D.XProperty, this.rightAnim); }; this.rightAnim = new SingleAnimation(position.X, position.X + offset, TimeSpan.FromSeconds(3)); this.rightAnim.Completed += (s, o) => { this.animation.BeginAnimation(Transform2D.XProperty, this.leftAnim); }; if (rightAnimation) { this.animation.BeginAnimation(Transform2D.XProperty, this.rightAnim); } else { this.animation.BeginAnimation(Transform2D.XProperty, this.leftAnim); } this.Collider = this.entity.FindComponent <Collider2D>(false); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.BackgroundColor = Color.CornflowerBlue; EntityManager.Add(camera2d); //Background Entity background = new Entity() .AddComponent(new Transform2D() { ////X = WaveServices.ViewportManager.LeftEdge, ////Y = WaveServices.ViewportManager.TopEdge, ////XScale = (WaveServices.ViewportManager.ScreenWidth / 768) / WaveServices.ViewportManager.RatioX, ////YScale = (WaveServices.ViewportManager.ScreenHeight / 1024) / WaveServices.ViewportManager.RatioY, DrawOrder = 1, }) .AddComponent(new Sprite(Directories.TexturePath + "background.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.Opaque)) .AddComponent(new StretchBehavior()); EntityManager.Add(background); // WaveLogo Entity waveLogo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = WaveServices.ViewportManager.TopEdge + 90, Origin = Vector2.Center }) .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "waveLogo")) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Alpha)); EntityManager.Add(waveLogo); // Logo Image logo = new Image(Directories.TexturePath + "largeLogo.wpk") { Margin = new Thickness(0, WaveServices.ViewportManager.TopEdge + 100, 0, 0), HorizontalAlignment = HorizontalAlignment.Center, }; EntityManager.Add(logo); // Moon Button Button moonButton = new Button() { Text = string.Empty, IsBorder = false, Width = 631, Height = 639, BackgroundImage = Directories.TexturePath + "moonRelease.wpk", PressedBackgroundImage = Directories.TexturePath + "moonPressed.wpk", Margin = new Thickness(76, 425, 0, 0), }; moonButton.Entity.AddComponent(new AnimationUI()); this.playButtonAnimation = moonButton.Entity.FindComponent <AnimationUI>(); moonButton.Entity.FindChild("ImageEntity").FindComponent <Transform2D>().Origin = Vector2.One / 2; moonButton.Click += (s, o) => { SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Click); SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.brokenGlass); WaveServices.ScreenContextManager.To(new ScreenContext(new GamePlayScene()), new SpinningSquaresTransition(TimeSpan.FromSeconds(1.5f))); }; EntityManager.Add(moonButton); // Button animation float maxScale = 1.05f; float minScale = 0.95f; Duration duration = TimeSpan.FromSeconds(2.5f); this.scaleUp = new SingleAnimation(minScale, maxScale, duration); this.scaleUp.Completed += (s, o) => { this.playButtonAnimation.BeginAnimation(Transform2D.XScaleProperty, this.scaleDown); this.playButtonAnimation.BeginAnimation(Transform2D.YScaleProperty, this.scaleDown); }; this.scaleDown = new SingleAnimation(maxScale, minScale, duration); this.scaleDown.Completed += (s, o) => { this.playButtonAnimation.BeginAnimation(Transform2D.XScaleProperty, this.scaleUp); this.playButtonAnimation.BeginAnimation(Transform2D.YScaleProperty, this.scaleUp); }; // Play Text TextBlock playText = new TextBlock() { FontPath = Directories.FontsPath + "OCR A Std_20.wpk", Foreground = new Color(119 / 255f, 250 / 255f, 255 / 255f), Text = "Play", VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(360, 885, 0, 0), }; EntityManager.Add(playText); // Your Best Score text TextBlock bestScoreText = new TextBlock() { Width = 200, FontPath = Directories.FontsPath + "OCR A Std_14.wpk", Foreground = new Color(119 / 255f, 250 / 255f, 255 / 255f), Text = "YOUR BEST SCORE:", Margin = new Thickness( 40, WaveServices.ViewportManager.BottomEdge - 40, 0, 0), }; EntityManager.Add(bestScoreText); // Scores GameStorage gameStorage = Catalog.GetItem <GameStorage>(); TextBlock maxScore = new TextBlock() { FontPath = Directories.FontsPath + "OCR A Std_20.wpk", Foreground = Color.White, Text = gameStorage.BestScore.ToString(), Margin = new Thickness( 290, WaveServices.ViewportManager.BottomEdge - 40, 0, 0) }; EntityManager.Add(maxScore); // Earth Entity earth = new Entity() .AddComponent(new Transform2D() { X = 550, Y = 954, }) .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "earth")) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.GUI)); EntityManager.Add(earth); }
public JellyFish(JellyFishType type, Vector2 position, bool rightAnimation = true) { this.entity = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = position.X, Y = position.Y, DrawOrder = 0.3f, }) .AddComponent(new AnimationUI()); // Cached this.animation = this.entity.FindComponent<AnimationUI>(); string textureName, colliderName; switch (type) { case JellyFishType.Big: textureName = "jellyFishSpriteSheet"; colliderName = "jellyFishCollider.wpk"; break; case JellyFishType.Little: textureName = "jellyFishLittleSpriteSheet"; colliderName = "jellyFishLittleCollider.wpk"; break; default: textureName = "jellyFishSpriteSheet"; colliderName = "jellyFishCollider.wpk"; break; } this.entity.AddComponent(new PerPixelCollider(Directories.TexturePath + colliderName, 0.5f) { IsGlobalAsset = true}); this.entity.AddComponent(new Sprite(Directories.TexturePath + string.Format("{0}.wpk", textureName)) { IsGlobalAsset = true}); this.entity.AddComponent(Animation2D.Create<TexturePackerGenericXml>(Directories.TexturePath + string.Format("{0}.xml", textureName)) .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 40, FramesPerSecond = 30 })); this.entity.AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); this.entity.FindComponent<Animation2D>().Play(true); // Animations float offset = 80; this.leftAnim = new SingleAnimation(position.X + offset, position.X, TimeSpan.FromSeconds(3)); this.leftAnim.Completed += (s, o) => { this.animation.BeginAnimation(Transform2D.XProperty, this.rightAnim); }; this.rightAnim = new SingleAnimation(position.X, position.X + offset, TimeSpan.FromSeconds(3)); this.rightAnim.Completed += (s, o) => { this.animation.BeginAnimation(Transform2D.XProperty, this.leftAnim); }; if (rightAnimation) { this.animation.BeginAnimation(Transform2D.XProperty, this.rightAnim); } else { this.animation.BeginAnimation(Transform2D.XProperty, this.leftAnim); } this.Collider = this.entity.FindComponent<Collider2D>(false); }
/// <summary> /// Creates the single animation action. /// </summary> /// <param name="scene">The scene.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animationUI">The animation UI.</param> /// <param name="dependencyProperty">The dependency property.</param> /// <returns>The action</returns> public static IGameAction CreateSingleAnimationGameAction(this Scene scene, SingleAnimation singleAnimation, AnimationUI animationUI, DependencyProperty dependencyProperty) { return(new SingleAnimationGameAction(singleAnimation, animationUI, dependencyProperty, scene)); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { RenderManager.BackgroundColor = Color.White; // Sonic PressedButton spankerButton = new PressedButton() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(40, 500, 0, 0), BackgroundImage = "Content/spanker.wpk", PressedBackgroundImage = "Content/spankerPressed.wpk", }; spankerButton.Entity.AddComponent(new AnimationUI()); this.spankerAnimation = spankerButton.Entity.FindComponent <AnimationUI>(); spankerButton.Click += (s, o) => { WaveServices.GetService <AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Spanker"); }; EntityManager.Add(spankerButton); // Link PressedButton colonelButton = new PressedButton() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(288, 500, 0, 0), BackgroundImage = "Content/colonel.wpk", PressedBackgroundImage = "Content/colonelPressed.wpk", }; colonelButton.Entity.AddComponent(new AnimationUI()); this.colonelAnimation = colonelButton.Entity.FindComponent <AnimationUI>(); colonelButton.Click += (s, o) => { WaveServices.GetService <AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Colonel"); }; EntityManager.Add(colonelButton); // Mario PressedButton fuzzButton = new PressedButton() { Width = 226, Height = 226, Text = string.Empty, Margin = new Thickness(536, 500, 0, 0), BackgroundImage = "Content/fuzz.wpk", PressedBackgroundImage = "Content/fuzzPressed.wpk", }; fuzzButton.Entity.AddComponent(new AnimationUI()); this.fuzzAnimation = fuzzButton.Entity.FindComponent <AnimationUI>(); fuzzButton.Click += (s, o) => { WaveServices.GetService <AnalyticsManager>().TagEvent("CharacterSelection", "Character", "Fuzz"); }; EntityManager.Add(fuzzButton); this.showSpanker = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); this.showColonel = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); this.showFuzz = new SingleAnimation(0, -374, 0.5f, EasingFunctions.Back); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundTransform = foregroundEntity.FindComponent<Transform2D>(); this.foregroundAnimation = foregroundEntity.FindComponent<AnimationUI>(); Entity bulletEntity = Owner.FindChild("BulletEntity"); this.bulletTransform = bulletEntity.FindComponent<Transform2D>(); this.bulletAnimation = bulletEntity.FindComponent<AnimationUI>(); this.textControl = Owner.FindChild("TextEntity").FindComponent<TextControl>(); if (this.on) { this.bulletTransform.X = DefaultOffset; this.foregroundTransform.XScale = DefaultOffset; this.textControl.Text = this.onText; } else { this.bulletTransform.X = 0; this.foregroundTransform.XScale = 0; this.textControl.Text = this.offText; } }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); Entity bulletEntity = Owner.FindChild("BulletEntity"); this.bulletTransform = bulletEntity.FindComponent<Transform2D>(); this.bulletImage = bulletEntity.FindComponent<ImageControl>(); this.bulletImage.Width = DefaultSliderWeight; this.bulletImage.Height = DefaultSliderWeight; Entity foregroundEntity = Owner.FindChild("ForegroundEntity"); this.foregroundImage = foregroundEntity.FindComponent<ImageControl>(); this.foregroundTransform = foregroundEntity.FindComponent<Transform2D>(); this.backgroundImage = Owner.FindChild("BackgroundEntity").FindComponent<ImageControl>(); Entity textEntity = Owner.FindChild("TextEntity"); this.textControl = textEntity.FindComponent<TextControl>(); this.textTransform = textEntity.FindComponent<Transform2D>(); this.animation = textEntity.FindComponent<AnimationUI>(); // Default parameters this.UpdateOrientation(); // Initialization value switch (this.orientation) { case Orientation.Vertical: float result = this.maximunOffset * (this.value - this.minimum) / this.difference; this.bulletTransform.Y = -result; this.foregroundTransform.YScale = result; break; case Orientation.Horizontal: this.bulletTransform.X = this.maximunOffset * (this.value - this.minimum) / this.difference; this.foregroundTransform.XScale = this.bulletTransform.X; break; } }
private void CreateUI() { // Super Entity super = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = -WaveServices.ViewportManager.VirtualWidth / 2, Y = 220, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "super.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.superAnimation = super.FindComponent<AnimationUI>(); EntityManager.Add(super); // Squid Entity squid = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth * 2, Y = 388, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "squid.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.squidAnimation = squid.FindComponent<AnimationUI>(); EntityManager.Add(squid); // Play Button Button play = new Button() { Text = string.Empty, IsBorder = false, BackgroundImage = Directories.TexturePath + "play.wpk", PressedBackgroundImage = Directories.TexturePath + "playPressed.wpk", Margin = new Thickness(244, 580, 0, 0), }; play.Click += (s, o) => { var gameContext = new ScreenContext("GamePlay", new GamePlayScene()) { Behavior = ScreenContextBehaviors.DrawInBackground }; WaveServices.ScreenContextManager.Pop(); WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f))); }; play.Entity.FindChild("ImageEntity").FindComponent<Transform2D>().Origin = Vector2.Center; play.Entity.AddComponent(new AnimationUI()); this.playAnimation = play.Entity.FindComponent<AnimationUI>(); EntityManager.Add(play); // Best Scores TextBlock bestScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your best score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 30), }; EntityManager.Add(bestScores); // Scores TextBlock scores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameStorage.BestScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 40), }; EntityManager.Add(scores); // StartFish Entity starFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 962, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(starFish); // Play background music WaveServices.MusicPlayer.Play(new MusicInfo(Directories.SoundsPath + "bg_music.mp3")); WaveServices.MusicPlayer.IsRepeat = true; }
private void CreateUI() { // Dark background Entity dark = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.LeftEdge, Y = WaveServices.ViewportManager.TopEdge, XScale = 1 / WaveServices.ViewportManager.RatioX, YScale = 1 / WaveServices.ViewportManager.RatioY, Opacity = 0.7f, DrawOrder = 0.9f, }) .AddComponent(new ImageControl(Color.Black, (int)WaveServices.ViewportManager.ScreenWidth, (int)WaveServices.ViewportManager.ScreenHeight)) .AddComponent(new ImageControlRenderer(DefaultLayers.GUI)); EntityManager.Add(dark); // Game Entity game = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 197, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "game.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.gameAnimation = game.FindComponent<AnimationUI>(); EntityManager.Add(game); // Over Entity over = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 439, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "over.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.overAnimation = over.FindComponent<AnimationUI>(); EntityManager.Add(over); // Restart Button Button restart = new Button() { Text = string.Empty, IsBorder = false, BackgroundImage = Directories.TexturePath + "restart.wpk", PressedBackgroundImage = Directories.TexturePath + "restartPressed.wpk", Margin = new Thickness(244, 571, 0, 0), }; restart.Click += (s, o) => { WaveServices.ScreenContextManager.FindContextByName("GamePlay").FindScene<GamePlayScene>().Reset(); WaveServices.ScreenContextManager.Pop(); }; restart.Entity.FindChild("ImageEntity").FindComponent<Transform2D>().Origin = Vector2.Center; restart.Entity.AddComponent(new AnimationUI()); this.restartAnimation = restart.Entity.FindComponent<AnimationUI>(); EntityManager.Add(restart); // Last score text TextBlock lastScoresText = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your last score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 80), }; EntityManager.Add(lastScoresText); // Last scores TextBlock lastScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameScene.CurrentScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 90), }; EntityManager.Add(lastScores); // StartFish Entity lastStarFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 910, XScale = 0.7f, YScale = 0.7f, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(lastStarFish); // Best Scores text TextBlock bestScoresText = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your best score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 10), }; EntityManager.Add(bestScoresText); // Best scores TextBlock bestScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameStorage.BestScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 20), }; EntityManager.Add(bestScores); // StartFish Entity bestStarFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 980, XScale = 0.7f, YScale = 0.7f, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(bestStarFish); }
private void CreateUI() { // Super Entity super = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = -WaveServices.ViewportManager.VirtualWidth / 2, Y = 220, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "super.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.superAnimation = super.FindComponent <AnimationUI>(); EntityManager.Add(super); // Squid Entity squid = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth * 2, Y = 388, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "squid.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.squidAnimation = squid.FindComponent <AnimationUI>(); EntityManager.Add(squid); // Play Button Button play = new Button() { Text = string.Empty, IsBorder = false, BackgroundImage = Directories.TexturePath + "play.wpk", PressedBackgroundImage = Directories.TexturePath + "playPressed.wpk", Margin = new Thickness(244, 580, 0, 0), }; play.Click += (s, o) => { var gameContext = new ScreenContext("GamePlay", new GamePlayScene()) { Behavior = ScreenContextBehaviors.DrawInBackground }; WaveServices.ScreenContextManager.Pop(); WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f))); }; play.Entity.FindChild("ImageEntity").FindComponent <Transform2D>().Origin = Vector2.Center; play.Entity.AddComponent(new AnimationUI()); this.playAnimation = play.Entity.FindComponent <AnimationUI>(); EntityManager.Add(play); // Best Scores TextBlock bestScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your best score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 30), }; EntityManager.Add(bestScores); // Scores TextBlock scores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameStorage.BestScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 40), }; EntityManager.Add(scores); // StartFish Entity starFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 962, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(starFish); // Play background music WaveServices.MusicPlayer.Play(new MusicInfo(Directories.SoundsPath + "bg_music.mp3")); WaveServices.MusicPlayer.IsRepeat = true; }
protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.ClearFlags = ClearFlags.DepthAndStencil; EntityManager.Add(camera2d); Entity logo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 300, Origin = new Vector2(0.5f, 0), DrawOrder = 0.1f }) .AddComponent(new Sprite("Content/GameOver.wpk")) .AddComponent(new AnimationUI()) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); this.gameStorage = Catalog.GetItem<GameStorage>(); this.EntityManager.Add(logo); this.labelAnimation = logo.FindComponent<AnimationUI>(); this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back); this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic); var button = new Button() { Margin = new Thickness(0, 657, 0, 0), HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top, Text = string.Empty, IsBorder = false, BackgroundImage = "Content/restart.wpk", PressedBackgroundImage = "Content/restart.wpk" }; button.Click += (o, e) => { GamePlayScene scene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene<GamePlayScene>(); scene.State = Behaviors.GameState.Game; scene.Reset(); WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f))); }; button.Entity.AddComponent(new AnimationUI()); this.playAnimation = button.Entity.FindComponent<AnimationUI>(); this.EntityManager.Add(button); var stackPanel = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Orientation = Orientation.Horizontal, Margin = new Thickness(0, 0, (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20)// (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20) }; var bestScoreLabel = new Image("Content/BestScore.wpk") { VerticalAlignment = VerticalAlignment.Center }; stackPanel.Add(bestScoreLabel); var bestScoreText = new TextBlock() { Text = this.gameStorage.BestScore.ToString(), FontPath = "Content/Space Age.wpk", VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(5,0,0,10) }; stackPanel.Add(bestScoreText); this.EntityManager.Add(stackPanel); }
/// <summary> /// And play a single animation action. /// </summary> /// <param name="parent">The parent.</param> /// <param name="singleAnimation">The single animation.</param> /// <param name="animationUI">The animation UI.</param> /// <param name="dependencyProperty">The dependency property.</param> /// <returns>The action</returns> public static IGameAction AndPlaySingleAnimation(this IGameAction parent, SingleAnimation singleAnimation, AnimationUI animationUI, DependencyProperty dependencyProperty) { return(new SingleAnimationGameAction(parent, singleAnimation, animationUI, dependencyProperty)); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.BackgroundColor = Color.CornflowerBlue; EntityManager.Add(camera2d); //Background Entity background = new Entity() .AddComponent(new Transform2D() { ////X = WaveServices.ViewportManager.LeftEdge, ////Y = WaveServices.ViewportManager.TopEdge, ////XScale = (WaveServices.ViewportManager.ScreenWidth / 768) / WaveServices.ViewportManager.RatioX, ////YScale = (WaveServices.ViewportManager.ScreenHeight / 1024) / WaveServices.ViewportManager.RatioY, DrawOrder = 1, }) .AddComponent(new Sprite(Directories.TexturePath + "background.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.Opaque)) .AddComponent(new StretchBehavior()); EntityManager.Add(background); // WaveLogo Entity waveLogo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = WaveServices.ViewportManager.TopEdge + 90, Origin = Vector2.Center }) .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "waveLogo")) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Alpha)); EntityManager.Add(waveLogo); // Logo Image logo = new Image(Directories.TexturePath + "largeLogo.wpk") { Margin = new Thickness(0, WaveServices.ViewportManager.TopEdge + 100, 0, 0), HorizontalAlignment = HorizontalAlignment.Center, }; EntityManager.Add(logo); // Moon Button Button moonButton = new Button() { Text = string.Empty, IsBorder = false, Width = 631, Height = 639, BackgroundImage = Directories.TexturePath + "moonRelease.wpk", PressedBackgroundImage = Directories.TexturePath + "moonPressed.wpk", Margin = new Thickness(76, 425, 0, 0), }; moonButton.Entity.AddComponent(new AnimationUI()); this.playButtonAnimation = moonButton.Entity.FindComponent<AnimationUI>(); moonButton.Entity.FindChild("ImageEntity").FindComponent<Transform2D>().Origin = Vector2.One / 2; moonButton.Click += (s, o) => { SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Click); SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.brokenGlass); WaveServices.ScreenContextManager.To(new ScreenContext(new GamePlayScene()), new SpinningSquaresTransition(TimeSpan.FromSeconds(1.5f))); }; EntityManager.Add(moonButton); // Button animation float maxScale = 1.05f; float minScale = 0.95f; Duration duration = TimeSpan.FromSeconds(2.5f); this.scaleUp = new SingleAnimation(minScale, maxScale, duration); this.scaleUp.Completed += (s, o) => { this.playButtonAnimation.BeginAnimation(Transform2D.XScaleProperty, this.scaleDown); this.playButtonAnimation.BeginAnimation(Transform2D.YScaleProperty, this.scaleDown); }; this.scaleDown = new SingleAnimation(maxScale, minScale, duration); this.scaleDown.Completed += (s, o) => { this.playButtonAnimation.BeginAnimation(Transform2D.XScaleProperty, this.scaleUp); this.playButtonAnimation.BeginAnimation(Transform2D.YScaleProperty, this.scaleUp); }; // Play Text TextBlock playText = new TextBlock() { FontPath = Directories.FontsPath + "OCR A Std_20.wpk", Foreground = new Color(119 / 255f, 250 / 255f, 255 / 255f), Text = "Play", VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(360, 885, 0, 0), }; EntityManager.Add(playText); // Your Best Score text TextBlock bestScoreText = new TextBlock() { Width = 200, FontPath = Directories.FontsPath + "OCR A Std_14.wpk", Foreground = new Color(119 / 255f, 250 / 255f, 255 / 255f), Text = "YOUR BEST SCORE:", Margin = new Thickness( 40, WaveServices.ViewportManager.BottomEdge - 40, 0, 0), }; EntityManager.Add(bestScoreText); // Scores GameStorage gameStorage = Catalog.GetItem<GameStorage>(); TextBlock maxScore = new TextBlock() { FontPath = Directories.FontsPath + "OCR A Std_20.wpk", Foreground = Color.White, Text = gameStorage.BestScore.ToString(), Margin = new Thickness( 290, WaveServices.ViewportManager.BottomEdge - 40, 0, 0) }; EntityManager.Add(maxScore); // Earth Entity earth = new Entity() .AddComponent(new Transform2D() { X = 550, Y = 954, }) .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "earth")) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.GUI)); EntityManager.Add(earth); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.imageCheckedEntity = Owner.FindChild("ImageCheckedEntity"); this.imageCheckedTransform = this.imageCheckedEntity.FindComponent<Transform2D>(); this.Animation = this.imageCheckedEntity.FindComponent<AnimationUI>(); // Initial configuration if (this.isChecked) { this.imageCheckedTransform.Opacity = 1.0f; } else { this.imageCheckedTransform.Opacity = 0.0f; } }
protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.ClearFlags = ClearFlags.DepthAndStencil; EntityManager.Add(camera2d); Entity logo = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 300, Origin = new Vector2(0.5f, 0), DrawOrder = 0.1f }) .AddComponent(new Sprite("Content/GameOver.wpk")) .AddComponent(new AnimationUI()) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); this.gameStorage = Catalog.GetItem <GameStorage>(); this.EntityManager.Add(logo); this.labelAnimation = logo.FindComponent <AnimationUI>(); this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back); this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic); var button = new Button() { Margin = new Thickness(0, 657, 0, 0), HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top, Text = string.Empty, IsBorder = false, BackgroundImage = "Content/restart.wpk", PressedBackgroundImage = "Content/restart.wpk" }; button.Click += (o, e) => { GamePlayScene scene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene <GamePlayScene>(); scene.State = Behaviors.GameState.Game; scene.Reset(); WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f))); }; button.Entity.AddComponent(new AnimationUI()); this.playAnimation = button.Entity.FindComponent <AnimationUI>(); this.EntityManager.Add(button); var stackPanel = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Orientation = Orientation.Horizontal, Margin = new Thickness(0, 0, (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20)// (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20) }; var bestScoreLabel = new Image("Content/BestScore.wpk") { VerticalAlignment = VerticalAlignment.Center }; stackPanel.Add(bestScoreLabel); var bestScoreText = new TextBlock() { Text = this.gameStorage.BestScore.ToString(), FontPath = "Content/Space Age.wpk", VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 10) }; stackPanel.Add(bestScoreText); this.EntityManager.Add(stackPanel); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.textControl = Owner.FindChild("TextEntity").FindComponent<TextControl>(); this.textBeforeCursor = this.textControl.Text; Entity cursorEntity = Owner.FindChild("CursorEntity"); this.cursorTransform = cursorEntity.FindComponent<Transform2D>(); this.cursorAnimation = cursorEntity.FindComponent<AnimationUI>(); this.imageControl = Owner.FindChild("ImageEntity").FindComponent<ImageControl>(); this.imageControl.Width = this.Panel.Width; this.imageControl.Height = this.Panel.Height; }
private void CreateUI() { // Dark background Entity dark = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.LeftEdge, Y = WaveServices.ViewportManager.TopEdge, XScale = 1 / WaveServices.ViewportManager.RatioX, YScale = 1 / WaveServices.ViewportManager.RatioY, Opacity = 0.7f, DrawOrder = 0.9f, }) .AddComponent(new ImageControl(Color.Black, (int)WaveServices.ViewportManager.ScreenWidth, (int)WaveServices.ViewportManager.ScreenHeight)) .AddComponent(new ImageControlRenderer(DefaultLayers.GUI)); EntityManager.Add(dark); // Game Entity game = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 197, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "game.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.gameAnimation = game.FindComponent <AnimationUI>(); EntityManager.Add(game); // Over Entity over = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 439, }) .AddComponent(new AnimationUI()) .AddComponent(new Sprite(Directories.TexturePath + "over.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); this.overAnimation = over.FindComponent <AnimationUI>(); EntityManager.Add(over); // Restart Button Button restart = new Button() { Text = string.Empty, IsBorder = false, BackgroundImage = Directories.TexturePath + "restart.wpk", PressedBackgroundImage = Directories.TexturePath + "restartPressed.wpk", Margin = new Thickness(244, 571, 0, 0), }; restart.Click += (s, o) => { WaveServices.ScreenContextManager.FindContextByName("GamePlay").FindScene <GamePlayScene>().Reset(); WaveServices.ScreenContextManager.Pop(); }; restart.Entity.FindChild("ImageEntity").FindComponent <Transform2D>().Origin = Vector2.Center; restart.Entity.AddComponent(new AnimationUI()); this.restartAnimation = restart.Entity.FindComponent <AnimationUI>(); EntityManager.Add(restart); // Last score text TextBlock lastScoresText = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your last score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 80), }; EntityManager.Add(lastScoresText); // Last scores TextBlock lastScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameScene.CurrentScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 90), }; EntityManager.Add(lastScores); // StartFish Entity lastStarFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 910, XScale = 0.7f, YScale = 0.7f, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(lastStarFish); // Best Scores text TextBlock bestScoresText = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_16.wpk", Text = "your best score:", Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(161, 0, 0, 10), }; EntityManager.Add(bestScoresText); // Best scores TextBlock bestScores = new TextBlock() { FontPath = Directories.FontsPath + "Bulky Pixels_26.wpk", Text = this.gameStorage.BestScore.ToString(), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(440, 0, 0, 20), }; EntityManager.Add(bestScores); // StartFish Entity bestStarFish = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = 585, Y = 980, XScale = 0.7f, YScale = 0.7f, }) .AddComponent(new Sprite(Directories.TexturePath + "starfish.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.GUI)); EntityManager.Add(bestStarFish); }