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)
            });
        }
        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)
            });
        }
예제 #3
0
        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)
            });
        }
예제 #4
0
        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()
                          ));
        }
예제 #5
0
        public void ShowEndScreen()
        {
            // Congratulation title
            var congratulationsNode = SKSpriteNode.FromImageNamed("Overlays/congratulations.png");

            // Max image
            var characterNode = SKSpriteNode.FromImageNamed("Overlays/congratulations_pandaMax.png");

            characterNode.Position    = new CGPoint(0f, -220f);
            characterNode.AnchorPoint = new CGPoint(0.5f, 0f);

            this.congratulationsGroupNode = new SKNode();
            this.congratulationsGroupNode.AddChild(characterNode);
            this.congratulationsGroupNode.AddChild(congratulationsNode);
            this.AddChild(this.congratulationsGroupNode);

            // Layout the overlay
            this.Layout2DOverlay();

            // Animate
            congratulationsNode.Alpha  = 0f;
            congratulationsNode.XScale = 0f;
            congratulationsNode.YScale = 0f;
            congratulationsNode.RunAction(SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.25),
                                                                          SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25),
                                                                                                             SKAction.ScaleTo(1f, 0.1) }) }));

            characterNode.Alpha  = 0f;
            characterNode.XScale = 0f;
            characterNode.YScale = 0f;
            characterNode.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5),
                                                                       SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.5),
                                                                                                       SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25),
                                                                                                                                          SKAction.ScaleTo(1f, 0.1) }) }) }));
        }
        public void FireProjectile()
        {
            var projectile = (SKSpriteNode)Projectile.Copy();

            projectile.Position  = Position;
            projectile.ZRotation = ZRotation;

            var emitter = (SKEmitterNode)ProjectileEmitter.Copy();

            emitter.TargetNode = CharacterScene.GetChildNode("world");
            projectile.AddChild(emitter);

            CharacterScene.AddNode(projectile, WorldLayer.Character);

            var rot = ZRotation;

            float x = -(float)Math.Sin(rot) * HeroProjectileSpeed * HeroProjectileLifetime;
            float y = (float)Math.Cos(rot) * HeroProjectileSpeed * HeroProjectileLifetime;

            projectile.RunAction(SKAction.MoveBy(x, y, HeroProjectileLifetime));

            projectile.RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(HeroProjectileFadeOutTime),
                SKAction.FadeOutWithDuration(HeroProjectileLifetime - HeroProjectileFadeOutTime),
                SKAction.RemoveFromParent()
            }));
            projectile.RunAction(ProjectileSoundAction);

            var userData = new UserData {
                Player = Player
            };


            projectile.UserData = (NSMutableDictionary)userData.Dictionary;
        }
예제 #7
0
 public void DidCollectKey()
 {
     this.collectedKeySprite.Texture = SKTexture.FromImageNamed("Overlays/key_full.png");
     this.collectedKeySprite.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5f),
                                                                          SKAction.ScaleBy(1.5f, 0.2f),
                                                                          SKAction.ScaleBy(1f / 1.5f, 0.2f) }));
 }
