Ejemplo n.º 1
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()
                          ));
        }
        private void HandlePanFrom(UIPanGestureRecognizer recognizer)
        {
            if (recognizer.State == UIGestureRecognizerState.Began)
            {
                PointF touchLocation = recognizer.LocationInView(recognizer.View);
                touchLocation = this.ConvertPointFromView(touchLocation);
                this.SelectNodeForTouch(touchLocation);
            }
            else if (recognizer.State == UIGestureRecognizerState.Changed)
            {
                PointF translation = recognizer.TranslationInView(recognizer.View);
                translation = new PointF(translation.X, -translation.Y);
                this.PanForTranslation(translation);
                recognizer.SetTranslation(new PointF(0, 0), recognizer.View);
            }
            else if (recognizer.State == UIGestureRecognizerState.Ended)
            {
                float scrollDuration = 0.2f;

                if (this.SelectedNode.Name != ANIMAL_NODE_NAME)
                {
                    PointF velocity = recognizer.VelocityInView(recognizer.View);
                    PointF p        = mult(velocity, scrollDuration);

                    PointF position = this.SelectedNode.Position;
                    PointF newPos   = new PointF(position.X + p.X, position.Y + p.Y);
                    newPos = this.BoundLayerPosition(newPos);
                    this.SelectedNode.RemoveAllActions();

                    SKAction moveTo = SKAction.MoveTo(newPos, scrollDuration);
                    moveTo.TimingMode = SKActionTimingMode.EaseOut;
                    this.SelectedNode.RunAction(moveTo);
                }
            }
        }
        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)
            });
        }
        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;
        }
        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 SelectNodeForTouch(PointF touchLocation)
        {
            // get the node that is on the posiion touchLocation
            SKSpriteNode touchedNode = (SKSpriteNode)this.GetNodeAtPoint(touchLocation);

            // if this is a new node being touched then stop all previous animation and set it as the selected node.
            if (this.SelectedNode != touchedNode)
            {
                if (this.SelectedNode != null)
                {
                    this.SelectedNode.RemoveAllActions();
                    this.SelectedNode.RunAction(SKAction.RotateToAngle(0.0f, 0.1));
                }

                this.SelectedNode = touchedNode;

                // if the node we've touched is an animal node then make it wiggle y0!
                if (touchedNode.Name == ANIMAL_NODE_NAME)
                {
                    SKAction sequence = SKAction.Sequence(new SKAction[] {
                        SKAction.RotateByAngle(this.DegreeToRadian(-4.0f), 0.1),
                        SKAction.RotateByAngle(0.0f, 0.1),
                        SKAction.RotateByAngle(this.DegreeToRadian(4.0f), 0.1)
                    });

                    this.SelectedNode.RunAction(SKAction.RepeatActionForever(sequence));
                }
            }
        }
Ejemplo n.º 7
0
        public void Finish()
        {
            currentScore.RunAction(SKAction.ScaleTo(0, 0.4), () =>
            {
                currentScore.Hidden = true;
            });

            gameBG.RunAction(SKAction.ScaleTo(0, 0.4), () =>
            {
                gameBG.Hidden   = true;
                gameLogo.Hidden = false;

                gameLogo.RunAction(SKAction.MoveTo(
                                       new CGPoint(
                                           x: Frame.GetMidX(),
                                           y: Frame.GetMidY() + (Frame.Size.Height / 2f) - 200),
                                       0.5), () =>
                {
                    playButton.Hidden = false;
                    playButton.RunAction(SKAction.ScaleTo(1, 0.3));

                    bestScore.RunAction(SKAction.MoveTo(
                                            new CGPoint(
                                                x: gameLogo.Position.X,
                                                y: gameLogo.Position.Y - 50),
                                            0.3));
                });
            });
        }
Ejemplo n.º 8
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)
            });
        }
