public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Idle", "goblin_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Walk", "goblin_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Attack", "goblin_attack_", GoblinAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_GetHit", "goblin_getHit_", GoblinGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Death", "goblin_death_", GoblinDeathFrames); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Damage"); sharedDeathSplort = SKSpriteNode.FromTexture(atlas.TextureNamed("minionSplort.png")); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 1, 0), SKAction.WaitForDuration(0.75f), SKAction.ColorizeWithColorBlendFactor(0, 0.1) }); }
protected override void LoadSceneAssets() { SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); // Load archived emitters and create copyable sprites. sharedProjectileSparkEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("ProjectileSplat"); sharedSpawnEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Spawn"); sharedSmallTree = new Tree(new SKNode[] { SKSpriteNode.FromTexture(atlas.TextureNamed("small_tree_base.png")), SKSpriteNode.FromTexture(atlas.TextureNamed("small_tree_middle.png")), SKSpriteNode.FromTexture(atlas.TextureNamed("small_tree_top.png")) }, 25); sharedBigTree = new Tree(new SKNode[] { SKSpriteNode.FromTexture(atlas.TextureNamed("big_tree_base.png")), SKSpriteNode.FromTexture(atlas.TextureNamed("big_tree_middle.png")), SKSpriteNode.FromTexture(atlas.TextureNamed("big_tree_top.png")) }, 150); sharedBigTree.FadeAlpha = true; sharedLeafEmitterA = GraphicsUtilities.EmitterNodeWithEmitterNamed("Leaves_01"); sharedLeafEmitterB = GraphicsUtilities.EmitterNodeWithEmitterNamed("Leaves_02"); // Load the tiles that make up the ground layer. LoadWorldTiles(); // Load assets for all the sprites within this scene. Cave.LoadSharedAssetsOnce(); HeroCharacter.LoadSharedAssetsOnce(); Archer.LoadSharedAssetsOnce(); Warrior.LoadSharedAssetsOnce(); Goblin.LoadSharedAssetsOnce(); Boss.LoadSharedAssetsOnce(); }
public void ApplyDamage(int amount) { if (amount >= health) { if (health >= 0) { health = 0; Explode(); } } else { health -= amount; if (health < showDamageBelowHealth) { // Show (increasing from none) damage to the ship if (visibleDamageNode == null) { visibleDamageNode = new DamageNode(Scene); AddChild(visibleDamageNode); } else { visibleDamageNode.ParticleBirthRate = visibleDamageNode.ParticleBirthRate * 2; } } } }
void Explode() { // Create a bunch of explosion emitters and send them flying in all directions. Then remove the ship from the scene. for (int i = 0; i < numberOfChunks; i++) { SKEmitterNode explosion = NodeFactory.CreateExplosionNode(Scene, shipExplosionDuration); float angle = myRand(0, (float)Math.PI * 2); float speed = myRand(shipChunkMinimumSpeed, shipChunkMaximumSpeed); var x = myRand((float)Position.X - shipChunkDispersion, (float)Position.X + shipChunkDispersion); var y = myRand((float)Position.Y - shipChunkDispersion, (float)Position.Y + shipChunkDispersion); explosion.Position = new CGPoint(x, y); var body = SKPhysicsBody.CreateCircularBody(0.25f); body.CollisionBitMask = 0; body.ContactTestBitMask = 0; body.CategoryBitMask = 0; body.Velocity = new CGVector((float)Math.Cos(angle) * speed, (float)Math.Sin(angle) * speed); explosion.PhysicsBody = body; Scene.AddChild(explosion); } RunAction(SKAction.Sequence( SKAction.WaitForDuration(removeShipTime), SKAction.RemoveFromParent() )); }
public new static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif sharedProjectile = SKSpriteNode.FromColor(whiteColor, new CGSize(2, 24)); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody(ProjectileCollisionRadius); sharedProjectile.Name = @"Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("ArcherProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Idle", "archer_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Walk", "archer_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Attack", "archer_attack_", ArcherAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_GetHit", "archer_getHit_", ArcherGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Death", "archer_death_", ArcherDeathFrames); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 10, 0), SKAction.WaitForDuration(0.75), SKAction.ColorizeWithColorBlendFactor(0, 0.25) }); }
static ExhaustNode() { template = UnarchiveNode("exhaust", "sks"); template.Position = new CGPoint(0f, -40f); template.Name = "exhaust"; template.ParticleAlpha = IdleAlpha; }
static ExhaustNode() { template = UnarchiveNode ("exhaust", "sks"); template.Position = new CGPoint (0f, -40f); template.Name = "exhaust"; template.ParticleAlpha = IdleAlpha; }
public new static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); sharedProjectile = SKSpriteNode.FromTexture(atlas.TextureNamed("warrior_throw_hammer.png")); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody(ProjectileCollisionRadius); sharedProjectile.Name = "Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("WarriorProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Idle", "warrior_idle_", WarriorIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Walk", "warrior_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Attack", "warrior_attack_", WarriorThrowFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_GetHit", "warrior_getHit_", WarriorGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Death", "warrior_death_", WarriorDeathFrames); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 10, 0), SKAction.WaitForDuration(0.5), SKAction.ColorizeWithColorBlendFactor(0, 0.25) }); }
private void CreateEmitterNode() { // Setup a intial Location var location = new CGPoint(); location.X = (((View.Frame.Width / 2))); location.Y = (((View.Frame.Height / 4))); // Define paricles and initial settings particleEmitterNode = new SKEmitterNode(); particleEmitterNode.Position = location; particleEmitterNode.NumParticlesToEmit = 0; particleEmitterNode.ZPosition = 2; particleEmitterNode.ParticleAlpha = 0.4f; particleEmitterNode.XAcceleration = 0; particleEmitterNode.YAcceleration = 1; particleEmitterNode.EmissionAngle = 100f; particleEmitterNode.TargetNode = this; particleEmitterNode.ParticleScale = 0.4f; particleEmitterNode.ParticleSpeedRange = 100f; particleEmitterNode.ParticleScaleRange = 0.5f; particleEmitterNode.ParticleScaleSpeed = -0.1f; particleEmitterNode.ParticleBirthRate = 500; particleEmitterNode.ParticlePositionRange = new CGVector(120f, 120f); particleEmitterNode.ParticleLifetimeRange = 10f; particleEmitterNode.ParticleRotationRange = 10f; particleEmitterNode.EmissionAngleRange = 200f; particleEmitterNode.ParticleTexture = SKTexture.FromImageNamed(("spark")); }
public override void ReleaseSceneAssets() { // Get rid of everything unique to this scene (but not the characters, which might appear in other scenes). backgroundTiles = null; sharedProjectileSparkEmitter = null; sharedSpawnEmitter = null; sharedLeafEmitterA = null; sharedLeafEmitterB = null; }
public static void RunOneShotEmitter(SKEmitterNode emitter, float duration) { emitter.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(duration), SKAction.Run(() => { emitter.ParticleBirthRate = 0; }), SKAction.WaitForDuration(emitter.ParticleLifetime + emitter.ParticleLifetimeRange), SKAction.RemoveFromParent() })); }
static MissileNode() { template = UnarchiveNode("missile", "sks"); // use a local variable to avoid multiple virtual call to the `PhysicsBody` property var body = SKPhysicsBody.CreateCircularBody(defaultSize); body.CategoryBitMask = Category.Missile; body.ContactTestBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge; body.CollisionBitMask = 0; template.PhysicsBody = body; }
void UpdateSmokeForHealth() { // Add smoke if health is < 75. if (Health > 75f || smokeEmitter != null) { return; } var emitter = (SKEmitterNode)DeathEmitter.Copy(); emitter.Position = Position; emitter.ZPosition = -0.8f; smokeEmitter = emitter; ((MultiplayerLayeredCharacterScene)Scene).AddNode(emitter, WorldLayer.AboveCharacter); }
void AddTrees() { for (int y = 0; y < LevelMapSize; y++) { for (int x = 0; x < LevelMapSize; x++) { var location = new CGPoint(x, y); var spot = treeMap.QueryTreeMap(location); var treePos = ConvertLevelMapPointToWorldPoint(location); WorldLayer treeLayer = WorldLayer.Top; Tree tree; if (spot.SmallTreeLocation >= 200) { // Create small tree at this location. treeLayer = WorldLayer.AboveCharacter; tree = (Tree)SharedSmallTree.Clone(); } else if (spot.BigTreeLocation >= 200) { // Create big tree with leaf emitters at this position. tree = (Tree)SharedBigTree.Clone(); // Pick one of the two leaf emitters for this tree. SKEmitterNode emitterToCopy = Random.Next(2) == 1 ? SharedLeafEmitterA : SharedLeafEmitterB; var emitter = (SKEmitterNode)emitterToCopy.Copy(); emitter.Position = treePos; emitter.Paused = true; AddNode(emitter, WorldLayer.AboveCharacter); particleSystems.Add(emitter); } else { continue; } tree.Position = treePos; tree.ZRotation = (float)(Random.NextDouble() * Math.PI * 2); AddNode(tree, treeLayer); parallaxSprites.Add(tree); trees.Add(tree); } } treeMap = null; }
public static SKEmitterNode CreateExplosionNode(SKNode target, double duration) { SKEmitterNode emitter = UnarchiveEmitterNode("explosion"); // Explosions always place their particles into the scene. emitter.TargetNode = target; // Stop spawning particles after enough have been spawned. emitter.NumParticlesToEmit = (nuint)(duration * emitter.ParticleBirthRate); // Calculate a time value that allows all the spawned particles to die. After this, the emitter node can be removed. double totalTime = duration + emitter.ParticleLifetime + emitter.ParticleLifetimeRange / 2; emitter.RunAction(SKAction.Sequence(SKAction.WaitForDuration(totalTime), SKAction.RemoveFromParent())); return(emitter); }
public static SKNode CreateMissileNode(SKNode target) { // Creates and returns a new missile game object. // This method loads a preconfigured emitter from an archive, and then configures it with a physics body. SKEmitterNode missile = UnarchiveEmitterNode("missile"); // The missile particles should be spawned in the scene, not on the missile object. missile.TargetNode = target; var physicsBody = SKPhysicsBody.CreateCircularBody(shotSize); physicsBody.CategoryBitMask = Category.Missile; physicsBody.ContactTestBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge; physicsBody.CollisionBitMask = 0; missile.PhysicsBody = physicsBody; return(missile); }
public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); SKEmitterNode fire = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFire"); fire.ZPosition = 1; SKEmitterNode smoke = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFireSmoke"); var sKNode = new SKNode(); sKNode.Add(fire); sKNode.Add(smoke); SKNode torch = sKNode; sharedCaveBase = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_base.png")); // Add two torches either side of the entrance. torch.Position = new CGPoint(83, 83); sharedCaveBase.AddChild(torch); var torchB = (SKNode)torch.Copy(); torchB.Position = new CGPoint(-83, 83); sharedCaveBase.AddChild(torchB); sharedCaveTop = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_top.png")); sharedDeathSplort = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_destroyed.png")); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDamage"); sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDeathSmoke"); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 1, 0), SKAction.WaitForDuration(0.25), SKAction.ColorizeWithColorBlendFactor(0, 0.1), }); }
internal void loadJetEffect(SKNode gameWorld) { defaultEmitterNodeParticleBirthRate = speedAtribute * 20; emitterNode = new SKEmitterNode(int.MaxValue); emitterNode.setScaleToFit(8.0f, 8.0f); emitterNode.particleLifetime = 1.0f; emitterNode.particleAlpha = 1.0f; emitterNode.particleAlphaSpeed = -4.0f; emitterNode.particleScaleSpeed = -1.0f; emitterNode.color = Mothership.colorFor(team); emitterNode.blendState = BlendState.Additive; emitterNode.particlePositionRange = new Vector2(8.0f, 8.0f); gameWorld.addChild(emitterNode); }
void ShowDamage() { // When the ship first shows damage, a damage node is created and added as a child. // If it takes more damage, then the number of particles is increased. if (visibleDamageNode == null) { visibleDamageNode = (SKEmitterNode)NSKeyedUnarchiver.UnarchiveFile(NSBundle.MainBundle.PathForResource("damage", "sks")); visibleDamageNode.Name = @"damaged"; // Make the scene the target node because the ship is moving around in the scene. Smoke particles // should be spawned based on the ship, but should otherwise exist independently of the ship. visibleDamageNode.TargetNode = Scene; AddChild(visibleDamageNode); } else { visibleDamageNode.ParticleBirthRate = visibleDamageNode.ParticleBirthRate * 2; } }
public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Boss_Idle", "boss_idle_", BossIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Boss_Walk", "boss_walk_", BossWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Boss_Attack", "boss_attack_", BossAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Boss_GetHit", "boss_getHit_", BossGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Boss_Death", "boss_death_", BossDeathFrames); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("BossDamage"); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 1, 0), SKAction.WaitForDuration(0.5), SKAction.ColorizeWithColorBlendFactor(0, 0.1) }); }
void loadEmitterNode() { emitterNode = new SKEmitterNode(60); emitterNode.texture2D = SKScene.current.Texture2D("spark8x8"); //emitterNode.particleSize = new Vector2(8, 8); emitterNode.particleBirthRate = 60.0f; emitterNode.particleLifetime = 1.0f; emitterNode.particleAlpha = 1.0f; emitterNode.particleAlphaSpeed = -4.0f; emitterNode.particleScale = 1.0f; emitterNode.particleScaleSpeed = -1.0f; emitterNode.particleColorBlendFactor = 1.0f; emitterNode.particleColor = color; emitterNode.particleBlendMode = BlendState.Additive; emitterNode.particlePositionRange = new Vector2(8.0f, 8.0f); shooter.parent.addChild(emitterNode); update(); }
void ShowDamage() { // When the ship first shows damage, a damage node is created and added as a child. // If it takes more damage, then the number of particles is increased. if (visibleDamageNode == null) { visibleDamageNode = (SKEmitterNode)NSKeyedUnarchiver.UnarchiveFile (NSBundle.MainBundle.PathForResource ("damage", "sks")); visibleDamageNode.Name = @"damaged"; // Make the scene the target node because the ship is moving around in the scene. Smoke particles // should be spawned based on the ship, but should otherwise exist independently of the ship. visibleDamageNode.TargetNode = Scene; AddChild(visibleDamageNode); } else { visibleDamageNode.ParticleBirthRate = visibleDamageNode.ParticleBirthRate * 2; } }
public void ApplyDamage(int amount) { if (amount >= health) { if (health >= 0) { health = 0; Explode (); } } else { health -= amount; if (health < showDamageBelowHealth) { // Show (increasing from none) damage to the ship if (visibleDamageNode == null) { visibleDamageNode = new DamageNode (Scene); AddChild (visibleDamageNode); } else visibleDamageNode.ParticleBirthRate = visibleDamageNode.ParticleBirthRate * 2; } } }
public static void LoadSharedAssetsOnce() { sharedProjectileSoundAction = SKAction.PlaySoundFileNamed("magicmissile.caf", false); sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Death"); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Damage"); }
static DamageNode() { template = UnarchiveNode("damage", "sks"); template.Name = "damaged"; }
static DamageNode () { template = UnarchiveNode ("damage", "sks"); template.Name = "damaged"; }
public static new void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject ().InvokeOnMainThread (() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName ("Environment"); sharedProjectile = SKSpriteNode.FromTexture (atlas.TextureNamed ("warrior_throw_hammer.png")); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody (ProjectileCollisionRadius); sharedProjectile.Name = "Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("WarriorProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Warrior_Idle", "warrior_idle_", WarriorIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Warrior_Walk", "warrior_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Warrior_Attack", "warrior_attack_", WarriorThrowFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Warrior_GetHit", "warrior_getHit_", WarriorGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Warrior_Death", "warrior_death_", WarriorDeathFrames); sharedDamageAction = SKAction.Sequence (new [] { SKAction.ColorizeWithColor (whiteColor, 10, 0), SKAction.WaitForDuration (0.5), SKAction.ColorizeWithColorBlendFactor (0, 0.25) }); }
public static new void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject ().InvokeOnMainThread (() => { whiteColor = NSColor.White; }); #endif sharedProjectile = SKSpriteNode.FromColor (whiteColor, new CGSize (2, 24)); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody (ProjectileCollisionRadius); sharedProjectile.Name = @"Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("ArcherProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Archer_Idle", "archer_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Archer_Walk", "archer_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Archer_Attack", "archer_attack_", ArcherAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Archer_GetHit", "archer_getHit_", ArcherGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Archer_Death", "archer_death_", ArcherDeathFrames); sharedDamageAction = SKAction.Sequence (new [] { SKAction.ColorizeWithColor (whiteColor, 10, 0), SKAction.WaitForDuration (0.75), SKAction.ColorizeWithColorBlendFactor (0, 0.25) }); }
public static void RunOneShotEmitter(SKEmitterNode emitter, float duration) { emitter.RunAction (SKAction.Sequence (new [] { SKAction.WaitForDuration (duration), SKAction.Run (() => { emitter.ParticleBirthRate = 0; }), SKAction.WaitForDuration (emitter.ParticleLifetime + emitter.ParticleLifetimeRange), SKAction.RemoveFromParent () })); }
public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject ().InvokeOnMainThread (() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName ("Environment"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Goblin_Idle", "goblin_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Goblin_Walk", "goblin_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Goblin_Attack", "goblin_attack_", GoblinAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Goblin_GetHit", "goblin_getHit_", GoblinGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas ("Goblin_Death", "goblin_death_", GoblinDeathFrames); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("Damage"); sharedDeathSplort = SKSpriteNode.FromTexture (atlas.TextureNamed ("minionSplort.png")); sharedDamageAction = SKAction.Sequence (new [] { SKAction.ColorizeWithColor (whiteColor, 1, 0), SKAction.WaitForDuration (0.75f), SKAction.ColorizeWithColorBlendFactor (0, 0.1) }); }
static MissileNode() { template = UnarchiveNode ("missile", "sks"); // use a local variable to avoid multiple virtual call to the `PhysicsBody` property var body = SKPhysicsBody.BodyWithCircleOfRadius (defaultSize); body.CategoryBitMask = Category.Missile; body.ContactTestBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge; body.CollisionBitMask = 0; template.PhysicsBody = body; }
public static void LoadSharedAssetsOnce() { sharedProjectileSoundAction = SKAction.PlaySoundFileNamed ("magicmissile.caf", false); sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("Death"); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("Damage"); }