Ejemplo n.º 1
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.º 2
0
        /// <summary>
        /// Render the buttons.
        /// </summary>
        void RenderButtons()
        {
            var start_button = Button.CreateButtonAt(
                SKTexture.FromImageNamed(START_BUTTON_IMAGE),
                SKTexture.FromImageNamed(START_PRESSED_BUTTON_IMAGE),
                "start",
                new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 1.25)
                );
            var settings_button = Button.CreateButtonAt(
                SKTexture.FromImageNamed(SETTINGS_BUTTON_IMAGE),
                SKTexture.FromImageNamed(SETTINGS_PRESSED_BUTTON_IMAGE),
                "settings",
                new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 0.75)
                );
            var exit_button = Button.CreateButtonAt(
                SKTexture.FromImageNamed(EXIT_BUTTON_IMAGE),
                SKTexture.FromImageNamed(EXIT_PRESSED_BUTTON_IMAGE),
                "exit",
                new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 0.25)
                );

            AddChild(start_button);
            AddChild(settings_button);
            AddChild(exit_button);
        }
Ejemplo n.º 3
0
        public LeaderboardScoresScreen(CGSize size) : base(size)
        {
            SKLabelNode title = new SKLabelNode("GillSans-Bold")
            {
                Text     = GameInfo.CurrentLeaderBoard.Title,
                FontSize = 14,
                Position = new CGPoint(FrameMidX, FrameMidY + 190)
            };

            var podiumSprite = SKSpriteNode.FromTexture(SKTexture.FromImageNamed("Images/Podium.png"));

            podiumSprite.Position = new CGPoint(FrameMidX, FrameMidY + 50);

            backButton = new SKLabelNode("GillSans-Bold")
            {
                Text      = "Back",
                FontSize  = 18,
                FontColor = ButtonColor,
                Position  = new CGPoint(FrameMidX, FrameMidY - 200)
            };

            if (GKLocalPlayer.LocalPlayer.Authenticated)
            {
                LoadLeaderboardScoresInfo(GameInfo.CurrentLeaderBoard);
            }

            AddChild(title);
            AddChild(backButton);
            AddChild(podiumSprite);
        }
Ejemplo n.º 4
0
        public BasicScene(CGSize size) : base(size)
        {
            ScaleMode = SKSceneScaleMode.AspectFill;

            //BackgroundColor = UIColor.FromRGBA (0.15f, 0.15f, 0.3f, 1f);


            bgr          = new SKSpriteNode(SKTexture.FromImageNamed("brickwall1"));
            bgr.Size     = Size;
            bgr.Position = new CGPoint(Size.Width / 2, Size.Height / 2);

            AddChild(bgr);


            UnselectedColor = UIColor.FromRGBA(0f, 0.5f, 0.5f, 1f);
            SelectedColor   = UIColor.FromRGBA(0.5f, 1f, 0.99f, 1f);

            ButtonColor = UIColor.FromRGBA(1f, 1f, 0f, 1f);
            InfoColor   = UIColor.FromRGBA(1f, 1f, 1f, 1f);

            FrameMidX = (float)Frame.GetMidX();
            FrameMidY = (float)Frame.GetMidY();

            transition = SKTransition.MoveInWithDirection(SKTransitionDirection.Right, 0.3);
        }
        public void SetPlayerDirection()
        {
            byte direction = 0;

            direction = GetDirection();
            this.dir  = direction;
            //all SIde E for now as the sprite pictures need to be redrawn
            switch (direction)
            {
            case 1:
                this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideE", "png"));
                break;

            case 2:
                this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideW", "png"));
                break;

            case 3:
                this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideW", "png"));
                break;

            case 4:
                this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideE", "png"));
                break;
            }
        }
Ejemplo n.º 6
0
        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"));
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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.º 9
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.º 10
0
        public void addItemBackground(CGPoint itemPos)
        {
            var bottleCap = new SKSpriteNode(SKTexture.FromImageNamed("capitem1"));

            bottleCap.SetScale(0.4f);
            bottleCap.Position = itemPos;
            AddChild(bottleCap);
        }
 public UtilityHelo()
 {
     this.MachineGun = new Bullets[50];
     for (int i = 0; i < this.MachineGun.Length; i += 1)
     {
         this.MachineGun[i] = new Bullets();
         this.MachineGun[i].Bullet.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("BulletImage_small", "png"));
     }
 }
Ejemplo n.º 12
0
 public Bullets()
 {
     this.x_world = 0;
     this.y_world = 0;
     this.Bullet  = new SKSpriteNode(
         SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("bullet", "png")));
     this.isFired      = false;
     this.damageCaused = 5;
 }