Ejemplo n.º 9
0
        private void MoveToUpFromCenterClear()
        {
            spriteTopBg.RemoveAllActions();
            spriteTop.RemoveAllActions();

            spriteBelowBg.RemoveAllActions();
            spriteBelow.RemoveAllActions();

            navSpriteTop.RemoveAllActions();
            navLabelTop.RemoveAllActions();

            navSpriteBottom.RemoveAllActions();
            navLabelBottom.RemoveAllActions();

            SKAction actionTop        = SKAction.MoveToY((View.Frame.Height * 1.5f) - 60, 0.2);
            SKAction actionBelow      = SKAction.MoveToY((View.Frame.Height / 2) - 60, 0.2);
            SKAction actionBelowLabel = SKAction.MoveToY(View.Frame.Height - 100, 0.2);
            SKAction actionTopLabel   = SKAction.MoveToY(View.Frame.Height - 40, 0.2);

            spriteTopBg.RunAction(actionTop);
            spriteTop.RunAction(actionTop);

            spriteBelowBg.RunAction(actionBelow);
            spriteBelow.RunAction(actionBelow);

            navSpriteTop.RunAction(actionTopLabel);
            navLabelTop.RunAction(actionTopLabel);

            navSpriteBottom.RunAction(actionBelowLabel);
            navLabelBottom.RunAction(actionBelowLabel);

            gameMode = 1;
        }
Ejemplo n.º 10
0
        void StartGame()
        {
            Console.WriteLine("Start game");

            gameLogo.RunAction(SKAction.MoveTo(
                                   new CGPoint(
                                       x: Frame.GetMidX() - 50,
                                       y: Frame.GetMidY() + 600),
                                   0.5),
                               () => gameLogo.Hidden = true);

            bestScore.RunAction(SKAction.MoveTo(
                                    new CGPoint(
                                        x: Frame.GetMidX(),
                                        y: Frame.GetMidY() + (Frame.Size.Height / -2f) + 20),
                                    0.4));

            playButton.RunAction(SKAction.ScaleTo(0, 0.3),
                                 () => playButton.Hidden = true);

            gameBG.SetScale(0);
            currentScore.SetScale(0);
            gameBG.Hidden       = false;
            currentScore.Hidden = false;
            gameBG.RunAction(SKAction.ScaleTo(1, 0.4));
            currentScore.RunAction(SKAction.ScaleTo(1, 0.4));

            game.InitGame();
        }
Ejemplo n.º 11
0
        private void MoveToDownFromCenterClear()
        {
            spriteTopBg.RemoveAllActions();
            spriteTop.RemoveAllActions();

            spriteBelowBg.RemoveAllActions();
            spriteBelow.RemoveAllActions();

            navSpriteTop.RemoveAllActions();
            navLabelTop.RemoveAllActions();

            navSpriteBottom.RemoveAllActions();
            navLabelBottom.RemoveAllActions();

            SKAction actionTop        = SKAction.MoveToY((View.Frame.Height / 2) + 60, 0.2);
            SKAction actionBelow      = SKAction.MoveToY((0 - View.Frame.Height / 2) + 60, 0.2);
            SKAction actionBelowLabel = SKAction.MoveToY(0 + 20, 0.2);
            SKAction actionTopLabel   = SKAction.MoveToY(0 + 80, 0.2);

            spriteTopBg.RunAction(actionTop);
            spriteTop.RunAction(actionTop);

            spriteBelowBg.RunAction(actionBelow);
            spriteBelow.RunAction(actionBelow);

            navSpriteTop.RunAction(actionTopLabel);
            navLabelTop.RunAction(actionTopLabel);

            navSpriteBottom.RunAction(actionBelowLabel);
            navLabelBottom.RunAction(actionBelowLabel);

            gameMode = 2;
        }
        void OnDidBeginContact(object sender, EventArgs e)
        {
            var contact = (SKPhysicsContact)sender;
            // Either bodyA or bodyB in the collision could be a character.
            var node = contact.BodyA.Node as Character;

            if (node != null)
            {
                node.CollidedWith(contact.BodyB);
            }

            // Check bodyB too.
            node = contact.BodyB.Node as Character;
            if (node != null)
            {
                node.CollidedWith(contact.BodyA);
            }

            // Handle collisions with projectiles.
            var isBodyA = (contact.BodyA.CategoryBitMask & (uint)ColliderType.Projectile) != 0;
            var isBodyB = (contact.BodyB.CategoryBitMask & (uint)ColliderType.Projectile) != 0;

            if (isBodyA || isBodyB)
            {
                SKNode projectile = isBodyA ? contact.BodyA.Node : contact.BodyB.Node;
                projectile.RunAction(SKAction.RemoveFromParent());

                // Build up a "one shot" particle to indicate where the projectile hit.
                var emitter = (SKEmitterNode)SharedProjectileSparkEmitter.Copy();
                AddNode(emitter, WorldLayer.AboveCharacter);
                emitter.Position = projectile.Position;
                GraphicsUtilities.RunOneShotEmitter(emitter, 0.15f);
            }
        }