예제 #8
0
        void ShowEndScreen()
        {
            gameIsComplete = true;

            // Add confettis
            SCNMatrix4 particlePosition = SCNMatrix4.CreateTranslation(0f, 8f, 0f);

            GameView.Scene.AddParticleSystem(confetti, particlePosition);

            // Congratulation title
            SKSpriteNode congrat = SKSpriteNode.FromImageNamed("Images/congratulations.png");

            congrat.Position = new CGPoint(GameView.Bounds.Width / 2, GameView.Bounds.Height / 2);
            SKScene overlay = GameView.OverlayScene;

            congrat.XScale = congrat.YScale = 0;
            congrat.Alpha  = 0;
            congrat.RunAction(SKAction.Group(new [] {
                SKAction.FadeInWithDuration(0.25),
                SKAction.Sequence(new [] {
                    SKAction.ScaleTo(.55f, 0.25),
                    SKAction.ScaleTo(.3f, 0.1),
                })
            }));

            // Panda Image
            SKSpriteNode congratPanda = SKSpriteNode.FromImageNamed("Images/congratulations_pandaMax.png");

            congratPanda.Position    = new CGPoint(GameView.Bounds.Width / 2f, GameView.Bounds.Height / 2f - 90f);
            congratPanda.AnchorPoint = new CGPoint(.5f, 0f);
            congratPanda.XScale      = congratPanda.YScale = 0f;
            congratPanda.Alpha       = 0;

            congratPanda.RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(.5f),
                SKAction.Sequence(new [] {
                    SKAction.ScaleTo(.5f, 0.25),
                    SKAction.ScaleTo(.4f, 0.1)
                })
            }));

            overlay.AddChild(congratPanda);
            overlay.AddChild(congrat);

            // Stop music
            GameView.Scene.RootNode.RemoveAllAudioPlayers();

            // Play the congrat sound.
            GameView.Scene.RootNode.AddAudioPlayer(SCNAudioPlayer.FromSource(victoryMusic));

            // Animate the camera forever
            DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1 * NanoSecondsPerSeond), () => {
                cameraYHandle.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, -1f, 0f, 3.0)));
                cameraXHandle.RunAction(SCNAction.RotateTo(-(float)Math.PI / 4f, 0f, 0f, 5.0));
            });
        }
예제 #9
0
        // Add Heartbeat Animation to parent node
        private void AddHeartbeat(double tempWait)
        {
            double   wait     = tempWait - 1;
            SKAction sleep    = SKAction.WaitForDuration(wait);
            SKAction sizeUp   = SKAction.ScaleTo(1.2f, 0.1f);
            SKAction sizeDown = SKAction.ScaleTo(0.9f, 0.1f);
            var      sequence = SKAction.Sequence(sleep, sizeUp, sizeDown);

            RunAction(SKAction.RepeatActionForever(sequence));
        }
예제 #10
0
 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()
     }));
 }
예제 #11
0
        public ExplosionNode(SKNode target)
            : base((template as NSObject).Copy().Handle)
        {
            TargetNode         = target;
            NumParticlesToEmit = (uint)(defaultDuration * ParticleBirthRate);
            double totalTime = defaultDuration + ParticleLifetime + ParticleLifetimeRange / 2;

            RunAction(SKAction.Sequence(
                          SKAction.WaitForDuration(totalTime),
                          SKAction.RemoveFromParent()
                          ));
        }
예제 #12
0
        SKAction GetResizeAction(SKTexture texture)
        {
            SKAction sequence = SKAction.Sequence(
                SKAction.WaitForDuration(1.0f),
                SKAction.ResizeTo(192.0f, 192.0f, 1.0f),
                SKAction.WaitForDuration(1.0f),
                SKAction.ResizeTo(128.0f, 192.0f, 1.0f),
                SKAction.WaitForDuration(1.0f),
                SKAction.ResizeTo(256.0f, 128.0f, 1.0f),
                SKAction.WaitForDuration(1.0f),
                SKAction.ResizeTo(texture.Size, 1.0f)
                );

            return(SKAction.RepeatActionForever(sequence));
        }
예제 #13
0
        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 void ShowLabel(string label)
        {
            if (Label == null)
            {
                Label = SKLabelNode.FromFont("Myriad Set");
                if (Label == null)
                {
                    Label = SKLabelNode.FromFont("Avenir-Heavy");
                }
                Label.FontSize = 140;
                Label.Position = new CGPoint(0, 0);

                AddChild(Label);
            }
            else
            {
                if (label != null)
                {
                    Label.Position = new CGPoint(0, Size.Height * 0.25f);
                }
            }

            if (label == null)
            {
                Label.RunAction(SKAction.FadeOutWithDuration(0.5));
            }
            else
            {
                                #if __IOS__
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    Label.FontSize = label.Length > 10 ? 50 : 80;
                }
                else
                                #endif
                Label.FontSize = label.Length > 10 ? 100 : 140;

                Label.Text  = label;
                Label.Alpha = 0.0f;
                Label.RunAction(SKAction.Sequence(new [] {
                    SKAction.WaitForDuration(0.5),
                    SKAction.FadeInWithDuration(0.5)
                }));
            }
        }
        protected override void CreateSceneContents()
        {
            base.CreateSceneContents();

            // no point in recomputing constant values each time
            var half_range = range / 2.0f;

            basex = (float)Scene.Frame.GetMidX() - half_range;
            basey = (float)Scene.Frame.GetMidY() - half_range;

            Scene.AddDescription("These textured sprite nodes are combined using an additive blend",
                                 new CGPoint(Scene.Frame.GetMidX(), 100));

            Scene.RunAction(SKAction.RepeatActionForever(SKAction.Sequence(
                                                             SKAction.Run(AddLight),
                                                             SKAction.WaitForDuration(0.5f, 0.1f)
                                                             )));
        }
