private static void TestUpdate() { Dictionary<int, string[]> events = new Dictionary<int, string[]>(); string[] test1 = {"test1", "test2"}; string[] test2 = {"test3"}; events.Add(1, test1); events.Add(5, test2); Roga2dAnimationSettings settings = new Roga2dAnimationSettings(null, null, null, null, CommandCalled); Roga2dBaseInterval interval = new Roga2dEventInterval(events, settings); interval.Start(); interval.Update(); interval.Update(); interval.Update(); interval.Update(); interval.Update(); Tester.Ok(!interval.IsDone()); interval.Update(); Tester.Ok(interval.IsDone()); Tester.Match(counter, 3); }
public Roga2dSourceInterval(Roga2dSprite sprite, List<Roga2dAnimationKeyFrame> keyFrames, Roga2dAnimationSettings settings, Dictionary<string, Roga2dSwapTextureDef> options) { this.options = options; this.sprite = sprite; this.frameDuration = 0; this.settings = settings; this.lastAnimationId = ""; this.keyFrames = keyFrames; this.renderObjectDescs = new List<Roga2dRenderObjectDesc>(this.keyFrames.Count); string lastKeyFrameId = ""; foreach (Roga2dAnimationKeyFrame keyFrame in this.keyFrames) { if (keyFrame.Id != "" && keyFrame.Type == Roga2dAnimationKeyFrameType.Image) { Roga2dRenderObject renderObject; if (lastKeyFrameId == keyFrame.Id) { renderObject = renderObjectDescs[renderObjectDescs.Count - 1].RenderObject; } else { renderObject = new Roga2dRenderObject(keyFrame.Id, keyFrame.PixelSize, keyFrame.PixelCenter, keyFrame.Rect); } Roga2dRenderObjectDesc desc = new Roga2dRenderObjectDesc(); desc.RenderObject = renderObject; desc.SrcRect = keyFrame.Rect; desc.PixelSize = keyFrame.PixelSize; renderObjectDescs.Add(desc); lastKeyFrameId = keyFrame.Id; } else { renderObjectDescs.Add(null); lastKeyFrameId = ""; } this.duration += keyFrame.Duration; } }
public static Roga2dAnimation Build(Roga2dNode node, Roga2dBaseInterval interval, Roga2dAnimationSettings settings) { Roga2dAnimation animation = new Roga2dAnimation(); animation.Interval = interval; animation.Node = node; animation.IsStarted = false; animation.finishCallback = null; animation.settings = settings; return animation; }
private static void CommandCalled(Roga2dAnimationSettings settings, string command) { if (counter == 0) { Tester.Match(command, "test1"); } else if(counter == 1) { Tester.Match(command, "test2"); } else if(counter == 2) { Tester.Match(command, "test3"); } counter += 1; }
public Roga2dEventInterval(Dictionary<int, string[]> events, Roga2dAnimationSettings settings) { // Calculate the length int max = 0; foreach (KeyValuePair<int, string[]> entry in events) { if (entry.Key > max) { max = entry.Key; } } this.duration = max + 1; this.events = events; this.settings = settings; }
void CommandCalled(Roga2dAnimationSettings settings, string command) { string[] commandData = command.Split(':'); if (commandData[0] == "damage") { // Flash effect Roga2dBaseInterval interval = EffectBuilder.GetInstance().BuildDamageInterval(settings.Target); Roga2dIntervalPlayer.GetInstance().Play(interval); // Damage pop Roga2dAnimation animation = EffectBuilder.GetInstance().BuildDamagePopAnimation(settings.Target.LocalPixelPosition, 2750); this.player.Play(settings.Root, null, animation, null); } }
private void playNextAnimation(int no) { AdventureObject battler = this.battlers[0]; if (battler.Sprite.IsVisible) { battler.Sprite.Hide(); Dictionary<string, Roga2dSwapTextureDef> options = new Dictionary<string, Roga2dSwapTextureDef>() { { "Battle/Skills/Battler_Base", new Roga2dSwapTextureDef() {TextureID = battler.TextureID, PixelSize = new Vector2(32, 32)}}, { "Battle/Skills/Monster_Base", new Roga2dSwapTextureDef() {TextureID = "death_wind", PixelSize = this.monster.PixelSize, SrcRect = this.monster.SrcRect}} }; Roga2dAnimationSettings settings = new Roga2dAnimationSettings(this.animationPlayer, this.root, battler, this.monster, CommandCalled); Roga2dAnimation animation = Roga2dUtils.LoadAnimation(ids[no], false, 1.0f, 0.5f, settings, options); this.animationPlayer.Play(battler, null, animation, AnimationFinished); } }
private void CommandCalled(Roga2dAnimationSettings settings, string command) { string[] commandData = command.Split(':'); if (commandData[0] == "damage") { uint damageValue = 2750; // Flash effect Roga2dBaseInterval interval = EffectBuilder.GetInstance().BuildDamageInterval(settings.Target); Roga2dIntervalPlayer.GetInstance().Play(interval); // Damage pop Roga2dAnimation animation = EffectBuilder.GetInstance().BuildDamagePopAnimation(settings.Target.LocalPixelPosition, damageValue); this.animationPlayer.Play(settings.Root, null, animation, null); AdventureObject obj = (AdventureObject)settings.Target; obj.ApplyDamage(damageValue); } }
void Update() { Roga2dIntervalPlayer.GetInstance().Update(); // Update animations this.player.Update(); this.root.Update(); if (Input.GetMouseButtonDown(0)) { AdventureObject battler = this.battlers[no % 5]; if (battler.Sprite.IsVisible) { battler.Sprite.Hide(); Dictionary<string, Roga2dSwapTextureDef> options = new Dictionary<string, Roga2dSwapTextureDef>() { { "Battle/Skills/Battler_Base", new Roga2dSwapTextureDef() {TextureID = battler.TextureID, PixelSize = new Vector2(32, 32)}}, { "Battle/Skills/Monster_Base", new Roga2dSwapTextureDef() {TextureID = "death_wind", PixelSize = this.monster.PixelSize, SrcRect = this.monster.SrcRect}} }; Roga2dAnimationSettings settings = new Roga2dAnimationSettings(this.player, this.root, battler, this.monster, CommandCalled); Roga2dAnimation animation = Roga2dUtils.LoadAnimation(ids[no], false, 1.0f, 0.5f, settings, options); this.player.Play(battler, null, animation, AnimationFinished); no +=1; if (no >= ids.Length) { no = 0; } } } // Change Camera position // camera.position = new Vector3(this.monster.Position.x, this.monster.Position.y, camera.position.z); }