Ejemplo n.º 13
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) }) }) }));
        }
Ejemplo n.º 14
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) }));
 }
Ejemplo n.º 15
0
        protected virtual void CreateBullet(double offset)
        {
            var laserBeam = new PurpleLaser();

            laserBeam.Node.ZRotation =
                (nfloat)(owner.CurrentRotation + laserBeam.DefaultRotation);

            double radius = offset;

            double x = owner.Node.Position.X +
                       radius * Math.Cos(owner.CurrentRotation + Math.PI / 2);

            double y = owner.Node.Position.Y +
                       radius * Math.Sin(owner.CurrentRotation + Math.PI / 2);

            var finalPoint = new CGPoint(x, y);

            laserBeam.Node.Position = finalPoint;

            owner.Node.Scene?.AddChild(laserBeam.Node);

            owner.Controller.BulletsInScene.Add(laserBeam);

            laserBeam.Node.RunAction(SKAction.RepeatActionForever(CreateShootAction()));
        }
Ejemplo n.º 16
0
        // Remove the Info Text (fade out)
        private void ReleaseInfoText()
        {
            SKAction actionOut = SKAction.FadeOutWithDuration(0.2);

            infoLabel1.RemoveAllActions();
            infoLabel2.RemoveAllActions();
            infoLabel3.RemoveAllActions();
            infoLabel4.RemoveAllActions();
            infoLabel5.RemoveAllActions();
            infoLabel6.RemoveAllActions();
            infoLabel7.RemoveAllActions();
            infoNode.RemoveAllActions();
            infoNode2.RemoveAllActions();
            infoNode3.RemoveAllActions();
            cancelSpark.RemoveAllActions();
            teatimeSprite.RemoveAllActions();

            infoLabel1.RunAction(actionOut);
            infoLabel2.RunAction(actionOut);
            infoLabel3.RunAction(actionOut);
            infoLabel4.RunAction(actionOut);
            infoLabel5.RunAction(actionOut);
            infoLabel6.RunAction(actionOut);
            infoLabel7.RunAction(actionOut);
            infoNode.RunAction(actionOut);
            infoNode2.RunAction(actionOut);
            infoNode3.RunAction(actionOut);
            cancelSpark.RunAction(actionOut);
            teatimeSprite.RunAction(actionOut);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Анимация счета за уничтожение цепочки
        /// </summary>
        /// <param name="chain">Уничтожаемая цепочка.</param>
        private void AnimateScore(GemList chain)
        {
            SKSpriteNode firstGem = chain.GetFirstGem().Sprite;
            SKSpriteNode lastGem  = chain.GetLastGem().Sprite;

            CGPoint centerPoint = new CGPoint(
                (firstGem.Position.X + lastGem.Position.X) / 2,
                (firstGem.Position.Y + lastGem.Position.Y) / 2 - 8);

            SKLabelNode scoreLabel = new SKLabelNode("GillSans-BoldItalic")
            {
                FontSize  = 16,
                Text      = chain.GetScore() + "",
                Position  = centerPoint,
                ZPosition = 300
            };

            gemLayer.AddChild(scoreLabel);

            SKAction moveAction = SKAction.MoveBy(0, 3, 0.7);

            //.Move(by: CGVector(dx: 0, dy: 3), duration: 0.7)
            moveAction.TimingMode = SKActionTimingMode.EaseOut;
            scoreLabel.RunAction(SKAction.Sequence(moveAction, SKAction.RemoveFromParent()));
        }
Ejemplo n.º 18
0
        public void ShowScanAction()
        {
            var size = base.Size;

            _scanText1 = new SKLabelNode("AppleSDGothicNeo-Regular")
            {
                Text     = "Move your phone",
                FontSize = 30,
                Position = new CGPoint(size.Width / 2, 100),
                Color    = UIColor.White,
            };
            AddChild(_scanText1);

            _scanText2 = new SKLabelNode("AppleSDGothicNeo-Regular")
            {
                Text     = "to find a surface",
                FontSize = 30,
                Position = new CGPoint(size.Width / 2, 70),
                Color    = UIColor.White,
            };
            AddChild(_scanText2);

            _phone          = SKSpriteNode.FromImageNamed("phone_scaled");
            _phone.Position = new CGPoint(size.Width / 2, 190);

            var circle        = UIBezierPath.FromRoundedRect(new CGRect(new CGPoint(size.Width / 2 - 20, 190), new CGSize(40, 40)), 20);
            var moveAlongPath = SKAction.RepeatActionForever(SKAction.FollowPath(circle.CGPath, false, false, 2.0));

            _phone.RunAction(moveAlongPath);

            AddChild(_phone);

            ScanActionShowing  = true;
            ScanActionFinished = false;
        }
Ejemplo n.º 19
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins

            // control player motion
            var moveRight = SKAction.RepeatActionForever(SKAction.MoveBy(75.0f, 0, 2.0f));
            var moveLeft  = SKAction.RepeatActionForever(SKAction.MoveBy(-75.0f, 0, 2.0f));

            base.TouchesBegan(touches, evt);
            var touch = (UITouch)touches.AnyObject;

            playerMove(touch);

            // detects left and right screen taps, moves player accordingly
            void playerMove(UITouch location)
            {
                if (touch.LocationInNode(this).X > (Frame.Width / 2))
                {
                    playerObject.RunAction(moveRight);
                }
                if (touch.LocationInNode(this).X < (Frame.Width / 2))
                {
                    playerObject.RunAction(moveLeft);
                }
                Console.WriteLine(touch.LocationInNode(this));
            }
        }