Ejemplo n.º 13
0
 public bool DidCollectAFlower()
 {
     if (flowerCount < 3)
     {
         flowers [flowerCount].Texture = SKTexture.FromImageNamed("Images/FlowerFull.png");
     }
     flowerCount++;
     return(flowerCount == 3);
 }
Ejemplo n.º 14
0
        public PointNode(string name)
        {
            UIImage image = UIImage.FromBundle(name);

            Name      = name;
            ZPosition = 12;
            Texture   = SKTexture.FromImageNamed((name));
            Size      = image.Size;
        }
Ejemplo n.º 15
0
 public void Texture()
 {
     using (var t = SKTexture.FromImageNamed("basn3p08.png"))
         using (var n = new SKSpriteNode(t)) {
             Assert.AreSame(n.Texture, t, "Texture-1");
             n.Texture = null;
             Assert.IsNull(n.Texture, "Texture-2");
         }
 }
Ejemplo n.º 16
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins
            foreach (var touch in touches)
            {
                UITouch touchc = touches.AnyObject as UITouch;

                // Check click
                var locationc = touchc.LocationInNode(this);
                var checkX    = touchc.LocationInView(View).X;
                var checkY    = touchc.LocationInView(View).Y;

                // other coordinate system
                //var checkX = ((UITouch)touchc).LocationInNode(this).X;
                //var checkY = ((UITouch)touchc).LocationInNode(this).Y;

                // Get Sprite Node at current location
                var nodeAtLocation = GetNodeAtPoint(locationc);
                if (nodeAtLocation.Name == "cancelSpark")
                {
                    ReleaseInfoText();
                }
                else
                {
                    if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel")
                    {
                        // If the info button is clicked change background
                        if (nodeAtLocation.Name == "info" || nodeAtLocation.Name == "navSprite")
                        {
                            infoTouch = true;

                            // Activate information background
                            if (switchInfo == false)
                            {
                                //setInfoText();
                                container.Alpha = 1f;
                                switchInfo      = true;

                                SKAction seqTextureInfo = SKAction.SetTexture(SKTexture.FromImageNamed(("inforeverse")));
                                infoSprite.RunAction((seqTextureInfo));
                            }

                            // Deactivate information background
                            else
                            {
                                container.Alpha = 0f;
                                switchInfo      = false;

                                SKAction seqTextureInfoNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("info")));
                                infoSprite.RunAction((seqTextureInfoNormal));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public virtual void Draw(GameScene scene)
        {
            if (SkNode == null)
            {
                SkNode = new SKSpriteNode(SKTexture.FromImageNamed("Ball"), UIColor.Clear, new CGSize(5, 5));
                scene.AddChild(SkNode);
            }

            SkNode.RunAction(SKAction.MoveTo(new CGPoint(X - (Z / Math.Sqrt(2.0)), Y - (Z / Math.Sqrt(2.0))), 0.5));
        }
Ejemplo n.º 18
0
 public EnemySprite()
 {
     Texture     = SKTexture.FromImageNamed(ENEMY_DUTY_IMAGE);
     Size        = Texture.Size;
     PhysicsBody = SKPhysicsBody.CreateRectangularBody(Size);
     PhysicsBody.AllowsRotation     = false;
     PhysicsBody.CategoryBitMask    = CollisionCategory.Enemy;
     PhysicsBody.ContactTestBitMask = CollisionCategory.Hero | CollisionCategory.Spell | CollisionCategory.Platform;
     PhysicsBody.CollisionBitMask  ^= CollisionCategory.Spell;
 }
        SKTexture [] LoadFrames(string baseImageName, int frameCount)
        {
            var frames = new SKTexture [frameCount];

            for (int i = 1; i <= frameCount; i++)
            {
                frames [i - 1] = SKTexture.FromImageNamed(baseImageName + i.ToString("0000"));
            }
            return(frames);
        }
Ejemplo n.º 20
0
        public Tanks()
        {
            this.enemySprite = new SKSpriteNode(
                SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("Tank", "png")));
            this.Cannon = new Bullets[12];

            this.MAXhSPEED    = 25;
            this.MAXvSPEED    = 25;
            this.pitch_cannon = 0;
        }
Ejemplo n.º 21
0
        // Function that detects the key pressed

        /*
         * public void Form1_KeyPress(object sender, KeyPressEventArgs e)
         * {
         *  if (e.KeyChar == 'w' || e.KeyChar == 'W')
         *  {
         *      Debug.WriteLine("detected");
         *      //do something
         *  }
         * }
         */
        // Function that performs the movement
        public void movement(ref Sprite[,,] sprites, ref Sprite.Entity player1, string sprite, ref CGPoint change, nfloat unit, int i, int j, nfloat Height, nfloat Width)
        {
            // Change sprite
            player1.spriteNode.Texture = SKTexture.FromImageNamed(sprite);
            int x = (int)((player1.actualX + i * 4) / 15);
            int y = (int)((player1.actualY + j * 4) / 15);

            Debug.WriteLine("Current pos: {0},{1}", player1.actualX, player1.actualY);
            Debug.WriteLine("Checker pos: {0},{1}", player1.actualX + 4 * i, player1.actualY + 4 * j);
            Debug.WriteLine("Destination: {0},{1}", player1.actualX + i * (3.75), player1.actualY + j * (3.75));
            Debug.WriteLine("Change: {0},{1}", x, y);
            sprites[player1.xPos, player1.yPos, player1.zPos] = null;
            // Checks if move is out of bounds
            if ((0 > player1.actualX + 4 * i | player1.actualX + 4 * i >= 15 * sprites.GetLength(0)) | (0 > player1.actualY + 4 * j | player1.actualY + 4 * j >= 15 * sprites.GetLength(1)))
            {
                Debug.WriteLine("Successfully prevented player from moving out of area");
            }

            // Moves player in the desired direction on the current floor
            else if ((sprites[x, y, player1.zPos] == null || !sprites[x, y, player1.zPos].Solid) & (player1.zPos == 0 || sprites[x, y, player1.zPos - 1] != null))
            {
                Debug.WriteLine("Moved in desired direction");
                player1.actualX += 3.75 * i; player1.xPos = (int)(player1.actualX / 15); change.X = i * unit;
                player1.actualY += 3.75 * j; player1.yPos = (int)(player1.actualY / 15); change.Y = j * unit;
            }

            // Moves a player in the desired direction and falls
            else if (player1.zPos > 0 && sprites[player1.xPos + i, player1.yPos + j, player1.zPos - 1] == null)
            {
                Debug.WriteLine("Moved in desired direction and fell");
                player1.actualX += 3.75 * i; player1.xPos = (int)(player1.actualX / 15); change.X = i * unit;
                player1.actualY += 3.75 * j; player1.yPos = (int)(player1.actualY / 15); change.Y = j * unit;
                while (player1.zPos > 0 && sprites[player1.xPos, player1.yPos, player1.zPos - 1] == null)
                {
                    player1.zPos--; player1.spriteNode.Position = new CGPoint(player1.spriteNode.Position.X, player1.spriteNode.Position.Y - (4 * Height / 150));
                }
            }

            // Moves player 1 up a floor whilst moving in the desired direction
            else if (sprites[x, y, player1.zPos].GetClimbable() && sprites[x, y, player1.zPos].GetHeight() - player1.zPos == 1)
            {
                Debug.WriteLine("Moved in desired direction and climbed");
                player1.spriteNode.Position = new CGPoint(player1.spriteNode.Position.X, player1.spriteNode.Position.Y + (4 * Height / 150));;
                player1.actualX            += 3.75 * 2 * i; player1.xPos = (int)(player1.actualX / 15); change.X = 2 * i * unit;
                player1.actualY            += 3.75 * 2 * j; player1.yPos = (int)(player1.actualY / 15); change.Y = 2 * j * unit;
                player1.zPos++;
            }
            else
            {
                Debug.WriteLine("Error");
            }
            player1.spriteNode.ZPosition = player1.defaultZ + 4 * (9 - (int)((player1.actualY) / 15)) + 6 * (player1.zPos) - 1;
            Debug.WriteLine("Current height: {0}", player1.zPos);
        }
Ejemplo n.º 22
0
        public LineNode(string name)
        {
            // Generate Line Node
            UIImage image = UIImage.FromBundle("line");

            Name      = name;
            ZPosition = 12;
            Texture   = SKTexture.FromImageNamed(("line"));
            Size      = image.Size;
            RndMove   = false;
        }
Ejemplo n.º 23
0
        public SpriteLoader(string folder = ".")
        {
            string[] _spritePaths = NSBundle.MainBundle.PathsForResources("png", folder);
            foreach (var spriteLocation in _spritePaths)
            {
                var lastSlash = spriteLocation.LastIndexOf('/');
                var newString = spriteLocation.Substring(lastSlash + 1);

                var spriteName = newString.Substring(0, newString.Length - 4);

                Sprites.Add(spriteName, SKTexture.FromImageNamed(spriteLocation));
            }
        }
 public Towers(int NumGuard)
 {
     this.tower = new SKSpriteNode(
         SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("TowerEnemies", "png")));
     this.x_world       = (int)this.tower.Position.X;
     this.y_world       = (int)this.tower.Position.Y;
     this.lives         = (byte)(NumGuard * 2);
     this.GuardMagazine = new Bullets[NumGuard];
     for (int i = 0; i < this.GuardMagazine.Length; i += 1)
     {
         this.GuardMagazine[i] = new Bullets();
     }
 }
 public Towers()
 {
     this.numberofguards = 10;
     this.lives          = (byte)(this.numberofguards * 2);
     this.x_world        = 0;
     this.y_world        = 0;
     this.tower          = new SKSpriteNode(
         SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("TowerEnemies", "png")));
     this.GuardMagazine = new Bullets[8];
     for (int i = 0; i < this.GuardMagazine.Length; i += 1)
     {
         this.GuardMagazine[i]             = new Bullets();
         this.GuardMagazine[i].Bullet.Name = "Tower_" + "Bullet_" + i.ToString();
     }
 }
