public void ImportAnimation(animation colladaAnim, Animation animation, TrackGroup trackGroup, Skeleton skeleton) { var childAnims = 0; foreach (var item in colladaAnim.Items) { if (item is animation) { ImportAnimation(item as animation, animation, trackGroup, skeleton); childAnims++; } } var duration = .0f; if (childAnims < colladaAnim.Items.Length) { ColladaAnimation importAnim = new ColladaAnimation(); if (importAnim.ImportFromCollada(colladaAnim, skeleton)) { duration = Math.Max(duration, importAnim.Duration); var track = importAnim.MakeTrack(Options.RemoveTrivialAnimationKeys); trackGroup.TransformTracks.Add(track); } } animation.Duration = Math.Max(animation.Duration, duration); }
public void SetAnim(animation a) { anim = a; anim.Play(); SetTexture(a.texture); dodirectional = false; }
public virtual void Fire() { if (_cooldown == 0) { if (clip == 0) { Reload(); return; } _anim = _fireAnim; _cooldown = _shootcd; audio.PlaySound("sound/revolver/shoot", 70); clip = (clip - 1).Clamp(0, 255); _anim = _fireAnim; _anim.Play(); var e = world.Player.GetLookatEntity(); if (e != null && e.GetState() == livestate.Alive) { e.DoDamage(_damage); } var c = renderer.GetCenterMapCell(); if (c != null) { c.OnShot(); } } }
private void btnConfig_Click_1(object sender, EventArgs e) { pnlTempo.Visible = false; animation anime = new animation(); animation.util.Animatte(pnlPomodoro, animation.util.effect.Slide, 180, 0); lblCronometro2.Visible = false; }
private void button4_Click(object sender, EventArgs e) { lblDate.Visible = false; lblQtdDias.Visible = false; lblDataFinal.Visible = false; animation anime = new animation(); animation.util.Animatte(pnlCalendario, animation.util.effect.Slide, 180, 0); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); backgscroll = new scrollingbackground(Content, "space", 1, 5, 5); gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight); for (int i = 0; i < numberofballs; i++) { float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio; if (tempsize < miniballsize) { tempsize = miniballsize; } balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize, new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser); } collidesound = Content.Load <SoundEffect>("rocks"); soundtrack1 = Content.Load <SoundEffect>("explosive_attack"); music1 = soundtrack1.CreateInstance(); music1.IsLooped = true; music1.Volume = 0.5f; soundtrack2 = Content.Load <SoundEffect>("iron-man"); music2 = soundtrack2.CreateInstance(); music2.IsLooped = true; music2.Volume = 0.5f; mainfont = Content.Load <SpriteFont>("quartz4"); for (int i = 0; i < numberofballs; i++) { explosion[i] = new animation(Content, "effect_005", 0, 0, 1f, Color.White, false, 24, 4, 5, false); } shiphit[0] = new animation(Content, "effect_003", 0, 0, 1, Color.White, false, 24, 5, 5, false); shiphit[1] = new animation(Content, "effect_002", 0, 0, 1, Color.White, false, 24, 4, 5, false); bullet[0] = new ammo(Content, "bullet1", 0, 0, .1f, Color.White, false); bullet[1] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); for (int b = 0; b < numberofbullets; b++) { for (int s = 0; s < numberofships; s++) { bullets5[s, b] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); } } reset(); }
public override void UpdateAnimationState(Engine.Object obj) { animation tempAnim = _animation; if (obj is Terror) { Terror zombie = obj as Terror; _animation = obj.VelocityX > zombie.WalkSpeed || obj.VelocityX < -zombie.WalkSpeed ? animation.RUNNING : animation.WALKING; } if (tempAnim != _animation) { SetupAnimation(obj); } Mirrored = obj.Velocity.X < 0 ? false : true; }
public bool ImportFromCollada(animation colladaAnim, Skeleton skeleton) { Animation = colladaAnim; ImportSources(); ImportSampler(); // Avoid importing empty animations if (Transforms.Count == 0) { return(false); } ImportChannel(skeleton); return(true); }
private void btnParar_Click(object sender, EventArgs e) { animation anime = new animation(); animation.util.Animatte(pnlPomodoro, animation.util.effect.Slide, 180, 0); btnPlayP.Visible = false; btnPauseP.Visible = false; pnlTempo.Visible = false; timer1.Enabled = false; lblCronometro.Text = "25:00:00"; lblCronometro2.Text = "25:00:00"; mil = 60; seg = 00; min = 25; }
public weapon(animation fireAnim, int maxclip, int totalammo, byte damage, int shootcd, int reloadcd, string sfxShoot, string sfxReload, string sfxEmpty) { _fireAnim = fireAnim; _anim = fireAnim; _sfxShoot = sfxShoot; _sfxReload = sfxReload; _sfxEmpty = sfxEmpty; _damage = damage; _shootcd = shootcd; _reloadcd = reloadcd; this.maxclip = maxclip; nonclip = totalammo; Reload(); }
public Player(string name, string triggerType, int mass, int height, int width, Vector2 position, int hp, int dmg, int _attackBoxWidth, int _attackBoxHeight, bool _animationFlip) : base(name, triggerType, mass, height, width, position, hp, dmg, _attackBoxWidth, _attackBoxHeight, _animationFlip) { speed = 700; jumpHeight = 16; inHub = false; interact = false; inJump = false; animTex = new animation[] { new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Idle"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Running"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Jump"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Attack"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Attack2"), 10, 4, 37), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Attack3"), 10, 8, 75), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Hurt"), 10, 2, 18), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Dance"), 10, 50, 500), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Falling"), 10, 2, 12), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Landing"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Stop"), 10, 4, 31), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Crouch"), 10, 3, 25), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Dying"), 10, 7, 62), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Slip"), 10, 10, 100), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/Evasion"), 10, 4, 37), new animation(Game1.Ressources.Load <Texture2D>("newPlayer/IsDead"), 10, 2, 12) }; slide = 0; onIce = false; maxHealth = hp; health = maxHealth; damage = dmg; attackBox.X = 0; attackBox.Y = 0; attackBox.Width = _attackBoxWidth; attackBox.Height = _attackBoxHeight; hurtBox.X = (int)position.X; hurtBox.Y = (int)position.Y; hurtBox.Width = width / 2; hurtBox.Height = height; }
public SubAnimation(animation anim) { foreach (object anObj in anim.Items) { if (anObj is source) { source src = anObj as source; mSources.Add(src.id, src); } else if (anObj is sampler) { sampler samp = anObj as sampler; mSamplers.Add(samp.id, samp); } else if (anObj is channel) { channel chan = anObj as channel; mChannels.Add(chan); } } }
public void ImportAnimation(animation anim, TrackGroup trackGroup) { var childAnims = 0; foreach (var item in anim.Items) { if (item is animation) { ImportAnimation(item as animation, trackGroup); childAnims++; } } if (childAnims < anim.Items.Length) { ColladaAnimation collada = new ColladaAnimation(); if (collada.ImportFromCollada(anim, Skeletons[0])) { var track = collada.MakeTrack(); trackGroup.TransformTracks.Add(track); } } }
public Animation(animation anim) { if (anim.Items.OfType <animation>().Count() > 0) { foreach (object anObj in anim.Items) { animation anm = anObj as animation; if (anm == null) { continue; } mName = anim.name; SubAnimation sa = new SubAnimation(anm); mSubAnims.Add(sa); } } else { SubAnimation sa = new SubAnimation(anim); mSubAnims.Add(sa); } }
// Update is called once per frame void Update() { if (isDead && deathtime < Time.realtimeSinceStartup) { UnityEngine.SceneManagement.SceneManager.LoadScene("Death"); } if (!isDead) { currentSpeed = moveSpeed * Time.timeScale; if (isHurt > Time.realtimeSinceStartup) { setFalse(thisAnimator); thisAnimator.SetBool("IsHurt", true); thisRender.color = new Color(1, 0.66f, 0.66f); if (isHurt - 1 > Time.realtimeSinceStartup) { thisRender.color = new Color(1, 0.5f, 0.5f); } moveSpeed = 0.02f; } else { thisRender.color = Color.white; moveSpeed = 0.05f; } if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) && isHurt < Time.realtimeSinceStartup + 1) { setIdle(thisAnimator); } if (isSwinging == false && isHurt < Time.realtimeSinceStartup + 1 && currentSpeed > 0)//cant slash and move { if (Input.GetKey(KeyCode.W)) { this.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + currentSpeed); setFalse(thisAnimator); thisAnimator.SetBool("walkUp", true); currentAnimation = animation.walkUp; CurrentDirection = direction.up; } if (Input.GetKey(KeyCode.S)) { this.transform.position = new Vector2(this.transform.position.x, this.transform.position.y - currentSpeed); currentAnimation = animation.walkDown; setFalse(thisAnimator); thisAnimator.SetBool("walkDown", true); CurrentDirection = direction.down; } if (Input.GetKey(KeyCode.A)) { this.transform.position = new Vector2(this.transform.position.x - currentSpeed, this.transform.position.y); CurrentDirection = direction.left; setFalse(thisAnimator); thisAnimator.SetBool("walkSideways", true); thisRender.flipX = false; } if (Input.GetKey(KeyCode.D)) { this.transform.position = new Vector2(this.transform.position.x + currentSpeed, this.transform.position.y); CurrentDirection = direction.right; setFalse(thisAnimator); thisAnimator.SetBool("walkSideways", true); thisRender.flipX = true; } if (Input.GetKey(KeyCode.Space)) { isSwinging = true; StartCoroutine("SlashWait"); switch (Random.Range(0, 3)) { case 0: AudioManager.Get().PlaySfxOnce(AudioManager.SFX.Slas_Stick_1); break; case 1: AudioManager.Get().PlaySfxOnce(AudioManager.SFX.Slas_Stick_2); break; case 2: AudioManager.Get().PlaySfxOnce(AudioManager.SFX.Slas_Stick_3); break; } switch (CurrentDirection) { case direction.up: setFalse(thisAnimator); thisAnimator.SetBool("swingUp", true); break; case direction.down: setFalse(thisAnimator); thisAnimator.SetBool("swingDown", true); break; case direction.left: setFalse(thisAnimator); thisAnimator.SetBool("swingLeft", true); break; case direction.right: setFalse(thisAnimator); thisAnimator.SetBool("swingLeft", true); break; } } if (Input.GetKey(KeyCode.LeftShift)) { if (CurrentBomb == null) { AudioManager.Get().PlaySfxOnce(AudioManager.SFX.Place_Bomb); CurrentBomb = GameObject.Instantiate(Bomb); switch (CurrentDirection) { case direction.up: CurrentBomb.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 0.66f); break; case direction.down: CurrentBomb.transform.position = new Vector2(this.transform.position.x, this.transform.position.y - 0.66f); break; case direction.left: CurrentBomb.transform.position = new Vector2(this.transform.position.x - 0.66f, this.transform.position.y); break; case direction.right: CurrentBomb.transform.position = new Vector2(this.transform.position.x + 0.66f, this.transform.position.y); break; } } } } } }
private void label5_Click(object sender, EventArgs e) { animation anime = new animation(); animation.util.Animatte(pnlPomodoro, animation.util.effect.Slide, 180, 0); }
public Antagonist() : base("Ryn", "ryn", 7, 150, 200, new Vector2(0, 0), 20000, 0, 200, 0, 0, 0, 0, false) { animTex = new animation[] { new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynIdle"), 10, 5, 50), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynMove"), 10, 4, 31), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynCry"), 10, 7, 62), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynCryAura"), 10, 7, 62), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynStandCry"), 3, 1, 3), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynDying"), 10, 8, 75), new animation(Game1.Ressources.Load <Texture2D>("Bosses/Ryn/RynIsDead"), 10, 2, 12) }; currentEntityState = 2; nextEntityState = 2; sizeInAnim = new Vector2[] { new Vector2(800, 2375) * 4, new Vector2(3000, 2450) * 4, new Vector2(2400, 1350) * 4, new Vector2(3580, 670) * 4, new Vector2(5450, 670) * 4, new Vector2(6250, 2100) * 4, new Vector2(6250, 2100) * 4 }; //Banshee, BeeShocking, FireRocky, IceCollossus, Skeleton enemyTemplates = JsonConvert.DeserializeObject <List <Enemy> >(File.ReadAllText("Ressources\\json-files\\enemyTemplates.json")).ToArray(); Dialogues = new NSC(name, "none", mass, height, width, position, health, damage); Dialogues.dialogues = new Conversation[] { new Conversation(new string[] { "Ryn" }, new string[] { "" }), new Conversation(new string[] { "Ryn" }, new string[] { "Where am I...?" }), new Conversation(new string[] { "Ryn" }, new string[] { "Aaaaah! Don't come near me!" }), new Conversation(new string[] { "Ryn" }, new string[] { "Go away! Go away!" }), new Conversation(new string[] { "Ryn" }, new string[] { "Why won't you go away?... Stay away!" }), new Conversation(new string[] { "Ryn" }, new string[] { "... Uuh... No!" }), new Conversation(new string[] { "Ryn" }, new string[] { "Don't come... please... *sobs* I... Sis... *sobs*" }), new Conversation(new string[] { "Ryn" }, new string[] { "..." }) }; locations = new Vector2[] { new Vector2(800, 2385) * 4, new Vector2(3000, 2445) * 4, new Vector2(2400, 1370) * 4, new Vector2(3580, 660) * 4, new Vector2(5450, 665) * 4, new Vector2(6250, 2120) * 4, new Vector2(6250, 2123) * 4 }; currentLocation = 5; position = locations[currentLocation] - Camera.Main.position; hurtBox.X = (int)position.X; hurtBox.Y = (int)position.Y; hurtBox.Width = width; hurtBox.Height = height; Level.Current.enemyObjects.Add(this); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorUtility.SetDirty(target); animationComponent ac = (animationComponent)target; int numAnims = 0; if (ac.animations != null) { numAnims = ac.animations.Length; } numAnims = EditorGUILayout.IntField("Animation count", numAnims); if (numAnims < 0) { numAnims = 0; } if (ac.animations == null || (ac.animations != null && numAnims != ac.animations.Length)) { animation[] newA = new animation[numAnims]; for (int i = 0; i < newA.Length; i++) { if (i < ac.animations.Length) { newA[i] = ac.animations[i]; } else { newA[i] = new animation(ac.transform.parent.gameObject.GetComponent <charComponent>(), i); } } ac.animations = newA; } if (GUILayout.Button("Add a Animation")) { animation[] newA = new animation[ac.animations.Length + 1]; for (int i = 0; i < ac.animations.Length; i++) { newA[i] = ac.animations[i]; } newA[ac.animations.Length] = new animation(ac.transform.parent.gameObject.GetComponent <charComponent>(), ac.animations.Length); ac.animations = newA; } if (ac.animations != null) { foldAnimations = EditorGUILayout.Foldout(foldAnimations, "Show Animations"); EditorGUI.indentLevel++; for (int i = 0; i < ac.animations.Length; i++) { ac.animations[i].fold = EditorGUILayout.Foldout(ac.animations[i].fold, ac.animations[i].name); if (ac.animations[i].fold) { EditorGUI.indentLevel++; EditorGUILayout.LabelField("Index " + ac.animations[i].index); ac.animations[i].name = EditorGUILayout.TextField("Name", ac.animations[i].name); int numFrameLists = 0; if (ac.animations[i].frames != null) { numFrameLists = ac.animations[i].frames.Length; } EditorGUILayout.LabelField("Frame Count " + numFrameLists); if (GUILayout.Button("Add a Frame")) { frameList[] newf = new frameList[numFrameLists + 1]; int[] times = new int[numFrameLists + 1]; int[] nexts = new int[numFrameLists + 1]; bool[] xFlips = new bool[numFrameLists + 1]; bool[] yFlips = new bool[numFrameLists + 1]; bool[] foldFrames = new bool[numFrameLists + 1]; charComponentAction[] StartAction = new charComponentAction[numFrameLists + 1]; charComponentAction[] EndAction = new charComponentAction[numFrameLists + 1]; for (int j = 0; j < numFrameLists; j++) { newf[j] = ac.animations[i].frames[j]; times[j] = ac.animations[i].times[j]; nexts[j] = ac.animations[i].nexts[j]; xFlips[j] = ac.animations[i].xFlips[j]; yFlips[j] = ac.animations[i].yFlips[j]; foldFrames[j] = ac.animations[i].foldFrames[j]; StartAction[j] = ac.animations[i].StartAction[j]; EndAction[j] = ac.animations[i].EndAction[j]; } newf[numFrameLists] = new frameList(); times[numFrameLists] = 1; nexts[numFrameLists] = numFrameLists + 1; xFlips[numFrameLists] = false; yFlips[numFrameLists] = false; foldFrames[numFrameLists] = false; StartAction[numFrameLists] = default(charComponentAction); EndAction[numFrameLists] = default(charComponentAction); ac.animations[i].frames = newf; ac.animations[i].times = times; ac.animations[i].nexts = nexts; ac.animations[i].xFlips = xFlips; ac.animations[i].yFlips = yFlips; ac.animations[i].foldFrames = foldFrames; ac.animations[i].StartAction = StartAction; ac.animations[i].EndAction = EndAction; } if (ac.animations[i].frames != null) { selectedGC = (graphicComponent)EditorGUILayout.ObjectField(selectedGC, typeof(graphicComponent), true); if (selectedGC != null && selectedGC.allFrames != null && selectedGC.allFrames.Length > 0) { string[] names = new string[selectedGC.allFrames.Length]; for (int k = 0; k < selectedGC.allFrames.Length; k++) { names[k] = selectedGC.allFrames[k].name; } selectedFrame = EditorGUILayout.Popup("Frames", selectedFrame, names); EditorGUILayout.ObjectField(selectedGC.allFrames[selectedFrame].mainSprite, typeof(Sprite), true, GUILayout.Width(112), GUILayout.Height(64)); EditorGUILayout.LabelField("X: " + selectedGC.allFrames[selectedFrame].mainPosX + " Y: " + selectedGC.allFrames[selectedFrame].mainPosY); EditorGUILayout.LabelField("Flip X: " + selectedGC.allFrames[selectedFrame].GlobalFlipX + " Flip Y: " + selectedGC.allFrames[selectedFrame].GlobalFlipX); } for (int j = 0; j < ac.animations[i].frames.Length; j++) { ac.animations[i].foldFrames[j] = EditorGUILayout.Foldout(ac.animations[i].foldFrames[j], "Frame " + (j + 1)); if (ac.animations[i].foldFrames[j]) { EditorGUI.indentLevel++; if (GUILayout.Button("Add")) { ac.animations[i].frames[j].frames.Add(selectedGC.allFrames[selectedFrame]); } foreach (frame f in ac.animations[i].frames[j].frames) { f.fold = EditorGUILayout.Foldout(f.fold, f.name); if (f.fold) { EditorGUI.indentLevel++; EditorGUILayout.ObjectField(f.mainSprite, typeof(Sprite), true, GUILayout.Width(128), GUILayout.Height(64)); EditorGUILayout.LabelField("X: " + f.mainPosX + " Y: " + f.mainPosY); EditorGUILayout.LabelField("Flip X: " + f.GlobalFlipX + " Flip Y: " + f.GlobalFlipX); int ind = ac.animations[i].frames[j].frames.IndexOf(f); if (GUILayout.Button("Change")) { ac.animations[i].frames[j].frames[ind] = selectedGC.allFrames[selectedFrame]; } if (GUILayout.Button("Refresh")) { ac.animations[i].frames[j].frames[ind] = selectedGC.allFrames[ac.animations[i].frames[j].frames[ind].index]; } if (GUILayout.Button("Delete")) { ac.animations[i].frames[j].frames.RemoveAt(ind); break; } if (ind != 0 && GUILayout.Button("Up")) { frame faux = ac.animations[i].frames[j].frames[ind - 1]; ac.animations[i].frames[j].frames[ind - 1] = f; ac.animations[i].frames[j].frames[ind] = faux; } if (ind != ac.animations[i].frames[j].frames.Count - 1 && GUILayout.Button("Down")) { frame faux = ac.animations[i].frames[j].frames[ind + 1]; ac.animations[i].frames[j].frames[ind + 1] = f; ac.animations[i].frames[j].frames[ind] = faux; } if (GUILayout.Button("Use")) { f.Use(); } EditorGUI.indentLevel--; } } EditorGUI.indentLevel--; ac.animations[i].nexts[j] = EditorGUILayout.IntField("Next", ac.animations[i].nexts[j]); ac.animations[i].times[j] = EditorGUILayout.IntField("Time", ac.animations[i].times[j]); ac.animations[i].xFlips[j] = EditorGUILayout.Toggle("X Flip", ac.animations[i].xFlips[j]); ac.animations[i].yFlips[j] = EditorGUILayout.Toggle("Y Flip", ac.animations[i].yFlips[j]); } } } EditorGUI.indentLevel--; } } EditorGUI.indentLevel--; } EditorUtility.SetDirty(target); }
// Start is called before the first frame update void Start() { coll = GetComponent <Collision>(); rb = GetComponent <Rigidbody2D>(); anim = GetComponentInChildren <animation>(); }
public void SetRotational() { anim = null; SetTexture(_rotTex); dodirectional = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); backgscroll = new scrollingbackground(Content, "space", 1, 5, 5); gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight); for (int i = 0; i < numberofballs; i++) { float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio; if (tempsize < miniballsize) tempsize = miniballsize; balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize, new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser); } collidesound = Content.Load<SoundEffect>("rocks"); soundtrack1 = Content.Load<SoundEffect>("explosive_attack"); music1 = soundtrack1.CreateInstance(); music1.IsLooped = true; music1.Volume = 0.5f; soundtrack2 = Content.Load<SoundEffect>("iron-man"); music2 = soundtrack2.CreateInstance(); music2.IsLooped = true; music2.Volume = 0.5f; mainfont = Content.Load<SpriteFont>("quartz4"); for (int i = 0; i < numberofballs; i++) { explosion[i] = new animation(Content, "effect_005", 0, 0, 1f, Color.White, false, 24, 4, 5, false); } shiphit[0] = new animation(Content, "effect_003", 0, 0, 1, Color.White, false, 24, 5, 5, false); shiphit[1] = new animation(Content, "effect_002", 0, 0, 1, Color.White, false, 24, 4, 5, false); bullet[0] = new ammo(Content, "bullet1", 0, 0, .1f, Color.White, false); bullet[1] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); for (int b = 0; b < numberofbullets; b++) for (int s = 0; s < numberofships; s++) bullets5[s, b] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); reset(); }
public void SetAnimation(animation anim) { _anim = anim; }
public List <animation> ExportTransform(IList <Keyframe> keyframes, string name, string target) { var anims = new List <animation>(); var inputs = new List <InputLocal>(); var outputs = new List <float>(keyframes.Count * 16); foreach (var keyframe in keyframes) { var transform = Matrix4.Identity; if (keyframe.hasRotation) { transform *= Matrix4.CreateFromQuaternion(keyframe.rotation.Inverted()); } if (keyframe.hasScaleShear) { var scaleShear = Matrix4.Identity; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { scaleShear[i, j] = keyframe.scaleShear[i, j]; } } transform *= scaleShear; } if (keyframe.hasTranslation) { transform[0, 3] += keyframe.translation[0]; transform[1, 3] += keyframe.translation[1]; transform[2, 3] += keyframe.translation[2]; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { outputs.Add(transform[i, j]); } } } var interpolations = new List <string>(keyframes.Count); for (int i = 0; i < keyframes.Count; i++) { // TODO: Add control point estimation code and add in/out tangents for Bezier //interpolations.Add("BEZIER"); interpolations.Add("LINEAR"); } var knots = new List <float>(keyframes.Count); foreach (var keyframe in keyframes) { knots.Add(keyframe.time); } /* * Fix up animations that have only one keyframe by adding another keyframe at * the end of the animation. * (This mainly applies to DaIdentity and DnConstant32f) */ if (keyframes.Count == 1) { knots.Add(ParentAnimation.Duration); for (int i = 0; i < 16; i++) { outputs.Add(outputs[i]); } interpolations.Add(interpolations[0]); } var knotsSource = ColladaUtils.MakeFloatSource(name, "inputs", new string[] { "TIME" }, knots.ToArray()); var knotsInput = new InputLocal(); knotsInput.semantic = "INPUT"; knotsInput.source = "#" + knotsSource.id; inputs.Add(knotsInput); var outSource = ColladaUtils.MakeFloatSource(name, "outputs", new string[] { "TRANSFORM" }, outputs.ToArray(), 16, "float4x4"); var outInput = new InputLocal(); outInput.semantic = "OUTPUT"; outInput.source = "#" + outSource.id; inputs.Add(outInput); var interpSource = ColladaUtils.MakeNameSource(name, "interpolations", new string[] { "INTERPOLATION" }, interpolations.ToArray()); var interpInput = new InputLocal(); interpInput.semantic = "INTERPOLATION"; interpInput.source = "#" + interpSource.id; inputs.Add(interpInput); var sampler = new sampler(); sampler.id = name + "_sampler"; sampler.input = inputs.ToArray(); var channel = new channel(); channel.source = "#" + sampler.id; channel.target = target; var animation = new animation(); animation.id = name; animation.name = name; var animItems = new List <object>(); animItems.Add(knotsSource); animItems.Add(outSource); animItems.Add(interpSource); animItems.Add(sampler); animItems.Add(channel); animation.Items = animItems.ToArray(); anims.Add(animation); return(anims); }
public void Export(string filePath) { PalletProperties palletProperties = _palletSolution.Analysis.PalletProperties; COLLADA model = new COLLADA(); // asset model.asset = new asset() { created = DateTime.Now, modified = DateTime.Now }; model.asset.keywords = "StackBuilder Pallet Case"; model.asset.title = _palletSolution.Title; model.asset.unit = new assetUnit() { name = "millimeters", meter = 0.001 }; model.asset.up_axis = UpAxisType.Z_UP; library_images images = new library_images(); library_materials materials = new library_materials(); library_effects effects = new library_effects(); library_geometries geometries = new library_geometries(); library_nodes nodes = new library_nodes(); library_cameras cameras = new library_cameras(); library_animations animations = new library_animations(); library_visual_scenes scenes = new library_visual_scenes(); COLLADAScene colladaScene = new COLLADAScene(); model.Items = new Object[] { images, materials, effects, geometries, nodes, cameras, animations, scenes }; model.scene = colladaScene; // colors and materials List <effect> listEffects = new List <effect>(); List <material> listMaterials = new List <material>(); List <image> listImages = new List <image>(); // effects effect effectPallet; material materialPallet; CreateMaterial(palletProperties.Color, null, null, "Pallet", out effectPallet, out materialPallet); listEffects.Add(effectPallet); listMaterials.Add(materialPallet); Box box = new Box(0, _palletSolution.Analysis.BProperties); // build list of effects / materials / images uint faceIndex = 0; foreach (Face face in box.Faces) { // build texture image if any string textureName = null; if (face.HasBitmap) { textureName = string.Format("textureFace_{0}", faceIndex); string texturePath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(filePath) , textureName + ".jpg"); double dimX = 0.0, dimY = 0.0; switch (faceIndex) { case 0: dimX = box.Width; dimY = box.Height; break; case 1: dimX = box.Width; dimY = box.Height; break; case 2: dimX = box.Length; dimY = box.Height; break; case 3: dimX = box.Length; dimY = box.Height; break; case 4: dimX = box.Length; dimY = box.Width; break; case 5: dimX = box.Length; dimY = box.Width; break; default: break; } face.ExtractFaceBitmap(dimX, dimY, _bmpWidth, texturePath); // create image listImages.Add( new image() { id = textureName + ".jpg", name = textureName + ".jpg", Item = @".\" + textureName + @".jpg" } ); } material materialCase; effect effectCase; CreateMaterial(face.ColorFill, textureName, "0", string.Format("Case{0}", faceIndex), out effectCase, out materialCase); listEffects.Add(effectCase); listMaterials.Add(materialCase); ++faceIndex; } // add to image list images.image = listImages.ToArray(); // case lines material effect effectCaseLines; material materialCaseLines; CreateMaterial(Color.Black, null, null, "CaseLines", out effectCaseLines, out materialCaseLines); listEffects.Add(effectCaseLines); listMaterials.Add(materialCaseLines); effects.effect = listEffects.ToArray(); materials.material = listMaterials.ToArray(); // geometries geometry geomPallet = new geometry() { id = "palletGeometry", name = "palletGeometry" }; geometry geomCase = new geometry() { id = "caseGeometry", name = "caseGeometry" }; geometries.geometry = new geometry[] { geomPallet, geomCase }; // pallet mesh meshPallet = CreatePalletMesh(palletProperties); geomPallet.Item = meshPallet; // case mesh meshCase = CreateCaseMesh(_palletSolution.Analysis.BProperties as BoxProperties); geomCase.Item = meshCase; // library_animations animation animationMain = new animation() { id = "animationMain_ID", name = "animationMain" }; animations.animation = new animation[] { animationMain }; List <object> listAnimationSource = new List <object>(); // library_visual_scenes visual_scene mainScene = new visual_scene() { id = "MainScene", name = "MainScene" }; scenes.visual_scene = new visual_scene[] { mainScene }; List <node> sceneNodes = new List <node>(); sceneNodes.Add(new node() { id = "PalletNode", name = "PalletNode", instance_geometry = new instance_geometry[] { new instance_geometry() { url = "#palletGeometry", bind_material = new bind_material() { technique_common = new instance_material[] { new instance_material() { symbol = "materialPallet", target = string.Format("#{0}", materialPallet.id) } } } } } }); uint caseIndex = 0; foreach (ILayer layer in _palletSolution) { BoxLayer bLayer = layer as BoxLayer; if (null == bLayer) { continue; } foreach (BoxPosition bp in bLayer) { Vector3D translation = bp.Position; Vector3D rotations = bp.Transformation.Rotations; node caseNode = new node() { id = string.Format("CaseNode_{0}_ID", caseIndex), name = string.Format("CaseNode_{0}", caseIndex), ItemsElementName = new ItemsChoiceType2[] { ItemsChoiceType2.translate, ItemsChoiceType2.rotate, ItemsChoiceType2.rotate, ItemsChoiceType2.rotate }, Items = new object[] { new TargetableFloat3() { Values = new double[] { translation.X, translation.Y, translation.Z }, sid = "t", }, new rotate() { Values = new double[] { 1.0, 0.0, 0.0, rotations.X }, sid = "rx" }, new rotate() { Values = new double[] { 0.0, 1.0, 0.0, rotations.Y }, sid = "ry" }, new rotate() { Values = new double[] { 0.0, 0.0, 1.0, rotations.Z }, sid = "rz" } }, instance_geometry = new instance_geometry[] { new instance_geometry() { url = "#caseGeometry", bind_material = new bind_material() { technique_common = new instance_material[] { new instance_material() { symbol = "materialCase0", target = "#material_Case0_ID" }, new instance_material() { symbol = "materialCase1", target = "#material_Case1_ID" }, new instance_material() { symbol = "materialCase2", target = "#material_Case2_ID" }, new instance_material() { symbol = "materialCase3", target = "#material_Case3_ID" }, new instance_material() { symbol = "materialCase4", target = "#material_Case4_ID" }, new instance_material() { symbol = "materialCase5", target = "#material_Case5_ID" }, new instance_material() { symbol = "materialCaseLines", target = "#material_CaseLines_ID" } } } } } }; sceneNodes.Add(caseNode); // animations CreateAnimation(caseIndex, (uint)_palletSolution.CaseCount, listAnimationSource, bp); // increment case index ++caseIndex; } } // add nodes mainScene.node = sceneNodes.ToArray(); animationMain.Items = listAnimationSource.ToArray(); // library_cameras camera cameraCamera = new camera() { id = "Camera-Camera", name = "Camera-Camera" }; cameraOpticsTechnique_commonPerspective cameraPerspective = new cameraOpticsTechnique_commonPerspective() { znear = new TargetableFloat() { sid = "znear", Value = 1.0 }, zfar = new TargetableFloat() { sid = "zfar", Value = 10000.0 } }; cameraCamera.optics = new cameraOptics() { technique_common = new cameraOpticsTechnique_common() { Item = cameraPerspective } }; cameras.camera = new camera[] { cameraCamera }; // colladaScene colladaScene.instance_visual_scene = new InstanceWithExtra() { url = "#MainScene" }; model.Save(filePath); model.Save(System.IO.Path.ChangeExtension(filePath, "xml")); }
public void startAnimationFromAnotherAnimation(animation animation) { currentIndex = animation.currentIndex; UseFrame(currentIndex); currentTime = animation.currentTime; }
public List <animation> ExportTransform(string name, string target) { var anims = new List <animation>(); if (NumKnots() > 0) { var inputs = new List <InputLocal>(); var numKnots = NumKnots(); var knots = GetKnots(); var outputs = new List <float>(knots.Count * 16); var quats = GetQuaternions(); foreach (var rotation in quats) { var transform = Matrix4.CreateFromQuaternion(rotation); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { outputs.Add(transform[i, j]); } } } var interpolations = new List <string>(numKnots); for (int i = 0; i < numKnots; i++) { // TODO: Add control point estimation code and add in/out tangents for Bezier //interpolations.Add("BEZIER"); interpolations.Add("LINEAR"); } /* * Fix up animations that have only one keyframe by adding another keyframe at * the end of the animation. * (This mainly applies to DaIdentity and DnConstant32f) */ if (numKnots == 1) { knots.Add(ParentAnimation.Duration); for (int i = 0; i < 16; i++) { outputs.Add(outputs[i]); } interpolations.Add(interpolations[0]); } var knotsSource = ColladaUtils.MakeFloatSource(name, "inputs", new string[] { "TIME" }, knots.ToArray()); var knotsInput = new InputLocal(); knotsInput.semantic = "INPUT"; knotsInput.source = "#" + knotsSource.id; inputs.Add(knotsInput); var outSource = ColladaUtils.MakeFloatSource(name, "outputs", new string[] { "TRANSFORM" }, outputs.ToArray(), 16, "float4x4"); var outInput = new InputLocal(); outInput.semantic = "OUTPUT"; outInput.source = "#" + outSource.id; inputs.Add(outInput); var interpSource = ColladaUtils.MakeNameSource(name, "interpolations", new string[] { "" }, interpolations.ToArray()); var interpInput = new InputLocal(); interpInput.semantic = "INTERPOLATION"; interpInput.source = "#" + interpSource.id; inputs.Add(interpInput); var sampler = new sampler(); sampler.id = name + "_sampler"; sampler.input = inputs.ToArray(); var channel = new channel(); channel.source = "#" + sampler.id; channel.target = target; var animation = new animation(); animation.id = name; animation.name = name; var animItems = new List <object>(); animItems.Add(knotsSource); animItems.Add(outSource); animItems.Add(interpSource); animItems.Add(sampler); animItems.Add(channel); animation.Items = animItems.ToArray(); anims.Add(animation); } return(anims); }
private void button2_Click(object sender, EventArgs e) { animation anime = new animation(); animation.util.Animatte(pnlCalendario, animation.util.effect.Slide, 180, 0); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load in high scores if (File.Exists(@"highscore.txt")) // This checks to see if the file exists { StreamReader sr = new StreamReader(@"highscore.txt"); // Open the file String line; // Create a string variable to read each line into for (int i = 0; i < numberofhighscores && !sr.EndOfStream; i++) { line = sr.ReadLine(); // Read the first line in the text file highscorenames[i] = line.Trim(); // Read high score name if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file line = line.Trim(); // This trims spaces from either side of the text highscores[i] = (int)Convert.ToDecimal(line); // This converts line to numeric } } sr.Close(); // Close the file } Array.Sort(highscores, highscorenames); Array.Reverse(highscores); Array.Reverse(highscorenames); collectgoodfood = new animation(Content, "magic_008", 0, 0, 2, Color.White, false, 26, 3, 5); collectbadfood = new animation(Content, "magic_008", 0, 0, 2, Color.Red, false, 26, 3, 5); death = Content.Load <SoundEffect>("ballhit"); mainfont = Content.Load <SpriteFont>("font"); //Loads Font background.image = Content.Load <Texture2D>("Main_Menu"); //Loads Menu Background background.rect.Y = 0; background.rect.X = 0; background.rect.Width = displaywidth; background.rect.Height = displayheight; controls.image = Content.Load <Texture2D>("controls"); //Loads Controls controls.rect.Y = 0; controls.rect.X = 0; controls.rect.Width = displaywidth; controls.rect.Height = displayheight; soundtrack1 = Content.Load <SoundEffect>("explosive_attack"); music1 = soundtrack1.CreateInstance(); music1.IsLooped = true; music1.Volume = 0.35f; gamebackground.image = Content.Load <Texture2D>("desert_BG"); //Loads Game Background gamebackground.position.Y = 0; gamebackground.position.X = 0; gamebackground.rect.Width = displaywidth; gamebackground.rect.Height = displayheight; gamebackground.velocity = new Vector3(-2, 0, 0); gamebackground2.image = Content.Load <Texture2D>("desert_BG"); //Loads Scrolling Background gamebackground2.position.Y = 0; gamebackground2.position.X = displaywidth; gamebackground2.rect.Width = displaywidth; gamebackground2.rect.Height = displayheight; gamebackground2.velocity = new Vector3(-2, 0, 0); gameoverimage.image = Content.Load <Texture2D>("gameoverimage"); gameoverimage.rect.Y = 0; gameoverimage.rect.X = 0; gameoverimage.rect.Width = displaywidth; gameoverimage.rect.Height = displayheight; vicscreen.image = Content.Load <Texture2D>("victoryscreen1"); vicscreen.rect.Y = 0; vicscreen.rect.X = 0; vicscreen.rect.Width = displaywidth; vicscreen.rect.Height = displayheight; loadsprites(ref menuoptions[0, 0], "START", displaywidth / 2, 200, 1.25f); //Loads Menu Options loadsprites(ref menuoptions[0, 1], "START LOGO", displaywidth / 2, 200, 1.25f); loadsprites(ref menuoptions[1, 0], "CONTROLS (2)", displaywidth / 2, 300, 1.25f); loadsprites(ref menuoptions[1, 1], "CONTROLS BUTTON", displaywidth / 2, 300, 1.25f); loadsprites(ref menuoptions[2, 0], "HIGH SCORE", displaywidth / 2, 400, 1.25f); loadsprites(ref menuoptions[2, 1], "HIGH SCORE LOGO", displaywidth / 2, 400, 1.25f); loadsprites(ref menuoptions[3, 0], "EXIT", displaywidth / 2, 500, 1.25f); loadsprites(ref menuoptions[3, 1], "EXIT LOGO", displaywidth / 2, 500, 1.25f); playerjump = Content.Load <SoundEffect>("jump sound 1"); bananacollect = Content.Load <SoundEffect>("collectgfood"); menuchange = Content.Load <SoundEffect>("MENU A_Select"); //Loads Menu Sounds menuselect = Content.Load <SoundEffect>("menuSound"); for (int i = 0; i < numberofbadfood; i++) // load bad foods { if (i < 20) { bfood[i].image = Content.Load <Texture2D>("chipsPHG"); } if (i >= 20 && i < 40) { bfood[i].image = Content.Load <Texture2D>("CheeseburgerRage"); } if (i >= 40 && i < numberofbadfood) { bfood[i].image = Content.Load <Texture2D>("evilHotdog"); } bfood[i].origin.Y = bfood[i].image.Height / 2; bfood[i].origin.X = bfood[i].image.Width / 2; bfood[i].position.Y = 640; bfood[i].position.X = 400; bfood[i].rect.Width = (int)(bfood[i].image.Width * 0.3f); bfood[i].rect.Height = (int)(bfood[i].image.Height * 0.27f); } for (int i = 0; i < numberofgoodfood; i++) { gfood[i].image = Content.Load <Texture2D>("banana"); gfood[i].origin.Y = gfood[i].image.Height / 2; gfood[i].origin.X = gfood[i].image.Width / 2; gfood[i].position.Y = 300; gfood[i].position.X = 1200; gfood[i].rect.Width = (int)(gfood[i].image.Width / 2); gfood[i].rect.Height = (int)(gfood[i].image.Height / 2); gfood[i].velocity = new Vector3(-5, 0, 0); } List <Texture2D> textures = new List <Texture2D>(); textures.Add(Content.Load <Texture2D>("circle")); textures.Add(Content.Load <Texture2D>("star")); textures.Add(Content.Load <Texture2D>("diamond")); for (int i = 0; i < numberofgoodfood; i++) { particleEngine[i] = new ParticleEngine(textures, new Vector2(450, 420)); } spawnfood(); }
public List <animation> ExportKeyframeTrack(TransformTrack transformTrack, string name, string target) { var track = transformTrack.ToKeyframes(); track.MergeAdjacentFrames(); track.InterpolateFrames(); var anims = new List <animation>(); var inputs = new List <InputLocal>(); var outputs = new List <float>(track.Keyframes.Count * 16); foreach (var keyframe in track.Keyframes.Values) { var transform = keyframe.ToTransform().ToMatrix4(); transform.Transpose(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { outputs.Add(transform[i, j]); } } } var interpolations = new List <string>(track.Keyframes.Count); for (int i = 0; i < track.Keyframes.Count; i++) { interpolations.Add("LINEAR"); } var knots = new List <float>(track.Keyframes.Count); foreach (var keyframe in track.Keyframes) { knots.Add(keyframe.Key); } /* * Fix up animations that have only one keyframe by adding another keyframe at * the end of the animation. * (This mainly applies to DaIdentity and DnConstant32f) */ if (track.Keyframes.Count == 1) { knots.Add(transformTrack.ParentAnimation.Duration); for (int i = 0; i < 16; i++) { outputs.Add(outputs[i]); } interpolations.Add(interpolations[0]); } var knotsSource = ColladaUtils.MakeFloatSource(name, "inputs", new string[] { "TIME" }, knots.ToArray()); var knotsInput = new InputLocal(); knotsInput.semantic = "INPUT"; knotsInput.source = "#" + knotsSource.id; inputs.Add(knotsInput); var outSource = ColladaUtils.MakeFloatSource(name, "outputs", new string[] { "TRANSFORM" }, outputs.ToArray(), 16, "float4x4"); var outInput = new InputLocal(); outInput.semantic = "OUTPUT"; outInput.source = "#" + outSource.id; inputs.Add(outInput); var interpSource = ColladaUtils.MakeNameSource(name, "interpolations", new string[] { "INTERPOLATION" }, interpolations.ToArray()); var interpInput = new InputLocal(); interpInput.semantic = "INTERPOLATION"; interpInput.source = "#" + interpSource.id; inputs.Add(interpInput); var sampler = new sampler(); sampler.id = name + "_sampler"; sampler.input = inputs.ToArray(); var channel = new channel(); channel.source = "#" + sampler.id; channel.target = target; var animation = new animation(); animation.id = name; animation.name = name; var animItems = new List <object>(); animItems.Add(knotsSource); animItems.Add(outSource); animItems.Add(interpSource); animItems.Add(sampler); animItems.Add(channel); animation.Items = animItems.ToArray(); anims.Add(animation); return(anims); }
public animation ExportChannel(string name, string target, string paramName, int coordinate, bool isRotation) { var inputs = new List <InputLocal>(); var numKnots = NumKnots(); var knots = GetKnots(); var outputs = ExportChannelControlData(coordinate, isRotation); var interpolations = new List <string>(numKnots); for (int i = 0; i < numKnots; i++) { // TODO: Add control point estimation code and add in/out tangents for Bezier //interpolations.Add("BEZIER"); interpolations.Add("LINEAR"); } /* * Fix up animations that have only one keyframe by adding another keyframe at * the end of the animation. * (This mainly applies to DaIdentity and DnConstant32f) */ if (numKnots == 1) { knots.Add(ParentAnimation.Duration); outputs.Add(outputs[0]); interpolations.Add(interpolations[0]); } var knotsSource = ColladaUtils.MakeFloatSource(name, "inputs", new string[] { "TIME" }, knots.ToArray()); var knotsInput = new InputLocal(); knotsInput.semantic = "INPUT"; knotsInput.source = "#" + knotsSource.id; inputs.Add(knotsInput); var outSource = ColladaUtils.MakeFloatSource(name, "outputs", new string[] { paramName }, outputs.ToArray()); var outInput = new InputLocal(); outInput.semantic = "OUTPUT"; outInput.source = "#" + outSource.id; inputs.Add(outInput); var interpSource = ColladaUtils.MakeNameSource(name, "interpolations", new string[] { "" }, interpolations.ToArray()); var interpInput = new InputLocal(); interpInput.semantic = "INTERPOLATION"; interpInput.source = "#" + interpSource.id; inputs.Add(interpInput); var sampler = new sampler(); sampler.id = name + "_sampler"; sampler.input = inputs.ToArray(); var channel = new channel(); channel.source = "#" + sampler.id; channel.target = target; var animation = new animation(); animation.id = name; animation.name = name; var animItems = new List <object>(); animItems.Add(knotsSource); animItems.Add(outSource); animItems.Add(interpSource); animItems.Add(sampler); animItems.Add(channel); animation.Items = animItems.ToArray(); return(animation); }