Ejemplo n.º 20
0
 private void HideSlidersMenu()
 {
     foreach (var slider in this.dofSliders)
     {
         slider.RunAction(SKAction.FadeOutWithDuration(Duration));
     }
 }
Ejemplo n.º 21
0
        public void SetStartupPosition(nfloat width, nfloat height)
        {
            Sprite.Position = new CGPoint(width / 2.5, height / 2);
            var action = SKAction.MoveBy(0, GRAVITY, 1);

            Sprite.RunAction(SKAction.RepeatActionForever(action));
        }
Ejemplo n.º 22
0
        // Show the congratulation screen.
        void ShowCongratulation()
        {
            var gNodes = gameNodes.Value;

            gNodes.Camera.UsesOrthographicProjection = false;

            sceneInterface.Scene.Background.Contents = UIColor.Black;

            gNodes.Confetti.Hidden = false;
            particleRemovalTimer?.Invalidate();
            particleRemovalTimer = NSTimer.CreateScheduledTimer(30, RemoveParticles);

            gNodes.CongratulationsLabel.RemoveFromParent();
            gNodes.CongratulationsLabel.Position = new CGPoint(ContentFrame.Width / 2, ContentFrame.Height / 2);
            gNodes.CongratulationsLabel.XScale   = 0;
            gNodes.CongratulationsLabel.YScale   = 0;
            gNodes.CongratulationsLabel.Alpha    = 0;

            gNodes.CongratulationsLabel.RunAction(SKAction.Group(new SKAction [] {
                SKAction.FadeInWithDuration(0.25),
                SKAction.Sequence(new SKAction [] {
                    SKAction.ScaleTo(0.7f, 0.25),
                    SKAction.ScaleTo(0.8f, 0.2)
                })
            }));

            sceneInterface.OverlayScene.AddChild(gNodes.CongratulationsLabel);
        }