Ejemplo n.º 26
0
        public HeroSprite()
        {
            _heroJump   = SKTexture.FromImageNamed(HERO_JUMP_IMAGE);
            _heroStand  = SKTexture.FromImageNamed(HERO_STAND_IMAGE);
            _heroMoving = SKTexture.FromImageNamed(HERO_MOVING_IMAGE);

            Texture     = _heroStand;
            Size        = Texture.Size;
            PhysicsBody = SKPhysicsBody.CreateRectangularBody(Size);
            PhysicsBody.CategoryBitMask    = CollisionCategory.Hero;
            PhysicsBody.ContactTestBitMask = CollisionCategory.Enemy | CollisionCategory.Spell;
            // XOR Spell bitmask to avoid collision
            PhysicsBody.CollisionBitMask ^= CollisionCategory.Spell;
            PhysicsBody.AllowsRotation    = false;
        }
Ejemplo n.º 27
0
        public void Draw(SKScene scene, double sec)
        {
            if (_skNode == null)
            {
                _skNode = new SKSpriteNode(SKTexture.FromImageNamed("Ball"), UIColor.Clear, new CGSize(5, 5));
                scene.AddChild(_skNode);
            }

            _skNode.RunAction(SKAction.MoveTo(new CGPoint(
                                                  OffsetFromZero[0] - (OffsetFromZero[2] / Math.Sqrt(2.0)),
                                                  OffsetFromZero[1] - (OffsetFromZero[2] / Math.Sqrt(2.0))), sec));

            foreach (var child in Children)
            {
                child.Draw(scene, sec);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Подсвечивание выбранного камешка заменой текстуры в спрайте
        /// </summary>
        /// <param name="gem">Камешек на подстветку.</param>
        private void ShowSelectionIndicator(Gem gem)
        {
            // Открепляем спрайт от родителя, если он есть
            if (selectedSprite.Parent != null)
            {
                selectedSprite.RemoveFromParent();
            }

            SKSpriteNode sprite  = gem.Sprite;
            SKTexture    texture = SKTexture.FromImageNamed(gem.GetSelectedSpriteName());

            selectedSprite.Size = new CGSize(gemCellWidth, gemCellHeight);
            selectedSprite.RunAction(SKAction.SetTexture(texture));

            // "Подсветка" добавляется в качестве потомка к основному спрайту камешка
            sprite.AddChild(selectedSprite);
            selectedSprite.Alpha = 1.0f;
        }
Ejemplo n.º 29
0
        public Kuma(SKScene sceen, CGPoint location, CGSize size)
        {
            _textures = new SKTexture[ImageMax];
            for (var i = 0; i < ImageMax; i++)
            {
                _textures[i] = SKTexture.FromImageNamed(String.Format("Image{0}", i));
            }

            _node             = SKSpriteNode.FromTexture((SKTexture)_textures[0]);
            _node.AnchorPoint = new CGPoint(0, 0);
            _node.Position    = location;
            _node.Size        = size;
            _node.ZPosition   = 0;
            sceen.AddChild(_node);

            _locationX = location.X;
            _locationY = location.Y;
            _width     = size.Width;
        }
Ejemplo n.º 30
0
        // テクスチャから初期化する
        // w 横の画像数
        // h 縦の画像数
        public AnimationNode(String name, int w, int h, double sec, CGSize size)
        {
            textures = new SKTexture[w * h];
            var texture = SKTexture.FromImageNamed(name);
            var c       = 0;

            for (var y = h - 1; y >= 0; y--)
            {
                for (var x = 0; x < w; x++)
                {
                    textures[c++] = SKTexture.FromRectangle(new CGRect(x / (float)w, y / (float)h, 1 / (float)w, 1 / (float)h), texture);
                }
            }
            node           = SKSpriteNode.FromTexture((SKTexture)textures[0]);
            node.Size      = size;
            node.ZPosition = 1;
            node.Position  = new CGPoint(-100, -100);
            action         = SKAction.AnimateWithTextures((SKTexture[])textures, sec);
        }