예제 #16
0
        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),
            });
        }
예제 #17
0
        /// <summary>
        /// Добававляем его спрайт на нод для камешка, с расчетом размера и позиции
        /// </summary>
        /// <param name="gem">Камешек которому добавляется спрайт.</param>
        private void AttachSpriteTo(Gem gem)
        {
            SKSpriteNode sprite;

            // Если разрушитель - открепляем старый спрайт на этом месте от слоя камешков
            if ((gem.IsALineDestroyer || gem.IsABomb) && Level.GemArray[gem.Row, gem.Column] != null)
            {
                sprite = Level.GemArray[gem.Row, gem.Column].Sprite;

                if (sprite != null && sprite.Parent != null)
                {
                    sprite.RemoveFromParent();
                }
            }

            // подготовка спрайта
            sprite          = SKSpriteNode.FromImageNamed(gem.GetSpriteName());
            sprite.Size     = new CGSize(gemCellWidth, gemCellHeight);
            sprite.Position = GetPositionFromRowAndColumn(gem.Row, gem.Column);
            gemLayer.AddChild(sprite);

            gem.Sprite = sprite;

            // подготовка к анимации
            sprite.Alpha  = 0;
            sprite.XScale = 0.5f;
            sprite.YScale = 0.5f;

            // Анимация появления камешка
            sprite.RunAction(
                SKAction.Sequence(
                    SKAction.WaitForDuration(0.25, 0.5),
                    SKAction.Group(
                        SKAction.FadeInWithDuration(0.25),
                        SKAction.ScaleTo(1.0f, 0.25)
                        )
                    ));

            // если разрушитель - заменяем в массиве камешек
            if (gem.IsALineDestroyer || gem.IsABomb)
            {
                Level.GemArray[gem.Row, gem.Column] = gem;
            }
        }
        public override void AnimationDidComplete(AnimationState animation)
        {
            base.AnimationDidComplete(animation);

            if (animation != AnimationState.Death)
            {
                return;
            }

            // In a real game, you'd complete the level here, maybe as shown by commented code below.
            RemoveAllActions();
            RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(3),
                SKAction.FadeOutWithDuration(2),
                SKAction.RemoveFromParent(),
//				SKAction.RunBlock(()=> {
//					CharacterScene.GemeOver();
//				})
            }));
        }
        public override void AnimationDidComplete(AnimationState animation)
        {
            base.AnimationDidComplete(animation);

            if (animation != AnimationState.Death)
            {
                return;
            }

            RemoveAllActions();

            RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(0.75),
                SKAction.FadeOutWithDuration(1),
                SKAction.Run(() => {
                    RemoveFromParent();
                    Cave.Recycle(this);
                })
            }));
        }
예제 #20
0
        public override void PerformDeath()
        {
            base.PerformDeath();

            var splort = (SKNode)DeathSplort.Copy();

            splort.ZPosition = -1;
            splort.ZRotation = VirtualZRotation;
            splort.Position  = Position;
            splort.Alpha     = 0.1f;
            splort.RunAction(SKAction.FadeAlphaTo(1, 0.5));

            MultiplayerLayeredCharacterScene scene = CharacterScene;

            scene.AddNode(splort, WorldLayer.BelowCharacter);

            RunAction(SKAction.Sequence(new [] {
                SKAction.FadeAlphaTo(0, 0.5f),
                SKAction.RemoveFromParent()
            }));

            smokeEmitter.RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(2),
                SKAction.Run(() => {
                    smokeEmitter.ParticleBirthRate = 2;
                }),

                SKAction.WaitForDuration(2),
                SKAction.Run(() => {
                    smokeEmitter.ParticleBirthRate = 0;
                }),

                SKAction.WaitForDuration(10),
                SKAction.FadeAlphaTo(0, 0.5),
                SKAction.RemoveFromParent()
            }));

            inactiveGoblins.Clear();
        }
