public IceballMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/iceball.png") { Damage = damageInstance; Width = 64; Height = 64; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.IceballDistance; Speed = AbilityConstants.IceballSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.08)); deathAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.93f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.85f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.78f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.71f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.64f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.58f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.51f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 8, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.46f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 9, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.38f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 10, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.3f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 11, 0, 64, 64), TimeSpan.FromSeconds(0.08), DeathFunc); Animations.Add(deathAnimation); }
public FrostDemon(MapSection section) : base(EnemyTypes.FrostDemon, EnemyConstants.GetFrostDemonProperties(), "Entities/FrostDemon.png", section) { _ai = new RangeAI(this, EnemyConstants.FrostDemonAggroRange, EnemyConstants.FrostDemonWanderLength, new RangeAttack(this, 14, 17, MissileTypes.FrostDemonMissile, EnemyConstants.FrostDemonMissileCooldown)); HitboxSize = 0.93f; Width = 64; Height = 64; AttackRange = 400; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(0, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), SpawnedFunc); Animations.Add(spawnAnimation); var walkAnimation = new Animation(AnimationTypes.Move); walkAnimation.AddFrame(new Rectangle(TextureSize * 0, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 1, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 4, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 5, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 6, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 7, TextureSize * 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); Animations.Add(walkAnimation); var attackAnimation = new Animation(AnimationTypes.Attack); attackAnimation.AddFrame(new Rectangle(TextureSize * 0, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 1, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 2, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 3, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 4, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 5, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25), AttackedFunc); attackAnimation.AddFrame(new Rectangle(TextureSize * 6, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), DoneAttackingFunc); Animations.Add(attackAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25), OnDeath); dieAnimation.AddFrame(new Rectangle(TextureSize * 1, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 4, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 5, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 6, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 7, TextureSize * 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 1, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 4, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 5, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 6, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); dieAnimation.AddFrame(new Rectangle(TextureSize * 7, TextureSize * 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25), OnDeathFinished); Animations.Add(dieAnimation); }
public IcicleMissile(Zerd zerd, DamageInstance damageInstance, Point p, int index) : base("Missiles/icicle.png") { Damage = damageInstance; Width = 40; Height = 40; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.IcicleDistance; Speed = AbilityConstants.IcicleSpeed; Velocity = Creator.Facing.Normalized().Rotate(360f * index / 8); // Move the icicle away from the caster a bit X += Velocity.X * 45; Y -= Velocity.Y * 45; Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); }
public void ConvertAnimation(odfANIMSection anim, odfParser odaParser, bool odaSkeleton) { if (odaSkeleton) { FrameList.Clear(); ConvertFrames(odaParser.FrameSection.RootFrame); } ImportedKeyframedAnimation iAnim = new ImportedKeyframedAnimation(); AnimationList.Add(iAnim); iAnim.TrackList = new List <ImportedAnimationKeyframedTrack>(anim.Count); string notFound = String.Empty; foreach (odfTrack track in anim) { odfFrame boneFrame = odf.FindFrame(track.BoneFrameId, odaParser.FrameSection.RootFrame); if (boneFrame == null) { notFound += (notFound.Length > 0 ? ", " : "") + track.BoneFrameId; continue; } ImportedAnimationKeyframedTrack iTrack = new ImportedAnimationKeyframedTrack(); iAnim.TrackList.Add(iTrack); iTrack.Name = boneFrame.Name; iTrack.Keyframes = ConvertTrack(track.KeyframeList); } if (notFound.Length > 0) { Report.ReportLog("Warning: Animations weren't converted for the following missing frame IDs: " + notFound); } }
public LavaBlastMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/lava_blast.png") { Damage = damageInstance; Width = 86; Height = 86; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance * (1 + zerd.Player.AbilityUpgrades[AbilityUpgradeType.LavaBlastDistance] / 100f); Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized(); TargetsHit = new List <Being>(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03)); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.91f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.82f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.73f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.64f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.55f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.46f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.37f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.28f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.19f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.1f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), DeathFunc); Animations.Add(deathAnimation); }
public HealthPotion(Enemy dropper) : base("Consumables/potions.png", dropper) { Animations = new AnimationList(); var anim = new Animation(AnimationTypes.Stand); anim.AddFrame(new Rectangle(0, 537, 146, 155), TimeSpan.FromMilliseconds(100)); Animations.Add(anim); }
public Zombie(MapSection section) : base(EnemyTypes.Zombie, EnemyConstants.GetZombieProperties(), "Entities/Zombie.png", section) { _ai = new MeleeAI(this, EnemyConstants.ZombieAggroRange, new Melee(this, EnemyConstants.ZombieMinDamage, EnemyConstants.ZombieMaxDamage), EnemyConstants.ZombieWanderLength); HitboxSize = 0.8f; Width = 64; Height = 64; AttackRange = EnemyConstants.ZombieAttackRange; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(TextureSize * 13, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5)); spawnAnimation.AddFrame(new Rectangle(TextureSize * 14, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5)); spawnAnimation.AddFrame(new Rectangle(TextureSize * 14, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), SpawnedFunc); Animations.Add(spawnAnimation); var walkAnimation = new Animation(AnimationTypes.Move); walkAnimation.AddFrame(new Rectangle(TextureSize * 9, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 10, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 11, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 12, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); Animations.Add(walkAnimation); var attackAnimation = new Animation(AnimationTypes.Attack); attackAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.35)); attackAnimation.AddFrame(new Rectangle(TextureSize * 8, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4), AttackedFunc); attackAnimation.AddFrame(new Rectangle(TextureSize * 8, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1), DoneAttackingFunc); Animations.Add(attackAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1), OnDeath); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 2, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 3, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 4, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 5, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 0, 6, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1)); dieAnimation.AddFrame(new Rectangle(TextureSize * 6, 6, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1), OnDeathFinished); Animations.Add(dieAnimation); }
public Archer(MapSection section) : base(EnemyTypes.Archer, EnemyConstants.GetArcherProperties(), "Entities/Archer.png", section) { _ai = new RangeAI(this, EnemyConstants.ArcherAggroRange, EnemyConstants.ArcherWanderLength, new RangeAttack(this, 12, 18, MissileTypes.Arrow, EnemyConstants.ArcherArrowCooldown)); HitboxSize = 0.93f; Width = 64; Height = 64; AttackRange = 625; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(0, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), SpawnedFunc); Animations.Add(spawnAnimation); var walkAnimation = new Animation(AnimationTypes.Move); walkAnimation.AddFrame(new Rectangle(TextureSize * 0, TextureSize * 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 1, TextureSize * 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); walkAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); Animations.Add(walkAnimation); var attackAnimation = new Animation(AnimationTypes.Attack); attackAnimation.AddFrame(new Rectangle(TextureSize * 0, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 1, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); attackAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25), AttackedFunc); attackAnimation.AddFrame(new Rectangle(TextureSize * 2, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), DoneAttackingFunc); Animations.Add(attackAnimation); var hitAnimation = new Animation(AnimationTypes.Damaged); hitAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25)); Animations.Add(hitAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.35), OnDeath); dieAnimation.AddFrame(new Rectangle(TextureSize * 3, TextureSize * 1, TextureSize, TextureSize), TimeSpan.FromSeconds(0.25), OnDeathFinished); Animations.Add(dieAnimation); }
public FireballMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/fireball.png") { Damage = damageInstance; var size = 64f * zerd.SkillValue(SkillType.ImprovedFireball, true); Width = (int)size; Height = (int)size; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance; Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.1)); deathAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.92f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 8, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.84f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 9, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.76f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 10, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.68f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 11, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.6f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 12, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.5f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 13, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.4f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 14, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.3f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 15, 0, 64, 64), TimeSpan.FromSeconds(0.1), DeathFunc); Animations.Add(deathAnimation); }
public Dog(MapSection section) : base(EnemyTypes.Dog, EnemyConstants.GetDogProperties(), "Entities/Dog.png", section) { _ai = new MeleeAI(this, EnemyConstants.DogAggroRange, new Melee(this, 6, 8), EnemyConstants.DogWanderLength); HitboxSize = 0.8f; Width = 64; Height = 64; AttackRange = 48; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(TextureSize * 6, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5)); spawnAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5)); spawnAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.05), SpawnedFunc); Animations.Add(spawnAnimation); var walkAnimation = new Animation(AnimationTypes.Move); walkAnimation.AddFrame(new Rectangle(TextureSize * 2, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 3, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 4, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); walkAnimation.AddFrame(new Rectangle(TextureSize * 5, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4)); Animations.Add(walkAnimation); var attackAnimation = new Animation(AnimationTypes.Attack); attackAnimation.AddFrame(new Rectangle(TextureSize * 0, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.35)); attackAnimation.AddFrame(new Rectangle(TextureSize * 1, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.4), AttackedFunc); attackAnimation.AddFrame(new Rectangle(TextureSize * 1, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1), DoneAttackingFunc); Animations.Add(attackAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(TextureSize * 7, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5), OnDeath); dieAnimation.AddFrame(new Rectangle(TextureSize * 6, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.5)); dieAnimation.AddFrame(new Rectangle(TextureSize * 6, 0, TextureSize, TextureSize), TimeSpan.FromSeconds(0.1), OnDeathFinished); Animations.Add(dieAnimation); }
public void ConvertAnimation(reaANICsection animSection, remParser parser) { ImportedSampledAnimation anim = new ImportedSampledAnimation(); anim.TrackList = new List <ImportedAnimationSampledTrack>(animSection.Count); foreach (reaAnimationTrack track in animSection) { remBone boneFrame = rem.FindFrame(track.boneFrame, parser.BONC.rootFrame); bool isTopFrame = boneFrame != null && boneFrame.Parent == parser.BONC.rootFrame; ImportedAnimationSampledTrack iTrack = ConvertTrack(track, isTopFrame); anim.TrackList.Add(iTrack); } AnimationList.Add(anim); }
public FrostDemonMissile(Being being, DamageInstance damageInstance, Point p) : base("Missiles/orbs.png") { Damage = damageInstance; Width = 86; Height = 86; X = p.X; Y = p.Y; Creator = being; Origin = p; Distance = EnemyConstants.FrostDemonMissileLength; Speed = EnemyConstants.FrostDemonMissileSpeed; Velocity = Creator.Facing.Normalized().Rotate(Helpers.RandomInRange(-3, 3)); Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(32 * 9, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 10, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 11, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15), SpawnedFunc); Animations.Add(spawnAnimation); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 6, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 7, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 8, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 7, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(32 * 11, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 10, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 9, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 9, 32 * 6, 32, 32), TimeSpan.FromSeconds(0.15), DeathFunc); Animations.Add(dieAnimation); }
public WandMissile(Being being, DamageInstance damageInstance, Point p) : base("Missiles/orbs.png") { Damage = damageInstance; Width = 32; Height = 32; X = p.X; Y = p.Y; Origin = p; Creator = being; Distance = AbilityConstants.WandDistance * being.SkillValue(SkillType.ImprovedWand, true); Speed = AbilityConstants.WandSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(32 * 3, 0, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 4, 0, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 5, 0, 32, 32), TimeSpan.FromSeconds(0.15), SpawnedFunc); Animations.Add(spawnAnimation); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 2, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 0, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(32 * 5, 0, 32, 32), TimeSpan.FromSeconds(0.07)); dieAnimation.AddFrame(new Rectangle(32 * 4, 0, 32, 32), TimeSpan.FromSeconds(0.07)); dieAnimation.AddFrame(new Rectangle(32 * 3, 0, 32, 32), TimeSpan.FromSeconds(0.07)); dieAnimation.AddFrame(new Rectangle(32 * 3, 0, 32, 32), TimeSpan.FromSeconds(0.07), DeathFunc); Animations.Add(dieAnimation); }
public SkeletonKingMissile(Being being, DamageInstance damageInstance, Vector2 velocity) : base("Missiles/orbs.png") { Damage = damageInstance; Width = 96; Height = 96; X = being.X; Y = being.Y; Creator = being; Origin = being.Position; Distance = 1000f; Speed = 600f; Velocity = velocity; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 4, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 5, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15), SpawnedFunc); Animations.Add(spawnAnimation); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 2, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(32 * 5, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 4, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15), DeathFunc); Animations.Add(dieAnimation); }
public Key(Enemy dropper) : base("Consumables/key.png", dropper) { const float scale = 0.2f; Width = 134 * scale; Height = 218 * scale; HitboxSize = 2; Animations = new AnimationList(); var anim = new Animation(AnimationTypes.Stand, 134, 218); anim.AddFrame(0, 0, TimeSpan.FromMilliseconds(300)); anim.AddFrame(1, 0, TimeSpan.FromMilliseconds(200)); anim.AddFrame(2, 0, TimeSpan.FromMilliseconds(200)); anim.AddFrame(1, 0, TimeSpan.FromMilliseconds(300)); Animations.Add(anim); }
public ArrowMissile(Being being, DamageInstance damageInstance, Point p) : base("Missiles/arrow.png") { Damage = damageInstance; Width = 22; Height = 22; X = p.X; Y = p.Y; Creator = being; Origin = p; Distance = EnemyConstants.ArcherArrowLength; Speed = EnemyConstants.ArcherArrowSpeed; Velocity = Creator.Facing.Normalized().Rotate(Helpers.RandomInRange(-3, 3)); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(0, 0, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); }
public TreasureChest(Enemy dropper) : base("Items/treasure-chest.png", dropper) { const float scale = 0.45f; Width = 119 * scale; Height = 108 * scale; PotentialItems = new List <PotentialItem>(); AddItem(dropper, 1); AddItem(dropper, GameplayConstants.SecondItemChanceFactor); AddItem(dropper, GameplayConstants.ThirdItemChanceFactor); PotentialItems = PotentialItems.OrderByDescending(t => t.Item.Rarity).ToList(); Animations = new AnimationList(); var anim = new Animation(AnimationTypes.Stand); var x = (int)PotentialItems.First().Item.Rarity % 2 == 0 ? 119 : 0; var y = 108 * (int)Math.Floor(((int)PotentialItems.First().Item.Rarity - 1) / 2f); anim.AddFrame(new Rectangle(x, y, 119, 108), TimeSpan.FromMilliseconds(100)); Animations.Add(anim); }
public DragonBreathMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/dragons_breath.png") { Damage = damageInstance; Width = 26f; Height = 26f; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance; Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized().Rotate(Globals.Random.Next(11) - 5); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 0, 32, 32), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(32 * 1, 0, 32, 32), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(32 * 2, 0, 32, 32), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); }
public CharmMissile(Being being, Point p) : base("Missiles/charm.png") { Width = 44; Height = 44; X = p.X; Y = p.Y; Origin = p; Creator = being; Distance = AbilityConstants.CharmDistance; Speed = AbilityConstants.CharmSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 2, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 2, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 4, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 3, 0, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 4, 0, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); }
private void ConvertAnimations() { foreach (var assetPreloadData in animationClipHashSet) { var animationClip = new AnimationClip(assetPreloadData); var iAnim = new ImportedKeyframedAnimation(); AnimationList.Add(iAnim); iAnim.Name = animationClip.m_Name; iAnim.TrackList = new List <ImportedAnimationKeyframedTrack>(); if (animationClip.m_Legacy) { foreach (var m_CompressedRotationCurve in animationClip.m_CompressedRotationCurves) { var path = m_CompressedRotationCurve.m_Path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); var numKeys = m_CompressedRotationCurve.m_Times.m_NumItems; var data = m_CompressedRotationCurve.m_Times.UnpackInts(); var times = new float[numKeys]; int t = 0; for (int i = 0; i < numKeys; i++) { t += data[i]; times[i] = t * 0.01f; } var quats = m_CompressedRotationCurve.m_Values.UnpackQuats(); for (int i = 0; i < numKeys; i++) { var quat = quats[i]; var value = Fbx.QuaternionToEuler(new Quaternion(quat.X, -quat.Y, -quat.Z, quat.W)); track.Rotations.Add(new ImportedKeyframe <Vector3>(times[i], value)); } } foreach (var m_RotationCurve in animationClip.m_RotationCurves) { var path = m_RotationCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); foreach (var m_Curve in m_RotationCurve.curve.m_Curve) { var value = Fbx.QuaternionToEuler(new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W)); track.Rotations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, value)); } } foreach (var m_PositionCurve in animationClip.m_PositionCurves) { var path = m_PositionCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); foreach (var m_Curve in m_PositionCurve.curve.m_Curve) { track.Translations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(-m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z))); } } foreach (var m_ScaleCurve in animationClip.m_ScaleCurves) { var path = m_ScaleCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); foreach (var m_Curve in m_ScaleCurve.curve.m_Curve) { track.Scalings.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z))); } } if (animationClip.m_EulerCurves != null) { foreach (var m_EulerCurve in animationClip.m_EulerCurves) { var path = m_EulerCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); foreach (var m_Curve in m_EulerCurve.curve.m_Curve) { track.Rotations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z))); } } } foreach (var m_FloatCurve in animationClip.m_FloatCurves) { var path = m_FloatCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); foreach (var m_Curve in m_FloatCurve.curve.m_Curve) { track.Curve.Add(new ImportedKeyframe <float>(m_Curve.time, m_Curve.value)); } } } else { var m_Clip = animationClip.m_MuscleClip.m_Clip; var streamedFrames = m_Clip.m_StreamedClip.ReadData(); var m_ClipBindingConstant = animationClip.m_ClipBindingConstant; for (int frameIndex = 1; frameIndex < streamedFrames.Count - 1; frameIndex++) { var frame = streamedFrames[frameIndex]; var streamedValues = frame.keyList.Select(x => x.value).ToArray(); for (int curveIndex = 0; curveIndex < frame.keyList.Count;) { ReadCurveData(iAnim, m_ClipBindingConstant, frame.keyList[curveIndex].index, frame.time, streamedValues, 0, ref curveIndex); } } var m_DenseClip = m_Clip.m_DenseClip; var streamCount = m_Clip.m_StreamedClip.curveCount; for (int frameIndex = 0; frameIndex < m_DenseClip.m_FrameCount; frameIndex++) { var time = frameIndex / m_DenseClip.m_SampleRate; var frameOffset = frameIndex * m_DenseClip.m_CurveCount; for (int curveIndex = 0; curveIndex < m_DenseClip.m_CurveCount;) { var index = streamCount + curveIndex; ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time, m_DenseClip.m_SampleArray, (int)frameOffset, ref curveIndex); } } var m_ConstantClip = m_Clip.m_ConstantClip; var denseCount = m_Clip.m_DenseClip.m_CurveCount; var time2 = 0.0f; for (int i = 0; i < 2; i++) { for (int curveIndex = 0; curveIndex < m_ConstantClip.data.Length;) { var index = streamCount + denseCount + curveIndex; ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time2, m_ConstantClip.data, 0, ref curveIndex); } time2 = animationClip.m_MuscleClip.m_StopTime; } } if ((bool)Properties.Settings.Default["FixRotation"]) { foreach (var track in iAnim.TrackList) { var prevKey = new Vector3(); foreach (var rotation in track.Rotations) { var value = rotation.value; ReplaceOutOfBound(ref prevKey, ref value); prevKey = value; rotation.value = value; } } } } }
private void ConvertAnimations() { foreach (var animationClip in animationClipHashSet) { var iAnim = new ImportedKeyframedAnimation(); var name = animationClip.m_Name; if (AnimationList.Exists(x => x.Name == name)) { for (int i = 1; ; i++) { var fixName = name + $"_{i}"; if (!AnimationList.Exists(x => x.Name == fixName)) { name = fixName; break; } } } iAnim.Name = name; iAnim.SampleRate = animationClip.m_SampleRate; iAnim.TrackList = new List <ImportedAnimationKeyframedTrack>(); AnimationList.Add(iAnim); if (animationClip.m_Legacy) { foreach (var m_CompressedRotationCurve in animationClip.m_CompressedRotationCurves) { var track = iAnim.FindTrack(FixBonePath(m_CompressedRotationCurve.m_Path)); var numKeys = m_CompressedRotationCurve.m_Times.m_NumItems; var data = m_CompressedRotationCurve.m_Times.UnpackInts(); var times = new float[numKeys]; int t = 0; for (int i = 0; i < numKeys; i++) { t += data[i]; times[i] = t * 0.01f; } var quats = m_CompressedRotationCurve.m_Values.UnpackQuats(); for (int i = 0; i < numKeys; i++) { var quat = quats[i]; var value = Fbx.QuaternionToEuler(new Quaternion(quat.X, -quat.Y, -quat.Z, quat.W)); track.Rotations.Add(new ImportedKeyframe <Vector3>(times[i], value)); } } foreach (var m_RotationCurve in animationClip.m_RotationCurves) { var track = iAnim.FindTrack(FixBonePath(m_RotationCurve.path)); foreach (var m_Curve in m_RotationCurve.curve.m_Curve) { var value = Fbx.QuaternionToEuler(new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W)); track.Rotations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, value)); } } foreach (var m_PositionCurve in animationClip.m_PositionCurves) { var track = iAnim.FindTrack(FixBonePath(m_PositionCurve.path)); foreach (var m_Curve in m_PositionCurve.curve.m_Curve) { track.Translations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(-m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z))); } } foreach (var m_ScaleCurve in animationClip.m_ScaleCurves) { var track = iAnim.FindTrack(FixBonePath(m_ScaleCurve.path)); foreach (var m_Curve in m_ScaleCurve.curve.m_Curve) { track.Scalings.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z))); } } if (animationClip.m_EulerCurves != null) { foreach (var m_EulerCurve in animationClip.m_EulerCurves) { var track = iAnim.FindTrack(FixBonePath(m_EulerCurve.path)); foreach (var m_Curve in m_EulerCurve.curve.m_Curve) { track.Rotations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, new Vector3(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z))); } } } } else { var m_Clip = animationClip.m_MuscleClip.m_Clip; var streamedFrames = m_Clip.m_StreamedClip.ReadData(); var m_ClipBindingConstant = animationClip.m_ClipBindingConstant; for (int frameIndex = 1; frameIndex < streamedFrames.Count - 1; frameIndex++) { var frame = streamedFrames[frameIndex]; var streamedValues = frame.keyList.Select(x => x.value).ToArray(); for (int curveIndex = 0; curveIndex < frame.keyList.Length;) { ReadCurveData(iAnim, m_ClipBindingConstant, frame.keyList[curveIndex].index, frame.time, streamedValues, 0, ref curveIndex); } } var m_DenseClip = m_Clip.m_DenseClip; var streamCount = m_Clip.m_StreamedClip.curveCount; for (int frameIndex = 0; frameIndex < m_DenseClip.m_FrameCount; frameIndex++) { var time = m_DenseClip.m_BeginTime + frameIndex / m_DenseClip.m_SampleRate; var frameOffset = frameIndex * m_DenseClip.m_CurveCount; for (int curveIndex = 0; curveIndex < m_DenseClip.m_CurveCount;) { var index = streamCount + curveIndex; ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time, m_DenseClip.m_SampleArray, (int)frameOffset, ref curveIndex); } } if (m_Clip.m_ConstantClip != null) { var m_ConstantClip = m_Clip.m_ConstantClip; var denseCount = m_Clip.m_DenseClip.m_CurveCount; var time2 = 0.0f; for (int i = 0; i < 2; i++) { for (int curveIndex = 0; curveIndex < m_ConstantClip.data.Length;) { var index = streamCount + denseCount + curveIndex; ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time2, m_ConstantClip.data, 0, ref curveIndex); } time2 = animationClip.m_MuscleClip.m_StopTime; } } } } }
public SkeletonKing(MapSection section) : base(EnemyTypes.SkeletonKing, EnemyConstants.GetSkeletonKingProperties(), "Entities/Zomb-King.png", section) { _ai = new SkeletonKingAI(this, new Melee(this, EnemyConstants.SkeletonKingMinDamage, EnemyConstants.SkeletonKingMaxDamage, null, EnemyConstants.SkeletonKingKnockback, EnemyConstants.SkeletonKingKnockbackMillis), new SkeletonKingBlast(this)); HitboxSize = 0.8f; Width = 312; Height = 312; AttackRange = 130; Spawned = true; Animations = new AnimationList(); var walkAnimation = new Animation(AnimationTypes.Move, new BodyPart(BodyPartType.Custom, 470, 370)); walkAnimation.AddFrame(0, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(1, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(2, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(1, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(0, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(3, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(4, 0, TimeSpan.FromSeconds(0.3)); walkAnimation.AddFrame(3, 0, TimeSpan.FromSeconds(0.3)); Animations.Add(walkAnimation); var attackAnimation = new Animation(AnimationTypes.Attack, new BodyPart(BodyPartType.Custom, 470, 370)); attackAnimation.AddFrame(1, 1, TimeSpan.FromSeconds(0.05)); attackAnimation.AddFrame(2, 1, TimeSpan.FromSeconds(0.05)); attackAnimation.AddFrame(3, 1, TimeSpan.FromSeconds(0.05)); attackAnimation.AddFrame(4, 1, TimeSpan.FromSeconds(0.05)); attackAnimation.AddFrame(5, 1, TimeSpan.FromSeconds(0.05), Rotate); attackAnimation.AddFrame(6, 1, TimeSpan.FromSeconds(0.05), Rotate); attackAnimation.AddFrame(7, 1, TimeSpan.FromSeconds(0.05), Rotate); attackAnimation.AddFrame(0, 2, TimeSpan.FromSeconds(0.05), Rotate); attackAnimation.AddFrame(1, 2, TimeSpan.FromSeconds(0.05), AttackedFunc); attackAnimation.AddFrame(2, 2, TimeSpan.FromSeconds(0.05), Unrotate); attackAnimation.AddFrame(3, 2, TimeSpan.FromSeconds(0.05), Unrotate); attackAnimation.AddFrame(4, 2, TimeSpan.FromSeconds(0.05), Unrotate); attackAnimation.AddFrame(5, 2, TimeSpan.FromSeconds(0.05), Unrotate); attackAnimation.AddFrame(5, 2, TimeSpan.FromSeconds(0.05), DoneAttackingFunc); Animations.Add(attackAnimation); var castingAnimation = new Animation(AnimationTypes.FireAttack, new BodyPart(BodyPartType.Custom, 470, 370)); castingAnimation.AddFrame(7, 0, TimeSpan.FromSeconds(0.15), BecomeInvulnerable); castingAnimation.AddFrame(0, 1, TimeSpan.FromSeconds(0.65)); castingAnimation.AddFrame(7, 0, TimeSpan.FromSeconds(0.15)); castingAnimation.AddFrame(5, 0, TimeSpan.FromSeconds(0.1), CastedFunc); castingAnimation.AddFrame(6, 0, TimeSpan.FromSeconds(0.3)); castingAnimation.AddFrame(5, 0, TimeSpan.FromSeconds(0.15)); castingAnimation.AddFrame(5, 0, TimeSpan.FromSeconds(0.05), DoneAttackingFunc); Animations.Add(castingAnimation); var dieAnimation = new Animation(AnimationTypes.Death, new BodyPart(BodyPartType.Custom, 470, 370)); dieAnimation.AddFrame(6, 2, TimeSpan.FromSeconds(0.1), OnDeath); dieAnimation.AddFrame(7, 2, TimeSpan.FromSeconds(0.1), OnDeathFinished); Animations.Add(dieAnimation); var walkEnragedAnimation = new Animation(AnimationTypes.MoveEnraged, new BodyPart(BodyPartType.Custom, 470, 370)); walkEnragedAnimation.AddFrame(0, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(1, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(2, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(1, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(0, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(3, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(4, 3, TimeSpan.FromSeconds(0.22)); walkEnragedAnimation.AddFrame(3, 3, TimeSpan.FromSeconds(0.22)); Animations.Add(walkEnragedAnimation); var attackEnragedAnimation = new Animation(AnimationTypes.AttackEnraged, new BodyPart(BodyPartType.Custom, 470, 370)); attackEnragedAnimation.AddFrame(1, 4, TimeSpan.FromSeconds(0.04)); attackEnragedAnimation.AddFrame(2, 4, TimeSpan.FromSeconds(0.04)); attackEnragedAnimation.AddFrame(3, 4, TimeSpan.FromSeconds(0.04)); attackEnragedAnimation.AddFrame(4, 4, TimeSpan.FromSeconds(0.04)); attackEnragedAnimation.AddFrame(5, 4, TimeSpan.FromSeconds(0.04), Rotate); attackEnragedAnimation.AddFrame(6, 4, TimeSpan.FromSeconds(0.04), Rotate); attackEnragedAnimation.AddFrame(7, 4, TimeSpan.FromSeconds(0.04), Rotate); attackEnragedAnimation.AddFrame(0, 5, TimeSpan.FromSeconds(0.04), Rotate); attackEnragedAnimation.AddFrame(1, 5, TimeSpan.FromSeconds(0.04), AttackedFunc); attackEnragedAnimation.AddFrame(2, 5, TimeSpan.FromSeconds(0.04), Unrotate); attackEnragedAnimation.AddFrame(3, 5, TimeSpan.FromSeconds(0.04), Unrotate); attackEnragedAnimation.AddFrame(4, 5, TimeSpan.FromSeconds(0.04), Unrotate); attackEnragedAnimation.AddFrame(5, 5, TimeSpan.FromSeconds(0.04), Unrotate); attackEnragedAnimation.AddFrame(5, 5, TimeSpan.FromSeconds(0.04), DoneAttackingFunc); Animations.Add(attackEnragedAnimation); var castingEnragedAnimation = new Animation(AnimationTypes.FireAttackEnraged, new BodyPart(BodyPartType.Custom, 470, 370)); castingEnragedAnimation.AddFrame(7, 3, TimeSpan.FromSeconds(0.12), BecomeInvulnerable); castingEnragedAnimation.AddFrame(0, 4, TimeSpan.FromSeconds(0.25)); castingEnragedAnimation.AddFrame(7, 3, TimeSpan.FromSeconds(0.1)); castingEnragedAnimation.AddFrame(5, 3, TimeSpan.FromSeconds(0.1), CastedFunc); castingEnragedAnimation.AddFrame(6, 3, TimeSpan.FromSeconds(0.2)); castingEnragedAnimation.AddFrame(5, 3, TimeSpan.FromSeconds(0.12)); castingEnragedAnimation.AddFrame(5, 3, TimeSpan.FromSeconds(0.05), DoneAttackingFunc); Animations.Add(castingEnragedAnimation); var dieEnragedAnimation = new Animation(AnimationTypes.DeathEnraged, new BodyPart(BodyPartType.Custom, 470, 370)); dieEnragedAnimation.AddFrame(6, 5, TimeSpan.FromSeconds(0.1), OnDeath); dieEnragedAnimation.AddFrame(7, 5, TimeSpan.FromSeconds(0.1), OnDeathFinished); Animations.Add(dieEnragedAnimation); // Center the boss in the middle of the section X = Globals.Map.GetSection(this).Center.X; Y = Globals.Map.GetSection(this).Center.Y; }
private void ConvertAnimations() { foreach (var assetPreloadData in animationClipHashSet) { var clip = new AnimationClip(assetPreloadData); if (clip.m_Legacy) { var iAnim = new ImportedKeyframedAnimation(); iAnim.Name = clip.m_Name; AnimationList.Add(iAnim); iAnim.TrackList = new List <ImportedAnimationKeyframedTrack>(); foreach (var m_RotationCurve in clip.m_RotationCurves) { var path = m_RotationCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); if (track == null) { track = new ImportedAnimationKeyframedTrack(); track.Name = boneName; iAnim.TrackList.Add(track); } foreach (var m_Curve in m_RotationCurve.curve.m_Curve) { var value = Fbx.QuaternionToEuler(new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W)); var inSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.inSlope.X, -m_Curve.inSlope.Y, -m_Curve.inSlope.Z, m_Curve.inSlope.W)); var outSlope = Fbx.QuaternionToEuler(new Quaternion(m_Curve.outSlope.X, -m_Curve.outSlope.Y, -m_Curve.outSlope.Z, m_Curve.outSlope.W)); track.Rotations.Add(new ImportedKeyframe <Vector3>(m_Curve.time, value, inSlope, outSlope)); } } foreach (var m_PositionCurve in clip.m_PositionCurves) { var path = m_PositionCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); if (track == null) { track = new ImportedAnimationKeyframedTrack(); track.Name = boneName; iAnim.TrackList.Add(track); } foreach (var m_Curve in m_PositionCurve.curve.m_Curve) { track.Translations.Add(new ImportedKeyframe <Vector3>( m_Curve.time, new Vector3(-m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z), new Vector3(-m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z), new Vector3(-m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z))); } } foreach (var m_ScaleCurve in clip.m_ScaleCurves) { var path = m_ScaleCurve.path; var boneName = path.Substring(path.LastIndexOf('/') + 1); var track = iAnim.FindTrack(boneName); if (track == null) { track = new ImportedAnimationKeyframedTrack(); track.Name = boneName; iAnim.TrackList.Add(track); } foreach (var m_Curve in m_ScaleCurve.curve.m_Curve) { track.Scalings.Add(new ImportedKeyframe <Vector3>( m_Curve.time, new Vector3(m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z), new Vector3(m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z), new Vector3(m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z))); } } if ((bool)Properties.Settings.Default["FixRotation"]) { foreach (var track in iAnim.TrackList) { var prevKey = new Vector3(); foreach (var rotation in track.Rotations) { var value = rotation.value; ReplaceOutOfBound(ref prevKey, ref value); prevKey = value; rotation.value = value; } } } } else { var iAnim = new ImportedSampledAnimation(); iAnim.Name = clip.m_Name; iAnim.SampleRate = clip.m_SampleRate; AnimationList.Add(iAnim); int numTracks = (clip.m_MuscleClip.m_Clip.m_ConstantClip.data.Length + (int)clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount + (int)clip.m_MuscleClip.m_Clip.m_StreamedClip.curveCount + 9) / 10; iAnim.TrackList = new List <ImportedAnimationSampledTrack>(numTracks); var streamedFrames = clip.m_MuscleClip.m_Clip.m_StreamedClip.ReadData(); float[] streamedValues = new float[clip.m_MuscleClip.m_Clip.m_StreamedClip.curveCount]; int numFrames = Math.Max(clip.m_MuscleClip.m_Clip.m_DenseClip.m_FrameCount, streamedFrames.Count - 2); for (int frameIdx = 0; frameIdx < numFrames; frameIdx++) { if (1 + frameIdx < streamedFrames.Count) { for (int i = 0; i < streamedFrames[1 + frameIdx].keyList.Count; i++) { streamedValues[i] = streamedFrames[1 + frameIdx].keyList[i].value; } } int numStreamedCurves = 1 + frameIdx < streamedFrames.Count ? streamedFrames[1 + frameIdx].keyList.Count : 0; int numCurves = numStreamedCurves + (int)clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount + clip.m_MuscleClip.m_Clip.m_ConstantClip.data.Length; int streamOffset = numStreamedCurves - (int)clip.m_MuscleClip.m_Clip.m_StreamedClip.curveCount; for (int curveIdx = 0; curveIdx < numCurves;) { GenericBinding binding; float[] data; int dataOffset; if (1 + frameIdx < streamedFrames.Count && curveIdx < streamedFrames[1 + frameIdx].keyList.Count) { binding = clip.m_ClipBindingConstant.FindBinding(streamedFrames[1 + frameIdx].keyList[curveIdx].index); data = streamedValues; dataOffset = 0; } else if (curveIdx < numStreamedCurves + clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount) { binding = clip.m_ClipBindingConstant.FindBinding(curveIdx - streamOffset); data = clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleArray; dataOffset = numStreamedCurves - frameIdx * (int)clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount; } else { binding = clip.m_ClipBindingConstant.FindBinding(curveIdx - streamOffset); data = clip.m_MuscleClip.m_Clip.m_ConstantClip.data; dataOffset = numStreamedCurves + (int)clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount; } if (binding.path == 0) { curveIdx++; continue; } string boneName = GetNameFromHashes(binding.path, binding.attribute); ImportedAnimationSampledTrack track = iAnim.FindTrack(boneName); if (track == null) { track = new ImportedAnimationSampledTrack(); track.Name = boneName; iAnim.TrackList.Add(track); } try { switch (binding.attribute) { case 1: if (track.Translations == null) { track.Translations = new Vector3?[numFrames]; } track.Translations[frameIdx] = new Vector3 ( -data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset] ); break; case 2: if (track.Rotations == null) { track.Rotations = new Vector3?[numFrames]; } track.Rotations[frameIdx] = Fbx.QuaternionToEuler(new Quaternion ( data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset] )); break; case 3: if (track.Scalings == null) { track.Scalings = new Vector3?[numFrames]; } track.Scalings[frameIdx] = new Vector3 ( data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset], data[curveIdx++ - dataOffset] ); break; case 4: if (track.Rotations == null) { track.Rotations = new Vector3?[numFrames]; } track.Rotations[frameIdx] = new Vector3 ( data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset], -data[curveIdx++ - dataOffset] ); break; default: if (track.Curve == null) { track.Curve = new float?[numFrames]; } track.Curve[frameIdx] = data[curveIdx++ - dataOffset]; break; } } catch { //errors.Append(" ").Append(boneName).Append(" a=").Append(binding.attribute).Append(" ci=").Append(curveIdx).Append("/#=").Append(numCurves).Append(" of=").Append(dataOffset).Append(" f=").Append(frameIdx).Append("/#=").Append(numFrames).Append("\n"); //TODO Display error break; } } } if ((bool)Properties.Settings.Default["FixRotation"]) { foreach (var track in iAnim.TrackList) { if (track.Rotations == null) { continue; } var prevKey = new Vector3(); for (var i = 0; i < track.Rotations.Length; i++) { var rotation = track.Rotations[i]; if (rotation == null) { continue; } var value = new Vector3(rotation.Value.X, rotation.Value.Y, rotation.Value.Z); ReplaceOutOfBound(ref prevKey, ref value); prevKey = value; track.Rotations[i] = value; } } } } } }