Ejemplo n.º 23
0
        void animateobstacle4()
        {
            var textures = Enumerable.Range(1, 4).Select(
                (i) => SKTexture.FromImageNamed(String.Format("trash-{0}", i))).ToArray();

            obstacleflame4 = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1));
            obstacle4.RunAction(obstacleflame4);
        }
Ejemplo n.º 24
0
        // definition of player walking animation
        void animatePlayer()
        {
            var textures = Enumerable.Range(1, 4).Select(
                (i) => SKTexture.FromImageNamed(String.Format("Stumbler-{0}", i))).ToArray();

            playerAnimate = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1));
            playerObject.RunAction(playerAnimate);
        }
        public void LeftPedal()
        {
            //1)UPDATE THE HEADING CCW
            this.Heading = (this.Heading + 5) % 360;
            var action1 = SKAction.RotateByAngle(this.Heading, 1.0);

            this.PlayerSpriteObject.RunAction(action1);
        }
        public void FaceTo(CGPoint position)
        {
            var      angle  = GraphicsUtilities.RadiansBetweenCGPoints(position, Position);
            var      ang    = GraphicsUtilities.PalarAdjust(angle);
            SKAction action = SKAction.RotateToAngle(ang, 0);

            RunAction(action);
        }
Ejemplo n.º 27
0
        void animateEnemy()
        {
            var textures = Enumerable.Range(1, 4).Select(
                (i) => SKTexture.FromImageNamed(String.Format("walker-{0}", i))).ToArray();

            enemyAnimate = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1));
            enemy.RunAction(enemyAnimate);
        }
Ejemplo n.º 28
0
        protected override void Move()
        {
            var action1     = SKAction.MoveBy(-50, 75, 0.5);
            var action2     = SKAction.MoveBy(-50, -75, 0.5);
            var seq         = SKAction.Sequence(action1, action2);
            var finalAction = SKAction.RepeatActionForever(seq);

            Node.RunAction(finalAction);
        }
        public void RotatePlayer_Pitch()
        {
            int    pitch1  = this.Pitch;
            double radians = pitch1 * Math.PI / 180;
            var    action1 = SKAction.RotateToAngle((float)radians, 1.0);

            //HAVE PLAYER MOVE TO ROTATED ANGLE
            this.PlayerSpriteObject.RunAction(action1);
        }
Ejemplo n.º 30
0
        public void textScaling(SKLabelNode scaled)
        {
            var up = SKAction.ScaleBy(1.2f, 0.8f);
            //var down = SKAction.ScaleBy (0.8f, 0.5f);
            var seq  = SKAction.Sequence(new SKAction[] { up, up.ReversedAction });        //({up,down});
            var fort = SKAction.RepeatActionForever(seq);

            scaled.RunAction(fort);
        }
Ejemplo n.º 31
0
        public MonkeyScene(SizeF size)
            : base(size)
        {
            monkey = SKSpriteNode.FromImageNamed ("frame-1");
            monkey.Position = new PointF (Size.Width / 2, Size.Height / 2);
            AddChild (monkey);

            var textures = Enumerable.Range (1, 8).Select (
                (i) => SKTexture.FromImageNamed (String.Format ("frame-{0}", i))).ToArray ();

             	animate = SKAction.RepeatActionForever (SKAction.AnimateWithTextures (textures, 0.1));
        }
Ejemplo n.º 32
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");

            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)
            });
        }
Ejemplo n.º 33
0
        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)
            });
        }
Ejemplo n.º 34
0
 public static void LoadSharedAssetsOnce()
 {
     sharedProjectileSoundAction = SKAction.PlaySoundFileNamed ("magicmissile.caf", false);
     sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("Death");
     sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed ("Damage");
 }
Ejemplo n.º 35
0
        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)
            });
        }