public DeleteAnimationAction(FrmMainContainer mainForm, TLayer layer, int index) { this.mainForm = mainForm; this.layer = layer; this.index = index; this.animation = layer.animations[index]; }
protected virtual void clone(TLayer target) { target.document = this.document; target.parent = this.parent; target.name = this.name; target.locked = this.locked; target.backgroundColor = this.backgroundColor; target.alpha = this.alpha; this.childs.ForEach((item) => { TLayer newItem = item.clone(); newItem.parent = target; target.childs.Add(newItem); }); this.animations.ForEach((item) => { TAnimation newAnimation = item.clone(); newAnimation.layer = target; target.animations.Add(newAnimation); }); this.events.ForEach((item) => { target.events.Add(item); }); this.states.ForEach((item) => { target.states.Add(item); }); }
public ChangeAnimationStateAction(FrmMainContainer mainForm, int index, TAnimation animation, string newState) { this.mainForm = mainForm; this.index = index; this.animation = animation; this.oldState = animation.state; this.newState = newState; }
public ChangeAnimationEventAction(FrmMainContainer mainForm, int index, TAnimation animation, string newEvent) { this.mainForm = mainForm; this.index = index; this.animation = animation; this.oldEvent = animation.eventu; this.newEvent = newEvent; }
public ChangeAnimationAction(FrmMainContainer mainForm, TLayer layer, TAnimation oldAnimation, TAnimation newAnimation) { this.mainForm = mainForm; this.layer = layer; this.oldAnimation = oldAnimation; this.newAnimation = newAnimation; this.index = layer.animations.IndexOf(oldAnimation); }
public virtual bool parseXml(XElement xml, TLayer parentLayer) { if (xml == null) { return(false); } try { name = xml.Element("Name").Value; parent = parentLayer; locked = TUtil.parseBoolXElement(xml.Element("Locked"), false); backgroundColor = Color.FromArgb(TUtil.parseIntXElement(xml.Element("BackgroundColor"), 0)); alpha = float.Parse(xml.Element("Alpha").Value); XElement xmlEvents = xml.Element("Events"); IEnumerable <XElement> xmlEventList = xmlEvents.Elements("Event"); foreach (XElement xmlEvent in xmlEventList) { events.Add(xmlEvent.Value); } XElement xmlStates = xml.Element("States"); IEnumerable <XElement> xmlStateList = xmlStates.Elements("State"); foreach (XElement xmlState in xmlStateList) { states.Add(xmlState.Value); } XElement xmlAnimations = xml.Element("Animations"); IEnumerable <XElement> xmlAnimationList = xmlAnimations.Elements("Animation"); foreach (XElement xmlAnimation in xmlAnimationList) { TAnimation animation = new TAnimation(this); if (!animation.parseXml(xmlAnimation)) { return(false); } animations.Add(animation); } XElement xmlChilds = xml.Element("Childs"); IEnumerable <XElement> xmlChildList = xmlChilds.Elements(); foreach (XElement xmlChild in xmlChildList) { TLayer layer = (TLayer)Activator.CreateInstance(Type.GetType(GetType().Namespace + ".T" + xmlChild.Name.ToString()), new Object[] { document }); if (!layer.parseXml(xmlChild, this)) { return(false); } childs.Add(layer); } return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public TSequence() { this.repeat = 1; this.animation = null; this.actions = new List <TAction>(); this.run_repeated = 0; this.run_currentAction = -1; }
private void pnlDisplayBox_MouseUp(object sender, MouseEventArgs e) { if (currentScene == null) { return; } if (e.Button == MouseButtons.Left && MousePressed) { // fire drop event if (MouseDownActor != null) { MouseDownActor.fireEvent(Program.DEFAULT_EVENT_DROP, false); // check this actor is puzzle actor if (MouseDownActor.puzzle && !MouseDownActor.isMoving()) { PointF[] bound1 = MouseDownActor.interactionBoundOnScreen(); // check if the puzzle actor went the correct puzzle area if (TUtil.isPolygonsIntersect(bound1, MouseDownActor.puzzleAreaOnScreen())) { // turn off the puzzle function after success MouseDownActor.puzzle = false; // fire puzzle success event MouseDownActor.fireEvent(Program.DEFAULT_EVENT_PUZZLE_SUCCESS, false); } else { // if puzzle is failed, actor return to original position TAnimation animation = new TAnimation(MouseDownActor); TSequence sequence = animation.addSequence(); sequence.addAction(new TActionIntervalMove() { duration = 300, position = MouseDownActor.backupActor.position }); sequence.addAction(new TActionInstantDispatchEvent() { actor = MouseDownActor.name, eventu = Program.DEFAULT_EVENT_PUZZLE_FAIL, recursive = false }); animation.start(); extraAnimations.Add(animation); } } } MousePressed = false; MouseDownActor = null; // redraw workspace this.pnlDisplayBox.Refresh(); } }
public static TAnimation newAnimation(TLayer layer, TAction action) { TAnimation animation = new TAnimation(layer); TSequence sequence = new TSequence(); animation.addSequence(sequence); action.sequence = sequence; sequence.addAction(action); return(animation); }
public TAnimation clone() { TAnimation anim = new TAnimation(this.layer); anim.eventu = eventu; anim.state = state; sequences.ForEach((item) => { TSequence newSequence = item.clone(); newSequence.animation = anim; anim.sequences.Add(newSequence); }); return(anim); }
public virtual void step(FrmEmulator emulator, long time) { // step of self for (int i = 0; i < animations.Count; i++) { TAnimation animation = animations[i]; if (animation.run_executing) { animation.step(emulator, time); } } // step of child for (int i = 0; i < childs.Count; i++) { childs[i].step(emulator, time); } }
//==================================== Execute =================================================// public virtual void fireEvent(string eventu, bool recursive) { if (run_enabled) { // animation of self for (int i = 0; i < animations.Count; i++) { TAnimation animation = animations[i]; if (animation.eventu == eventu && animation.state == run_state && animation.run_executing == false) { animation.start(); } } // animation of child if (recursive) { for (int i = 0; i < childs.Count; i++) { childs[i].fireEvent(eventu, recursive); } } } }
public AddAnimationAction(FrmMainContainer mainForm, TLayer layer, TAnimation animation) { this.mainForm = mainForm; this.layer = layer; this.animation = animation; }
private List <TActor> extraActorsOfEmulator(TScene scene) { // result List <TActor> extras = new List <TActor>(); // back navigation button if (scene.prevButtonVisible && imgPrevButton != null) { TImageActor btnPrev = new TImageActor(document, imgPrevButton, 0, Program.BOOK_HEIGHT, scene, "[emulator_actor]:prev_button"); btnPrev.anchor = new PointF(0, 1); extras.Add(btnPrev); if (document.navigationLeftButtonRender) { TAnimation animation = new TAnimation(btnPrev); TSequence sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = document.navigationButtonDelayTime * 1000 }); sequence.addAction(new TActionInstantDispatchEvent() { actor = btnPrev.name, eventu = Program.DEFAULT_EVENT_UNDEFINED, recursive = false }); animation.eventu = Program.DEFAULT_EVENT_ENTER; animation.start(); btnPrev.animations.Add(animation); animation = new TAnimation(btnPrev); sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = 500 }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1.4f, 1.4f) }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1f, 1f) }); sequence.repeat = 100; animation.eventu = Program.DEFAULT_EVENT_UNDEFINED; btnPrev.animations.Add(animation); } else { TAnimation animation = TAnimation.newAnimation(btnPrev, new TActionInstantGoScene() { type = TActionInstantGoScene.ActionType.PREVIOUS }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnPrev.animations.Add(animation); } } // next navigation button if (scene.nextButtonVisible && imgNextButton != null) { TImageActor btnNext = new TImageActor(document, imgNextButton, Program.BOOK_WIDTH, Program.BOOK_HEIGHT, scene, "[emulator_actor]:next_button"); btnNext.anchor = new PointF(1, 1); extras.Add(btnNext); if (document.navigationRightButtonRender) { TAnimation animation = new TAnimation(btnNext); TSequence sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = document.navigationButtonDelayTime * 1000 }); sequence.addAction(new TActionInstantDispatchEvent() { actor = btnNext.name, eventu = Program.DEFAULT_EVENT_UNDEFINED, recursive = false }); animation.eventu = Program.DEFAULT_EVENT_ENTER; animation.start(); btnNext.animations.Add(animation); animation = new TAnimation(btnNext); sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = 500 }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1.4f, 1.4f) }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1f, 1f) }); sequence.repeat = 100; animation.eventu = Program.DEFAULT_EVENT_UNDEFINED; btnNext.animations.Add(animation); } else { TAnimation animation = TAnimation.newAnimation(btnNext, new TActionInstantGoScene() { type = TActionInstantGoScene.ActionType.NEXT }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnNext.animations.Add(animation); } } // menu button { TImageActor btnMenu = new TImageActor(document, Properties.Resources.emulator_img_menu_button, Program.BOOK_WIDTH, 0, scene, "[emulator_actor]:menu_button"); btnMenu.anchor = new PointF(1, 0); extras.Add(btnMenu); TAnimation animation = TAnimation.newAnimation(btnMenu, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:show_dialog", recursive = true }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnMenu.animations.Add(animation); } // menu popup { // background TImageActor dlgMenu = new TImageActor(document, Properties.Resources.emulator_img_menu_dialog_bg, 0, 0, scene, "[emulator_actor]:menu_dialog"); { dlgMenu.anchor = new PointF(0, 0); dlgMenu.alpha = 0; extras.Add(dlgMenu); // show dialog TAnimation animShow = new TAnimation(dlgMenu); TSequence seqShow = animShow.addSequence(); seqShow.addAction(new TActionIntervalFade() { duration = 100, type = TActionIntervalFade.ActionType.IN }); animShow.eventu = "[emulator_event]:show_dialog"; dlgMenu.animations.Add(animShow); // hide dialog TAnimation animHide = new TAnimation(dlgMenu); TSequence seqHide = animHide.addSequence(); seqHide.addAction(new TActionIntervalDelay() { duration = 200 }); seqHide.addAction(new TActionIntervalFade() { duration = 100, type = TActionIntervalFade.ActionType.OUT }); animHide.eventu = "[emulator_event]:hide_dialog"; dlgMenu.animations.Add(animHide); TAnimation animation = TAnimation.newAnimation(dlgMenu, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:hide_dialog", recursive = true }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; dlgMenu.animations.Add(animation); } TAnimation animShowBase = TAnimation.newAnimation(null, new TActionIntervalMove() { duration = 300, easingMode = TEasingFunction.EasingMode.Out, easingType = TEasingFunction.EasingType.Bounce }); animShowBase.eventu = "[emulator_event]:show_dialog"; TAnimation animHideBase = TAnimation.newAnimation(null, new TActionIntervalMove() { duration = 300, easingMode = TEasingFunction.EasingMode.In, easingType = TEasingFunction.EasingType.Back }); animHideBase.eventu = "[emulator_event]:hide_dialog"; TImageActor btnBGM = new TImageActor(document, Properties.Resources.emulator_img_bgm_off, -100, 290, dlgMenu, "[emulator_actor]:menu_bgm_button"); { btnBGM.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnBGM); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnBGM; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 290); btnBGM.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnBGM; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnBGM.position; btnBGM.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnBGM, new TActionRuntime(0, delegate(float percent) { if (bgmOn) { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_on); } else { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnBGM.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnBGM, new TActionRuntime(0, delegate(float percent) { toggleBGM(); if (bgmOn) { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_on); } else { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnBGM.animations.Add(animToggle); } TImageActor btnEffect = new TImageActor(document, Properties.Resources.emulator_img_effect_off, -100, 480, dlgMenu, "[emulator_actor]:menu_effect_button"); { btnEffect.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnEffect); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnEffect; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 480); btnEffect.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnEffect; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnEffect.position; btnEffect.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnEffect, new TActionRuntime(0, delegate(float percent) { if (effectOn) { btnEffect.loadImage(Properties.Resources.emulator_img_effect_on); } else { btnEffect.loadImage(Properties.Resources.emulator_img_effect_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnEffect.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnEffect, new TActionRuntime(0, delegate(float percent) { toggleEffect(); if (effectOn) { btnEffect.loadImage(Properties.Resources.emulator_img_effect_on); } else { btnEffect.loadImage(Properties.Resources.emulator_img_effect_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnEffect.animations.Add(animToggle); } TImageActor btnVoice = new TImageActor(document, Properties.Resources.emulator_img_voice_off, -100, 600, dlgMenu, "[emulator_actor]:menu_voice_button"); { btnVoice.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnVoice); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnVoice; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 670); btnVoice.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnVoice; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnVoice.position; btnVoice.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnVoice, new TActionRuntime(0, delegate(float percent) { if (voiceOn) { btnVoice.loadImage(Properties.Resources.emulator_img_voice_on); } else { btnVoice.loadImage(Properties.Resources.emulator_img_voice_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnVoice.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnVoice, new TActionRuntime(0, delegate(float percent) { toggleVoice(); if (voiceOn) { btnVoice.loadImage(Properties.Resources.emulator_img_voice_on); } else { btnVoice.loadImage(Properties.Resources.emulator_img_voice_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnVoice.animations.Add(animToggle); } TImageActor btnText = new TImageActor(document, Properties.Resources.emulator_img_text_off, -100, 100, dlgMenu, "[emulator_actor]:menu_text_button"); { btnText.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnText); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnText; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 100); btnText.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnText; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnText.position; btnText.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnText, new TActionRuntime(0, delegate(float percent) { if (textOn) { btnText.loadImage(Properties.Resources.emulator_img_text_on); } else { btnText.loadImage(Properties.Resources.emulator_img_text_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnText.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnText, new TActionRuntime(0, delegate(float percent) { toggleText(); if (textOn) { btnText.loadImage(Properties.Resources.emulator_img_text_on); } else { btnText.loadImage(Properties.Resources.emulator_img_text_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnText.animations.Add(animToggle); } /* * TImageActor btnBack = new TImageActor(document, Properties.Resources.emulator_img_menu_dialog_bg, 0, 0, dlgMenu, "[emulator_actor]:menu_back_button"); * { * btnBack.anchor = new PointF(1.0f, 0f); * dlgMenu.childs.Add(btnBack); * * // show animation from base show animation * TAnimation animShow = animShowBase.clone(); * animShow.layer = btnBack; * ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(900, 500); * btnBack.animations.Add(animShow); * * // hide animation from base hide animation * TAnimation animHide = animHideBase.clone(); * animHide.layer = btnBack; * ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnBack.position; * btnBack.animations.Add(animHide); * * TAnimation animation = TAnimation.newAnimation(btnBack, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:hide_dialog", recursive = true }); * animation.eventu = Program.DEFAULT_EVENT_TOUCH; * btnBack.animations.Add(animation); * } */ } return(extras); }