예제 #21
0
        public GameOverScene(SizeF size, int score) : base(size)
        {
            BackgroundColor = new UIColor(0.15f, 0.15f, 0.3f, 1.0f);

            SKLabelNode label = SKLabelNode.FromFont("Chalkduster");

            label.Text      = "Your final score is: " + score + " Points";
            label.FontSize  = 30f;
            label.FontColor = UIColor.Black;
            label.Position  = new PointF(Size.Width / 2, Size.Height / 2);
            AddChild(label);

            RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(3),
                SKAction.RunBlock(() => {
                    SKTransition reveal = SKTransition.FlipHorizontalWithDuration(0.5);
                    var scene           = new MyScene(size);

                    View.PresentScene(scene, reveal);
                }),
            }));
        }
        public override void AnimationDidComplete(AnimationState animation)
        {
            switch (animation)
            {
            case AnimationState.Death:
                var emitter = (SKEmitterNode)DeathEmitter.Copy();
                emitter.ZPosition = -0.8f;
                AddChild(emitter);
                GraphicsUtilities.RunOneShotEmitter(emitter, 4.5f);

                RunAction(SKAction.Sequence(new [] {
                    SKAction.WaitForDuration(4),
                    SKAction.Run(() => CharacterScene.HeroWasKilled(this)),
                    SKAction.RemoveFromParent()
                }));
                break;

            case AnimationState.Attack:
                FireProjectile();
                break;
            }
        }
 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 AddAnimatedSprite()
        {
            SKSpriteNode animatedSprite = (SKSpriteNode)(template as NSObject).Copy();

            animatedSprite.Position = new CGPoint(925, 384);

            Scene.AddChild(animatedSprite);
            Scene.AddDescription("Animated Color Blending",
                                 new CGPoint(animatedSprite.Position.X, animatedSprite.Position.Y - 90));

            animatedSprite.RunAction(SKAction.RepeatActionForever(SKAction.Sequence(
                                                                      SKAction.WaitForDuration(1.0),
                                                                      SKAction.ColorizeWithColor(UIColor.Red, 1.0f, 1.0f),
                                                                      SKAction.WaitForDuration(1.0),
                                                                      SKAction.ColorizeWithColor(UIColor.Green, 1.0f, 1.0f),
                                                                      SKAction.WaitForDuration(1.0),
                                                                      SKAction.ColorizeWithColor(UIColor.Blue, 1.0f, 1.0f),
                                                                      SKAction.WaitForDuration(1.0),
                                                                      SKAction.ColorizeWithColor(UIColor.Yellow, 1.0f, 1.0f),
                                                                      SKAction.WaitForDuration(1.0),
                                                                      SKAction.ColorizeWithColorBlendFactor(0.0f, 1.0f)
                                                                      )));
        }
예제 #25
0
        void Explode()
        {
            for (int i = 0; i < numberOfChunks; i++)
            {
                float angle    = myRand(0, (float)Math.PI * 2);
                float speed    = myRand(shipChunkMinimumSpeed, shipChunkMaximumSpeed);
                var   position = new CGPoint(myRand((float)Position.X - shipChunkDispersion, (float)Position.Y + shipChunkDispersion),
                                             (nfloat)myRand((float)Position.Y - shipChunkDispersion, (float)Position.Y + shipChunkDispersion));
                var explosion = new ExplosionNode(Scene, position);
                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()
                          ));
        }
예제 #26
0
        // Do SKActions in a sequence on the given Sprite Node (wait, fade in, wait, fade out)
        private void DoActionSequenceOnNode(SKNode node, double waitSec, double fadeInSec, double waitSecMiddle, double fadeOutSec, nfloat maxAlpha)
        {
            SKAction sequence = SKAction.Sequence(SKAction.WaitForDuration(waitSec), SKAction.FadeAlphaTo(maxAlpha, fadeInSec), SKAction.WaitForDuration(waitSecMiddle), SKAction.FadeOutWithDuration(fadeOutSec));

            node.RunAction(sequence);
        }